Skip to content

Commit e96f941

Browse files
committed
use optionLabels in all question types
1 parent 7fe999d commit e96f941

13 files changed

+23
-9
lines changed

web/src/components/questions/GenericQuestion.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const question: Question = {
3030
id: 1,
3131
text: "Do you write unit tests?",
3232
options: ["always", "sometimes", "never"],
33+
optionLabels: ["Always", "Sometimes", "Never"],
3334
defaultOption: "sometimes",
3435
};
3536

web/src/components/questions/GenericQuestion.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export default function GenericQuestion({
5151
<Popup.Actions>
5252
<QuestionActions
5353
actions={question.options}
54+
actionLabels={question.optionLabels}
5455
defaultAction={question.defaultOption}
5556
actionCallback={actionCallback}
5657
/>

web/src/components/questions/LuksActivationQuestion.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const questionMock: Question = {
3434
class: "storage.luks_activation",
3535
text: "A Luks device found. Do you want to open it?",
3636
options: ["decrypt", "skip"],
37+
optionLabels: ["Decrypt", "Skip"],
3738
defaultOption: "decrypt",
3839
data: { attempt: "1" },
3940
};

web/src/components/questions/LuksActivationQuestion.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export default function LuksActivationQuestion({ question, answerCallback }) {
8888
<Popup.Actions>
8989
<QuestionActions
9090
actions={question.options}
91+
actionLabels={question.optionLabels}
9192
defaultAction={defaultAction}
9293
actionCallback={actionCallback}
9394
conditions={conditions}

web/src/components/questions/PackageErrorQuestion.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const question: Question = {
3232
class: "software.package_error.provide_error",
3333
text: "Package download failed",
3434
options: ["Retry", "Skip"],
35+
optionLabels: ["Retry", "Skip"],
3536
defaultOption: "Retry",
3637
data: { package: "foo", error_code: "INVALID" },
3738
};

web/src/components/questions/PackageErrorQuestion.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export default function PackageErrorQuestion({
6969
<Popup.Actions>
7070
<QuestionActions
7171
actions={question.options}
72+
actionLabels={question.optionLabels}
7273
defaultAction={question.defaultOption}
7374
actionCallback={actionCallback}
7475
/>

web/src/components/questions/QuestionActions.test.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ let question: Question = {
3232
id: 1,
3333
text: "Should we use a component for rendering actions?",
3434
options: ["no", "maybe", "sure"],
35+
optionLabels: ["Nein", "Vielleicht", "Sicher"],
3536
defaultOption,
3637
};
3738

@@ -41,6 +42,7 @@ const renderQuestionActions = () =>
4142
installerRender(
4243
<QuestionActions
4344
actions={question.options}
45+
actionLabels={question.optionLabels}
4446
defaultAction={question.defaultOption}
4547
actionCallback={actionCallback}
4648
conditions={{ disable: { no: true } }}
@@ -52,17 +54,17 @@ describe("QuestionActions", () => {
5254
it("renders the default option as primary action", async () => {
5355
renderQuestionActions();
5456

55-
const button = await screen.findByRole("button", { name: "Sure" });
57+
const button = await screen.findByRole("button", { name: "Sicher" });
5658
expect(button.classList.contains("pf-m-primary")).toBe(true);
5759
});
5860

5961
it("renders non default options as secondary actions", async () => {
6062
renderQuestionActions();
6163

62-
let button = await screen.findByRole("button", { name: "Maybe" });
64+
let button = await screen.findByRole("button", { name: "Vielleicht" });
6365
expect(button.classList.contains("pf-m-secondary")).toBe(true);
6466

65-
button = await screen.findByRole("button", { name: "No" });
67+
button = await screen.findByRole("button", { name: "Nein" });
6668
expect(button.classList.contains("pf-m-secondary")).toBe(true);
6769
});
6870
});
@@ -77,35 +79,35 @@ describe("QuestionActions", () => {
7779
it("renders the first option as primary action", async () => {
7880
renderQuestionActions();
7981

80-
const button = await screen.findByRole("button", { name: "No" });
82+
const button = await screen.findByRole("button", { name: "Nein" });
8183
expect(button.classList.contains("pf-m-primary")).toBe(true);
8284
});
8385

8486
it("renders the other options as secondary actions", async () => {
8587
renderQuestionActions();
8688

87-
let button = await screen.findByRole("button", { name: "Maybe" });
89+
let button = await screen.findByRole("button", { name: "Vielleicht" });
8890
expect(button.classList.contains("pf-m-secondary")).toBe(true);
8991

90-
button = await screen.findByRole("button", { name: "Sure" });
92+
button = await screen.findByRole("button", { name: "Sicher" });
9193
expect(button.classList.contains("pf-m-secondary")).toBe(true);
9294
});
9395
});
9496

9597
it("renders actions enabled or disabled according to given conditions", async () => {
9698
renderQuestionActions();
9799

98-
let button = await screen.findByRole("button", { name: "No" });
100+
let button = await screen.findByRole("button", { name: "Nein" });
99101
expect(button).toHaveAttribute("disabled");
100102

101-
button = await screen.findByRole("button", { name: "Maybe" });
103+
button = await screen.findByRole("button", { name: "Vielleicht" });
102104
expect(button).not.toHaveAttribute("disabled");
103105
});
104106

105107
it("calls the actionCallback when user clicks on action", async () => {
106108
const { user } = renderQuestionActions();
107109

108-
const button = await screen.findByRole("button", { name: "Sure" });
110+
const button = await screen.findByRole("button", { name: "Sicher" });
109111
await user.click(button);
110112

111113
expect(actionCallback).toHaveBeenCalled();

web/src/components/questions/QuestionWithPassword.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const question: Question = {
3434
class: "question.password",
3535
text: "Random question. Will you provide random password?",
3636
options: ["ok", "cancel"],
37+
optionLabels: ["Ok", "Cancel"],
3738
defaultOption: "cancel",
3839
};
3940

web/src/components/questions/QuestionWithPassword.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export default function QuestionWithPassword({
7575
<Popup.Actions>
7676
<QuestionActions
7777
actions={question.options}
78+
actionLabels={question.optionLabels}
7879
defaultAction={defaultAction}
7980
actionCallback={actionCallback}
8081
/>

web/src/components/questions/Questions.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const genericQuestion: Question = {
4949
type: QuestionType.generic,
5050
text: "Do you write unit tests?",
5151
options: ["always", "sometimes", "never"],
52+
optionLabels: ["Always", "Sometimes", "Never"],
5253
defaultOption: "sometimes",
5354
};
5455
const passwordQuestion: Question = { id: 1, type: QuestionType.withPassword };

0 commit comments

Comments
 (0)