import "cypress-file-upload"; 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('[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('[data-cy="quiz-variant-question-answer"]') .eq(2) .should("have.value", "") .type("3") .type("{enter}"); cy.get('[data-cy="quiz-variant-question-answer"]') .eq(3) .should("have.value", "") .type("4") .type("{enter}"); cy.visit("http://localhost:3000/view"); cy.wait(500); cy.get("#buttonFurther").should("be.disabled"); cy.contains("div", "1").click(); cy.wait(500); cy.get("#buttonFurther").should("not.be.disabled"); cy.visit("http://localhost:3000/view"); 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('[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('[data-cy="quiz-variant-question-answer"]') .eq(2) .should("have.value", "") .type("3") .type("{enter}"); cy.get('[data-cy="quiz-variant-question-answer"]') .eq(3) .should("have.value", "") .type("4") .type("{enter}"); cy.visit("http://localhost:3000/view"); cy.wait(500); cy.get("#buttonFurther").should("be.disabled"); cy.contains("label", "1").click(); cy.wait(500); cy.get("#buttonFurther").should("not.be.disabled"); cy.visit("http://localhost:3000/view"); 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('[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('[data-cy="quiz-variant-question-answer"]') .eq(2) .should("have.value", "") .type("3") .type("{enter}"); cy.get('[data-cy="quiz-variant-question-answer"]') .eq(3) .should("have.value", "") .type("4") .type("{enter}"); cy.visit("http://localhost:3000/view"); cy.wait(500); cy.get("#buttonFurther").should("be.disabled"); cy.contains("div", "1").click(); cy.wait(500); cy.get("#buttonFurther").should("not.be.disabled"); cy.visit("http://localhost:3000/view"); 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('[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('[data-cy="quiz-variant-question-answer"]') .eq(2) .should("have.value", "") .type("3") .type("{enter}"); cy.get('[data-cy="quiz-variant-question-answer"]') .eq(3) .should("have.value", "") .type("4") .type("{enter}"); cy.visit("http://localhost:3000/view"); cy.wait(500); cy.get("#buttonFurther").should("be.disabled"); cy.contains("div", "1").click(); cy.wait(500); cy.get("#buttonFurther").should("not.be.disabled"); cy.visit("http://localhost:3000/view"); 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('input[placeholder="Пример ответа"]') .eq(0) .type("1") .type("{enter}"); cy.visit("http://localhost:3000/view"); cy.wait(500); cy.get("#buttonFurther").should("be.disabled"); cy.get('input[type="text"]').type("email@invalid.com"); cy.wait(500); cy.get("#buttonFurther").should("not.be.disabled"); cy.visit("http://localhost:3000/view"); 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('[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('[data-cy="quiz-variant-question-answer"]') .eq(2) .should("have.value", "") .type("3") .type("{enter}"); cy.get('[data-cy="quiz-variant-question-answer"]') .eq(3) .should("have.value", "") .type("4") .type("{enter}"); cy.visit("http://localhost:3000/view"); cy.wait(500); cy.get("#buttonFurther").should("be.disabled"); cy.get("#display-select").click(); cy.get("li").eq(0).click(); cy.wait(500); cy.get("#buttonFurther").should("not.be.disabled"); cy.visit("http://localhost:3000/view"); 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.visit("http://localhost:3000/view"); cy.wait(500); cy.get("#buttonFurther").should("be.disabled"); cy.get('button[data-cy="open-datepicker"]').click(); cy.wait(500); cy.get('button[role="gridcell"]').eq(16).click(); cy.wait(500); cy.get("#buttonFurther").should("not.be.disabled"); cy.visit("http://localhost:3000/view"); 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-number"]`).click(); cy.get( '[data-cy="checkbox-optional-question"] > .PrivateSwitchBase-input', ).click(); cy.visit("http://localhost:3000/view"); cy.wait(500); cy.get("#buttonFurther").should("be.disabled"); cy.get('div[data-cy="textfield"]').as("textFieldDiv"); cy.get("@textFieldDiv").find("input").type("10"); cy.wait(500); cy.get("#buttonFurther").should("not.be.disabled"); cy.visit("http://localhost:3000/view"); 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-file"]`).click(); cy.get( '[data-cy="checkbox-optional-question"] > .PrivateSwitchBase-input', ).click(); cy.visit("http://localhost:3000/view"); cy.wait(500); cy.get("#buttonFurther").should("be.disabled"); cy.get('label.MuiButtonBase-root input[type="file"]').attachFile( "../e2e/image/Bunner.png", ); cy.wait(500); cy.get("#buttonFurther").should("not.be.disabled"); cy.visit("http://localhost:3000/view"); 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-rating"]`).click(); cy.get( '[data-cy="checkbox-optional-question"] > .PrivateSwitchBase-input', ).click(); cy.visit("http://localhost:3000/view"); cy.wait(500); cy.get("#buttonFurther").should("be.disabled"); cy.contains("label", "4 Stars").click(); cy.wait(500); cy.get("#buttonFurther").should("not.be.disabled"); cy.visit("http://localhost:3000/view"); 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.visit("http://localhost:3000/list"); cy.wait(500); cy.get('[data-cy="delete-quiz"]').each(($button) => { cy.wrap($button).click(); cy.wait(500); cy.get("#deleteButton").click(); }); }); });