From f23ffd72132c673416bafa47449c3a7387a8661e Mon Sep 17 00:00:00 2001 From: ArtChaos189 Date: Thu, 11 Jan 2024 18:37:01 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D1=82=D0=B5=D1=81=D1=82=20=D0=BD=D0=B0=20=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=B8=D0=BB=D1=8C=D0=BD=D0=BE=D1=81=D1=82=D1=8C=20=D0=BE?= =?UTF-8?q?=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8=D1=8F=20?= =?UTF-8?q?=D0=B2=D0=BE=D0=BF=D1=80=D0=BE=D1=81=D0=BE=D0=B2=20=D0=B2=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B5=D0=B2=D1=8C=D1=8E=20=D0=B8=20=D1=82=D0=B5?= =?UTF-8?q?=D1=81=D1=82=D0=BE=D0=B2=D0=BE=D0=BC=20=D0=BF=D1=80=D0=BE=D1=81?= =?UTF-8?q?=D0=BC=D0=BE=D1=82=D1=80=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cypress/e2e/quizQuestionsFields.cy.ts | 495 ++++++++++++++++++ .../DraggableList/QuestionPageCard.tsx | 1 + .../Questions/PageOptions/PageOptions.tsx | 1 + .../DescriptionForm/DescriptionForm.tsx | 6 +- .../ResultPage/cards/EmailSettingsCard.tsx | 1 + 5 files changed, 503 insertions(+), 1 deletion(-) create mode 100644 cypress/e2e/quizQuestionsFields.cy.ts diff --git a/cypress/e2e/quizQuestionsFields.cy.ts b/cypress/e2e/quizQuestionsFields.cy.ts new file mode 100644 index 00000000..03d3d2bb --- /dev/null +++ b/cypress/e2e/quizQuestionsFields.cy.ts @@ -0,0 +1,495 @@ +describe("Тестирование полей вопросов", () => { + beforeEach(() => { + cy.visit("http://localhost:3000"); + cy.wait(1000); + cy.contains("Регистрация / Войти").click(); + const login = "valid_user@exammple.com"; + const password = "valid_password"; + + cy.get("#email").type(login); + cy.get("#password").type(password); + cy.get('button[type="submit"]').click(); + }); + + it("Тест на правильность отображения вопросов в превью и тестовом просмотре ", () => { + cy.get('[data-cy="create-quiz"]').click(); + cy.wait(1000); + cy.get('button[data-cy="create-quiz-card"]').eq(0).click(); + cy.wait(1000); + cy.get('button[data-cy="select-quiz-layout-standard"]').click(); + cy.get('input[type="checkbox"]').click(); + + cy.get('[data-cy="setup-questions"]').click(); + + cy.wait(500); + // cy.get('[data-cy="create-question"]').click(); + + cy.get(`[data-cy="select-questiontype-images"]`).click(); + + cy.get( + '[data-cy="checkbox-optional-question"] > .PrivateSwitchBase-input', + ).click(); + + cy.get("#questionTitle").type("Заголовок вопроса"); + + cy.get('[data-cy="quiz-variant-question-answer"]') + .eq(0) + .type("1") + .type("{enter}"); + cy.get('[data-cy="quiz-variant-question-answer"]') + .eq(1) + .should("have.value", "") + .type("2") + .type("{enter}"); + + // превью + cy.get(`button[data-cy="button-preview"]`).click(); + cy.wait(2000); + + cy.get(".MuiTypography-h6") + .should("exist") + .and("have.text", "Заголовок вопроса"); + cy.get(":nth-child(1) > .MuiFormControlLabel-root") + .should("exist") + .and("have.text", "1"); + cy.get(":nth-child(2) > .MuiFormControlLabel-root") + .should("exist") + .and("have.text", "2"); + + cy.get(`button[data-cy="button-preview"]`).click(); + + cy.visit("http://localhost:3000/view"); + cy.wait(2000); + + // проверка введёных значений + cy.get(".MuiTypography-h5") + .should("exist") + .and("have.text", "Заголовок вопроса"); + + cy.get(":nth-child(1) > .MuiFormControlLabel-root") + .should("exist") + .and("have.text", "1"); + cy.get(":nth-child(2) > .MuiFormControlLabel-root") + .should("exist") + .and("have.text", "2"); + + cy.visit("http://localhost:3000/edit"); + + cy.wait(500); + cy.get('[data-cy="delete-question"]').click(); + cy.wait(5000); + cy.get('[data-cy="create-question"]').click(); + + //Варианты ответов + + cy.get(`[data-cy="select-questiontype-variant"]`).click(); + + cy.get( + '[data-cy="checkbox-optional-question"] > .PrivateSwitchBase-input', + ).click(); + + cy.get("#questionTitle").type("Заголовок вопроса"); + + cy.get('[data-cy="quiz-variant-question-answer"]') + .eq(0) + .type("1") + .type("{enter}"); + cy.get('[data-cy="quiz-variant-question-answer"]') + .eq(1) + .should("have.value", "") + .type("2") + .type("{enter}"); + + // превью + cy.get(`button[data-cy="button-preview"]`).click(); + cy.wait(2000); + + cy.get(".MuiTypography-h6") + .should("exist") + .and("have.text", "Заголовок вопроса"); + cy.get(".MuiFormControlLabel-label").contains("1").should("exist"); + cy.get(".MuiFormControlLabel-label").contains("2").should("exist"); + + cy.get(`button[data-cy="button-preview"]`).click(); + + cy.visit("http://localhost:3000/view"); + cy.wait(2000); + + // проверка введёных значений + cy.get(".MuiTypography-h5") + .should("exist") + .and("have.text", "Заголовок вопроса"); + + cy.get(".MuiFormControlLabel-label").contains("1").should("exist"); + cy.get(".MuiFormControlLabel-label").contains("2").should("exist"); + + cy.visit("http://localhost:3000/edit"); + + cy.wait(500); + cy.get('[data-cy="delete-question"]').click(); + cy.wait(5000); + cy.get('[data-cy="create-question"]').click(); + + // Варианты и картинка + + + cy.get(`[data-cy="select-questiontype-varimg"]`).click(); + + cy.get( + '[data-cy="checkbox-optional-question"] > .PrivateSwitchBase-input', + ).click(); + + cy.get("#questionTitle").type("Заголовок вопроса"); + + cy.get('[data-cy="quiz-variant-question-answer"]') + .eq(0) + .type("1") + .type("{enter}"); + cy.get('[data-cy="quiz-variant-question-answer"]') + .eq(1) + .should("have.value", "") + .type("2") + .type("{enter}"); + + // превью + cy.get(`button[data-cy="button-preview"]`).click(); + cy.wait(2000); + + cy.get(".MuiTypography-h6") + .should("exist") + .and("have.text", "Заголовок вопроса"); + cy.get(".MuiFormControlLabel-label").contains("1").should("exist"); + cy.get(".MuiFormControlLabel-label").contains("2").should("exist"); + + cy.get(`button[data-cy="button-preview"]`).click(); + + cy.visit("http://localhost:3000/view"); + cy.wait(2000); + + // проверка введёных значений + cy.get(".MuiTypography-h5") + .should("exist") + .and("have.text", "Заголовок вопроса"); + + cy.get(".MuiFormControlLabel-label").contains("1").should("exist"); + cy.get(".MuiFormControlLabel-label").contains("2").should("exist"); + + cy.visit("http://localhost:3000/edit"); + + cy.wait(500); + cy.get('[data-cy="delete-question"]').click(); + cy.wait(5000); + cy.get('[data-cy="create-question"]').click(); + + //Эмоджи + + + cy.get(`[data-cy="select-questiontype-emoji"]`).click(); + + cy.get( + '[data-cy="checkbox-optional-question"] > .PrivateSwitchBase-input', + ).click(); + + cy.get("#questionTitle").type("Заголовок вопроса"); + + cy.get('[data-cy="quiz-variant-question-answer"]') + .eq(0) + .type("1") + .type("{enter}"); + cy.get('[data-cy="quiz-variant-question-answer"]') + .eq(1) + .should("have.value", "") + .type("2") + .type("{enter}"); + + // превью + cy.get(`button[data-cy="button-preview"]`).click(); + cy.wait(2000); + + cy.get(".MuiTypography-h6") + .should("exist") + .and("have.text", "Заголовок вопроса"); + cy.get(".MuiFormControlLabel-label").contains("1").should("exist"); + cy.get(".MuiFormControlLabel-label").contains("2").should("exist"); + + cy.get(`button[data-cy="button-preview"]`).click(); + + cy.visit("http://localhost:3000/view"); + cy.wait(2000); + + // проверка введёных значений + cy.get(".MuiTypography-h5") + .should("exist") + .and("have.text", "Заголовок вопроса"); + + cy.get(".MuiFormControlLabel-label").contains("1").should("exist"); + cy.get(".MuiFormControlLabel-label").contains("2").should("exist"); + + cy.visit("http://localhost:3000/edit"); + + cy.wait(500); + cy.get('[data-cy="delete-question"]').click(); + cy.wait(5000); + cy.get('[data-cy="create-question"]').click(); + + //Своё поле для ввода + + cy.get(`[data-cy="select-questiontype-text"]`).click(); + + cy.get( + '[data-cy="checkbox-optional-question"] > .PrivateSwitchBase-input', + ).click(); + + cy.get("#questionTitle").type("Заголовок вопроса"); + + cy.get('input[placeholder="Пример ответа"]') + .eq(0) + .type("1") + .type("{enter}"); + + // превью + cy.get(`button[data-cy="button-preview"]`).click(); + cy.wait(2000); + + cy.get(".MuiTypography-h6") + .should("exist") + .and("have.text", "Заголовок вопроса"); + + cy.get('input[placeholder="1"]').should("exist"); + + cy.get(`button[data-cy="button-preview"]`).click(); + + cy.visit("http://localhost:3000/view"); + cy.wait(2000); + + // проверка введёных значений + cy.get(".MuiTypography-h5") + .should("exist") + .and("have.text", "Заголовок вопроса"); + + cy.get('input[placeholder="1"]').should("exist"); + + cy.visit("http://localhost:3000/edit"); + + cy.wait(500); + cy.get('[data-cy="delete-question"]').click(); + cy.wait(5000); + cy.get('[data-cy="create-question"]').click(); + + //Выпадающий список + + + cy.get(`[data-cy="select-questiontype-select"]`).click(); + + cy.get( + '[data-cy="checkbox-optional-question"] > .PrivateSwitchBase-input', + ).click(); + + cy.get("#questionTitle").type("Заголовок вопроса"); + + cy.get('[data-cy="quiz-variant-question-answer"]') + .eq(0) + .type("1") + .type("{enter}"); + cy.get('[data-cy="quiz-variant-question-answer"]') + .eq(1) + .should("have.value", "") + .type("2") + .type("{enter}"); + + // превью + cy.get(`button[data-cy="button-preview"]`).click(); + cy.wait(2000); + + cy.get(".MuiTypography-h6") + .should("exist") + .and("have.text", "Заголовок вопроса"); + + cy.get(".MuiFormControlLabel-label").contains("1").should("exist"); + cy.get(".MuiFormControlLabel-label").contains("2").should("exist"); + + cy.get(`button[data-cy="button-preview"]`).click(); + + cy.visit("http://localhost:3000/view"); + cy.wait(2000); + + // проверка введёных значений + cy.get(".MuiTypography-h5") + .should("exist") + .and("have.text", "Заголовок вопроса"); + + cy.get(".MuiFormControlLabel-label").contains("1").should("exist"); + cy.get(".MuiFormControlLabel-label").contains("2").should("exist"); + + cy.visit("http://localhost:3000/edit"); + + cy.wait(500); + cy.get('[data-cy="delete-question"]').click(); + cy.wait(5000); + cy.get('[data-cy="create-question"]').click(); + + //Дата + + cy.get(`[data-cy="select-questiontype-date"]`).click(); + cy.get( + '[data-cy="checkbox-optional-question"] > .PrivateSwitchBase-input', + ).click(); + + cy.get("#questionTitle").type("Заголовок вопроса"); + + // превью + cy.get(`button[data-cy="button-preview"]`).click(); + cy.wait(2000); + + cy.get(".MuiTypography-h6") + .should("exist") + .and("have.text", "Заголовок вопроса"); + + cy.get(`button[data-cy="button-preview"]`).click(); + + cy.visit("http://localhost:3000/view"); + cy.wait(2000); + + // проверка введёных значений + cy.get(".MuiTypography-h5") + .should("exist") + .and("have.text", "Заголовок вопроса"); + + cy.wait(500); + cy.get('[data-cy="delete-question"]').click(); + cy.wait(5000); + cy.get('[data-cy="create-question"]').click(); + + //Ползунок + + + cy.get(`[data-cy="select-questiontype-number"]`).click(); + cy.get( + '[data-cy="checkbox-optional-question"] > .PrivateSwitchBase-input', + ).click(); + + cy.get("#questionTitle").type("Заголовок вопроса"); + + // превью + cy.get(`button[data-cy="button-preview"]`).click(); + cy.wait(2000); + + cy.get(".MuiTypography-h6") + .should("exist") + .and("have.text", "Заголовок вопроса"); + cy.get(".MuiTypography-p") + .should("exist") + .and("have.text", "Заголовок вопроса"); + + cy.get(`button[data-cy="button-preview"]`).click(); + + cy.visit("http://localhost:3000/view"); + cy.wait(2000); + + // проверка введёных значений + cy.get(".MuiTypography-h5") + .should("exist") + .and("have.text", "Заголовок вопроса"); + + cy.wait(500); + cy.get('[data-cy="delete-question"]').click(); + cy.wait(5000); + cy.get('[data-cy="create-question"]').click(); + + // Загрузка файла + + + cy.get(`[data-cy="select-questiontype-file"]`).click(); + cy.get( + '[data-cy="checkbox-optional-question"] > .PrivateSwitchBase-input', + ).click(); + + cy.get("#questionTitle").type("Заголовок вопроса"); + + // превью + cy.get(`button[data-cy="button-preview"]`).click(); + cy.wait(2000); + + cy.get(".MuiTypography-h6") + .should("exist") + .and("have.text", "Заголовок вопроса"); + + cy.get(`button[data-cy="button-preview"]`).click(); + + cy.visit("http://localhost:3000/view"); + cy.wait(2000); + + // проверка введёных значений + cy.get(".MuiTypography-h5") + .should("exist") + .and("have.text", "Заголовок вопроса"); + + cy.wait(500); + cy.get('[data-cy="delete-question"]').click(); + cy.wait(5000); + cy.get('[data-cy="create-question"]').click(); + + // Страница + + cy.get(`[data-cy="select-questiontype-page"]`).click(); + cy.get( + '[data-cy="checkbox-optional-question"] > .PrivateSwitchBase-input', + ).click(); + + cy.get("#questionTitle").type("Заголовок вопроса"); + cy.get("#addText").type("Добавляю текст"); + + // превью + cy.get(`button[data-cy="button-preview"]`).click(); + cy.wait(2000); + + cy.get(".MuiTypography-h6") + .should("exist") + .and("have.text", "Заголовок вопроса"); + cy.get(".MuiTypography-p") + .should("exist") + .and("have.text", "Добавляю текст"); + + cy.get(`button[data-cy="button-preview"]`).click(); + + cy.visit("http://localhost:3000/view"); + cy.wait(2000); + + // проверка введёных значений + cy.get(".MuiTypography-h5") + .should("exist") + .and("have.text", "Заголовок вопроса"); + cy.get(".MuiTypography-p") + .should("exist") + .and("have.text", "Добавляю текст"); + + cy.wait(500); + cy.get('[data-cy="delete-question"]').click(); + cy.wait(5000); + cy.get('[data-cy="create-question"]').click(); + + // Рейтинг + + cy.get(`[data-cy="select-questiontype-rating"]`).click(); + cy.get( + '[data-cy="checkbox-optional-question"] > .PrivateSwitchBase-input', + ).click(); + + cy.get("#questionTitle").type("Заголовок вопроса"); + + // превью + cy.get(`button[data-cy="button-preview"]`).click(); + cy.wait(2000); + + cy.get(".MuiTypography-h6") + .should("exist") + .and("have.text", "Заголовок вопроса"); + + cy.get(`button[data-cy="button-preview"]`).click(); + + cy.visit("http://localhost:3000/view"); + cy.wait(2000); + + // проверка введёных значений + cy.get(".MuiTypography-h5") + .should("exist") + .and("have.text", "Заголовок вопроса"); + + cy.wait(500); + cy.get('[data-cy="delete-question"]').click(); + cy.wait(5000); + cy.get('[data-cy="create-question"]').click(); + }); +}); diff --git a/src/pages/Questions/DraggableList/QuestionPageCard.tsx b/src/pages/Questions/DraggableList/QuestionPageCard.tsx index 4abf1f96..076f1592 100644 --- a/src/pages/Questions/DraggableList/QuestionPageCard.tsx +++ b/src/pages/Questions/DraggableList/QuestionPageCard.tsx @@ -133,6 +133,7 @@ export default function QuestionsPageCard({ }} > diff --git a/src/pages/Questions/PageOptions/PageOptions.tsx b/src/pages/Questions/PageOptions/PageOptions.tsx index e18d3d41..4d7fea8b 100644 --- a/src/pages/Questions/PageOptions/PageOptions.tsx +++ b/src/pages/Questions/PageOptions/PageOptions.tsx @@ -80,6 +80,7 @@ export default function PageOptions({ disableInput, question }: Props) { }} > setText(target.value)} diff --git a/src/pages/ResultPage/DescriptionForm/DescriptionForm.tsx b/src/pages/ResultPage/DescriptionForm/DescriptionForm.tsx index 788078f3..db3932c6 100644 --- a/src/pages/ResultPage/DescriptionForm/DescriptionForm.tsx +++ b/src/pages/ResultPage/DescriptionForm/DescriptionForm.tsx @@ -50,7 +50,11 @@ export const DescriptionForm = () => { mb: "19px", }} > - + diff --git a/src/pages/ResultPage/cards/EmailSettingsCard.tsx b/src/pages/ResultPage/cards/EmailSettingsCard.tsx index caa4b61b..2840a16b 100644 --- a/src/pages/ResultPage/cards/EmailSettingsCard.tsx +++ b/src/pages/ResultPage/cards/EmailSettingsCard.tsx @@ -119,6 +119,7 @@ export const EmailSettingsCard = ({ quizExpand }: Props) => { Тема письма {