add text question preview test
This commit is contained in:
parent
4631f6098a
commit
930386b9c8
@ -28,7 +28,7 @@ describe("Quiz preview", () => {
|
|||||||
|
|
||||||
it("should contain title and options, and be selected properly", () => {
|
it("should contain title and options, and be selected properly", () => {
|
||||||
cy.get("[data-cy=quiz-preview-layout]").within(() => {
|
cy.get("[data-cy=quiz-preview-layout]").within(() => {
|
||||||
cy.get("[data-cy=variant-title]").should("have.text", "Question Title");
|
cy.get("[data-cy=question-title]").should("have.text", "Question Title");
|
||||||
cy.get("[data-cy=variant-answer]").eq(0).should("have.text", "Answer 1");
|
cy.get("[data-cy=variant-answer]").eq(0).should("have.text", "Answer 1");
|
||||||
cy.get("[data-cy=variant-answer]").eq(1).should("have.text", "Answer 2");
|
cy.get("[data-cy=variant-answer]").eq(1).should("have.text", "Answer 2");
|
||||||
cy.get("[data-cy=variant-answer]").eq(2).should("have.text", "Answer 3");
|
cy.get("[data-cy=variant-answer]").eq(2).should("have.text", "Answer 3");
|
||||||
@ -159,7 +159,7 @@ describe("Quiz preview", () => {
|
|||||||
|
|
||||||
it("should contain title and options, and be selected properly", () => {
|
it("should contain title and options, and be selected properly", () => {
|
||||||
cy.get("[data-cy=quiz-preview-layout]").within(() => {
|
cy.get("[data-cy=quiz-preview-layout]").within(() => {
|
||||||
cy.get("[data-cy=variant-title]").should("have.text", "Question Title");
|
cy.get("[data-cy=question-title]").should("have.text", "Question Title");
|
||||||
cy.get("[data-cy=variant-answer]").eq(0).should("have.text", "Answer 1");
|
cy.get("[data-cy=variant-answer]").eq(0).should("have.text", "Answer 1");
|
||||||
cy.get("[data-cy=variant-answer]").eq(1).should("have.text", "Answer 2");
|
cy.get("[data-cy=variant-answer]").eq(1).should("have.text", "Answer 2");
|
||||||
cy.get("[data-cy=variant-answer]").eq(2).should("have.text", "Answer 3");
|
cy.get("[data-cy=variant-answer]").eq(2).should("have.text", "Answer 3");
|
||||||
@ -237,7 +237,7 @@ describe("Quiz preview", () => {
|
|||||||
const emojiRegex = "(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])";
|
const emojiRegex = "(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])";
|
||||||
|
|
||||||
cy.get("[data-cy=quiz-preview-layout]").within(() => {
|
cy.get("[data-cy=quiz-preview-layout]").within(() => {
|
||||||
cy.get("[data-cy=variant-title]").should("have.text", "Question Title");
|
cy.get("[data-cy=question-title]").should("have.text", "Question Title");
|
||||||
cy.get("[data-cy=variant-answer]").eq(0).invoke("text").should("match",
|
cy.get("[data-cy=variant-answer]").eq(0).invoke("text").should("match",
|
||||||
new RegExp(`${emojiRegex} Answer 1`)
|
new RegExp(`${emojiRegex} Answer 1`)
|
||||||
);
|
);
|
||||||
@ -265,4 +265,23 @@ describe("Quiz preview", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("Text question", () => {
|
||||||
|
beforeEach(function setupQuestion() {
|
||||||
|
cy.get("[data-cy=select-questiontype-text]").click();
|
||||||
|
cy.get("[data-cy=quiz-question-card]").eq(0).within(() => {
|
||||||
|
cy.get("[data-cy=quiz-question-title]").type("Question Title");
|
||||||
|
cy.get("[data-cy=textfield]").type("Suggestion");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should contain title and textfield, that can be filled", () => {
|
||||||
|
cy.get("[data-cy=quiz-preview-layout]").within(() => {
|
||||||
|
cy.get("[data-cy=question-title]").should("have.text", "Question Title");
|
||||||
|
cy.get("[data-cy=textfield] input").should("have.attr", "placeholder", "Suggestion");
|
||||||
|
cy.get("[data-cy=textfield] input").focus().type("Some text");
|
||||||
|
cy.get("[data-cy=textfield] input").should("have.prop", "value", "Some text");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -67,6 +67,7 @@ export default function CustomTextField({
|
|||||||
py: 0,
|
py: 0,
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
|
data-cy="textfield"
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
);
|
);
|
||||||
|
@ -27,7 +27,7 @@ export default function Emoji({ question }: Props) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<FormControl fullWidth>
|
<FormControl fullWidth>
|
||||||
<FormLabel id="quiz-question-radio-group" data-cy="variant-title">{question.title}</FormLabel>
|
<FormLabel id="quiz-question-radio-group" data-cy="question-title">{question.title}</FormLabel>
|
||||||
<RadioGroup
|
<RadioGroup
|
||||||
aria-labelledby="quiz-question-radio-group"
|
aria-labelledby="quiz-question-radio-group"
|
||||||
value={value}
|
value={value}
|
||||||
|
@ -17,7 +17,7 @@ export default function Text({ question }: Props) {
|
|||||||
gap: 1,
|
gap: 1,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Typography variant="h6">{question.title}</Typography>
|
<Typography variant="h6" data-cy="question-title">{question.title}</Typography>
|
||||||
<CustomTextField placeholder={question.content.placeholder} />
|
<CustomTextField placeholder={question.content.placeholder} />
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
|
@ -27,7 +27,7 @@ export default function Variant({ question }: Props) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<FormControl fullWidth>
|
<FormControl fullWidth>
|
||||||
<FormLabel id="quiz-question-radio-group" data-cy="variant-title">
|
<FormLabel id="quiz-question-radio-group" data-cy="question-title">
|
||||||
{question.title}
|
{question.title}
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
<RadioGroup
|
<RadioGroup
|
||||||
|
@ -44,7 +44,7 @@ export default function Varimg({ question }: Props) {
|
|||||||
<FormControl>
|
<FormControl>
|
||||||
<FormLabel
|
<FormLabel
|
||||||
id="quiz-question-radio-group"
|
id="quiz-question-radio-group"
|
||||||
data-cy="variant-title"
|
data-cy="question-title"
|
||||||
>
|
>
|
||||||
{question.title}
|
{question.title}
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
|
Loading…
Reference in New Issue
Block a user