297 lines
9.9 KiB
TypeScript
297 lines
9.9 KiB
TypeScript
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.contains("button", "Варианты с картинками").click();
|
||
|
||
cy.contains("label", "Необязательный вопрос").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.contains("Далее →").should("be.disabled");
|
||
cy.contains("div", "1").click();
|
||
|
||
cy.wait(500);
|
||
cy.contains("Далее →").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.contains("button", "Варианты ответов").click();
|
||
cy.contains("label", "Необязательный вопрос").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.contains("Далее →").should("be.disabled");
|
||
cy.contains("label", "1").click();
|
||
|
||
cy.wait(500);
|
||
cy.contains("Далее →").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.contains("button", "Варианты и картинка").click();
|
||
cy.contains("label", "Необязательный вопрос").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.contains("Далее →").should("be.disabled");
|
||
cy.contains("div", "1").click();
|
||
|
||
cy.wait(500);
|
||
cy.contains("Далее →").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.contains("button", "Эмоджи").click();
|
||
cy.contains("label", "Необязательный вопрос").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.contains("Далее →").should("be.disabled");
|
||
cy.contains("div", "1").click();
|
||
|
||
cy.wait(500);
|
||
cy.contains("Далее →").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.contains("button", "Своё поле для ввода").click();
|
||
cy.contains("label", "Необязательный вопрос").click();
|
||
|
||
cy.get('input[placeholder="Пример ответа"]').eq(0).type("1").type("{enter}");
|
||
|
||
cy.visit("http://localhost:3000/view");
|
||
cy.wait(500);
|
||
|
||
cy.contains("Далее →").should("be.disabled");
|
||
cy.get('input[type="text"]').type("email@invalid.com");
|
||
|
||
cy.wait(500);
|
||
cy.contains("Далее →").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.contains("button", "Выпадающий список").click();
|
||
cy.contains("label", "Необязательный вопрос").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.contains("Далее →").should("be.disabled");
|
||
cy.get("#display-select").click();
|
||
cy.get("li").eq(0).click();
|
||
|
||
cy.wait(500);
|
||
cy.contains("Далее →").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.contains("button", "Дата").click();
|
||
cy.contains("label", "Необязательный вопрос").click();
|
||
|
||
cy.visit("http://localhost:3000/view");
|
||
cy.wait(500);
|
||
|
||
cy.contains("Далее →").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.contains("Далее →").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.contains("button", "Ползунок").click();
|
||
cy.contains("label", "Необязательный вопрос").click();
|
||
|
||
cy.visit("http://localhost:3000/view");
|
||
cy.wait(500);
|
||
|
||
cy.contains("Далее →").should("be.disabled");
|
||
cy.get('input[aria-invalid="false"][id=":r0:"][placeholder="0"]').type("10");
|
||
|
||
cy.wait(500);
|
||
cy.contains("Далее →").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.contains("button", "Загрузка файла").click();
|
||
cy.contains("label", "Необязательный вопрос").click();
|
||
|
||
cy.visit("http://localhost:3000/view");
|
||
cy.wait(500);
|
||
|
||
cy.contains("Далее →").should("be.disabled");
|
||
cy.get('label.MuiButtonBase-root input[type="file"]').attachFile("./image/Bunner.png");
|
||
|
||
cy.wait(500);
|
||
cy.contains("Далее →").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.contains("button", "Рейтинг").click();
|
||
cy.contains("label", "Необязательный вопрос").click();
|
||
|
||
cy.visit("http://localhost:3000/view");
|
||
cy.wait(500);
|
||
|
||
cy.contains("Далее →").should("be.disabled");
|
||
cy.contains("label", "4 Stars").click();
|
||
|
||
cy.wait(500);
|
||
cy.contains("Далее →").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.contains("button", "Удалить").click();
|
||
});
|
||
});
|
||
});
|