add select question preview test

This commit is contained in:
nflnkr 2023-11-07 14:45:47 +03:00
parent 930386b9c8
commit cf887e1bbe
2 changed files with 26 additions and 0 deletions

@ -284,4 +284,28 @@ describe("Quiz preview", () => {
});
});
});
describe("Select question", () => {
beforeEach(function setupQuestion() {
cy.get("[data-cy=select-questiontype-select]").click();
cy.get("[data-cy=quiz-question-title]").type("Question Title");
cy.get("[data-cy=quiz-variant-question-answer]").eq(0).type("Answer 1{enter}");
cy.get("[data-cy=quiz-variant-question-answer]").eq(1).type("Answer 2{enter}");
cy.get("[data-cy=quiz-variant-question-answer]").eq(2).type("Answer 3");
});
it("should contain title and select, and be selected properly", () => {
cy.get("[data-cy=quiz-preview-layout]").within(() => {
cy.get("[data-cy=select]").click();
cy.get("[data-cy=select-option]", { withinSubject: null }).eq(0).click();
cy.get("[data-cy=select] #category-select").should("have.text", "Answer 1");
cy.get("[data-cy=select]").click();
cy.get("[data-cy=select-option]", { withinSubject: null }).eq(1).click();
cy.get("[data-cy=select] #category-select").should("have.text", "Answer 2");
cy.get("[data-cy=select]").click();
cy.get("[data-cy=select-option]", { withinSubject: null }).eq(2).click();
cy.get("[data-cy=select] #category-select").should("have.text", "Answer 3");
});
});
});
});

@ -49,6 +49,7 @@ export default function Text({ question }: Props) {
placeholder={question.content.default}
displayEmpty
onChange={handleChange}
data-cy="select"
sx={{
height: "48px",
borderRadius: "8px",
@ -105,6 +106,7 @@ export default function Text({ question }: Props) {
<MenuItem
key={variant.answer}
value={variant.answer}
data-cy="select-option"
sx={{
display: "flex",
alignItems: "center",