diff --git a/cypress/e2e/quizPreview.cy.ts b/cypress/e2e/quizPreview.cy.ts index 668752c2..03133206 100644 --- a/cypress/e2e/quizPreview.cy.ts +++ b/cypress/e2e/quizPreview.cy.ts @@ -130,7 +130,7 @@ describe("Quiz preview", () => { }); }); - describe.only("Varimg question", () => { + describe("Varimg question", () => { beforeEach(function setupQuestion() { cy.fixture("image1.png", null).as("image1"); cy.fixture("image2.png", null).as("image2"); @@ -157,10 +157,8 @@ describe("Quiz preview", () => { }); }); - it("should contain title and options, and be selected properly", function () { + it("should contain title and options, and be selected properly", () => { cy.get("[data-cy=quiz-preview-layout]").within(() => { - cy.get("[data-cy=variant-title]").should("have.text", "Question Title"); - cy.get("[data-cy=variant-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(1).should("have.text", "Answer 2"); @@ -199,4 +197,72 @@ describe("Quiz preview", () => { }); }); }); + + describe("Emoji question", () => { + beforeEach(function setupQuestion() { + cy.get("[data-cy=select-questiontype-emoji]").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=quiz-variant-question-answer]").eq(0).type("Answer 1{enter}"); + cy.get("[data-cy=choose-emoji-button]").eq(0).click(); + cy.get("em-emoji-picker", { withinSubject: null }).within(() => { + cy.get(".emoji-mart-emoji", { + withinSubject: null, + includeShadowDom: true, + }).eq(0).click(); + }); + + cy.get("[data-cy=quiz-variant-question-answer]").eq(1).type("Answer 2{enter}"); + cy.get("[data-cy=choose-emoji-button]").eq(1).click(); + cy.get("em-emoji-picker", { withinSubject: null }).within(() => { + cy.get(".emoji-mart-emoji", { + withinSubject: null, + includeShadowDom: true, + }).eq(1).click(); + }); + + cy.get("[data-cy=quiz-variant-question-answer]").eq(2).type("Answer 3"); + cy.get("[data-cy=choose-emoji-button]").eq(2).click(); + cy.get("em-emoji-picker", { withinSubject: null }).within(() => { + cy.get(".emoji-mart-emoji", { + withinSubject: null, + includeShadowDom: true, + }).eq(2).click(); + }); + }); + }); + + it("should contain title and options, and be selected properly", () => { + 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=variant-title]").should("have.text", "Question Title"); + cy.get("[data-cy=variant-answer]").eq(0).invoke("text").should("match", + new RegExp(`${emojiRegex} Answer 1`) + ); + cy.get("[data-cy=variant-answer]").eq(1).invoke("text").should("match", + new RegExp(`${emojiRegex} Answer 2`) + ); + cy.get("[data-cy=variant-answer]").eq(2).invoke("text").should("match", + new RegExp(`${emojiRegex} Answer 3`) + ); + + cy.get("[data-cy=variant-answer]").eq(0).click(); + cy.get("[data-cy=variant-radio]").eq(0).should("be.checked"); + cy.get("[data-cy=variant-radio]").eq(1).should("not.be.checked"); + cy.get("[data-cy=variant-radio]").eq(2).should("not.be.checked"); + + cy.get("[data-cy=variant-answer]").eq(1).click(); + cy.get("[data-cy=variant-radio]").eq(0).should("not.be.checked"); + cy.get("[data-cy=variant-radio]").eq(1).should("be.checked"); + cy.get("[data-cy=variant-radio]").eq(2).should("not.be.checked"); + + cy.get("[data-cy=variant-answer]").eq(2).click(); + cy.get("[data-cy=variant-radio]").eq(0).should("not.be.checked"); + cy.get("[data-cy=variant-radio]").eq(1).should("not.be.checked"); + cy.get("[data-cy=variant-radio]").eq(2).should("be.checked"); + }); + }); + }); }); diff --git a/src/pages/Questions/Emoji/Emoji.tsx b/src/pages/Questions/Emoji/Emoji.tsx index 9b77ed23..8730209f 100644 --- a/src/pages/Questions/Emoji/Emoji.tsx +++ b/src/pages/Questions/Emoji/Emoji.tsx @@ -54,6 +54,7 @@ export default function Emoji({ totalIndex }: Props) { {!isTablet && ( { setAnchorElement(currentTarget); setCurrentIndex(index); diff --git a/src/ui_kit/QuizPreview/QuizPreviewQuestionTypes/Emoji.tsx b/src/ui_kit/QuizPreview/QuizPreviewQuestionTypes/Emoji.tsx index 15912f3c..2db7c025 100644 --- a/src/ui_kit/QuizPreview/QuizPreviewQuestionTypes/Emoji.tsx +++ b/src/ui_kit/QuizPreview/QuizPreviewQuestionTypes/Emoji.tsx @@ -27,7 +27,7 @@ export default function Emoji({ question }: Props) { return ( - {question.title} + {question.title} } + control={ + + } label={ - + {`${variant.extendedText} ${variant.answer}`} {variant.hints && (