2023-12-14 22:03:28 +00:00
|
|
|
|
import "cypress-file-upload";
|
|
|
|
|
|
2024-01-10 10:43:04 +00:00
|
|
|
|
describe("Тестирование публикации", () => {
|
2023-12-14 22:03:28 +00:00
|
|
|
|
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();
|
|
|
|
|
|
2024-01-10 10:43:04 +00:00
|
|
|
|
cy.wait(500);
|
|
|
|
|
cy.get('[data-cy="create-question"]').click();
|
2023-12-14 22:03:28 +00:00
|
|
|
|
|
2024-01-10 10:43:04 +00:00
|
|
|
|
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}");
|
2023-12-14 22:03:28 +00:00
|
|
|
|
|
|
|
|
|
cy.visit("http://localhost:3000/view");
|
|
|
|
|
cy.wait(500);
|
|
|
|
|
|
2024-01-10 10:43:04 +00:00
|
|
|
|
cy.get("#buttonFurther").should("be.disabled");
|
2023-12-14 22:03:28 +00:00
|
|
|
|
cy.contains("div", "1").click();
|
|
|
|
|
|
|
|
|
|
cy.wait(500);
|
2024-01-10 10:43:04 +00:00
|
|
|
|
cy.get("#buttonFurther").should("not.be.disabled");
|
2023-12-14 22:03:28 +00:00
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
//Варианты ответов +
|
|
|
|
|
|
2024-01-10 10:43:04 +00:00
|
|
|
|
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}");
|
2023-12-14 22:03:28 +00:00
|
|
|
|
|
|
|
|
|
cy.visit("http://localhost:3000/view");
|
|
|
|
|
cy.wait(500);
|
|
|
|
|
|
2024-01-10 10:43:04 +00:00
|
|
|
|
cy.get("#buttonFurther").should("be.disabled");
|
2023-12-14 22:03:28 +00:00
|
|
|
|
cy.contains("label", "1").click();
|
|
|
|
|
|
|
|
|
|
cy.wait(500);
|
2024-01-10 10:43:04 +00:00
|
|
|
|
cy.get("#buttonFurther").should("not.be.disabled");
|
2023-12-14 22:03:28 +00:00
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
// Варианты и картинка +
|
|
|
|
|
|
2024-01-10 10:43:04 +00:00
|
|
|
|
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}");
|
2023-12-14 22:03:28 +00:00
|
|
|
|
|
|
|
|
|
cy.visit("http://localhost:3000/view");
|
|
|
|
|
cy.wait(500);
|
|
|
|
|
|
2024-01-10 10:43:04 +00:00
|
|
|
|
cy.get("#buttonFurther").should("be.disabled");
|
2023-12-14 22:03:28 +00:00
|
|
|
|
cy.contains("div", "1").click();
|
|
|
|
|
|
|
|
|
|
cy.wait(500);
|
2024-01-10 10:43:04 +00:00
|
|
|
|
cy.get("#buttonFurther").should("not.be.disabled");
|
2023-12-14 22:03:28 +00:00
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
//Эмоджи +
|
|
|
|
|
|
2024-01-10 10:43:04 +00:00
|
|
|
|
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}");
|
2023-12-14 22:03:28 +00:00
|
|
|
|
|
|
|
|
|
cy.visit("http://localhost:3000/view");
|
|
|
|
|
cy.wait(500);
|
|
|
|
|
|
2024-01-10 10:43:04 +00:00
|
|
|
|
cy.get("#buttonFurther").should("be.disabled");
|
2023-12-14 22:03:28 +00:00
|
|
|
|
cy.contains("div", "1").click();
|
|
|
|
|
|
|
|
|
|
cy.wait(500);
|
2024-01-10 10:43:04 +00:00
|
|
|
|
cy.get("#buttonFurther").should("not.be.disabled");
|
2023-12-14 22:03:28 +00:00
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
//Своё поле для ввода +
|
|
|
|
|
|
2024-01-10 10:43:04 +00:00
|
|
|
|
cy.get(`[data-cy="select-questiontype-text"]`).click();
|
|
|
|
|
cy.get(
|
|
|
|
|
'[data-cy="checkbox-optional-question"] > .PrivateSwitchBase-input',
|
|
|
|
|
).click();
|
2023-12-14 22:03:28 +00:00
|
|
|
|
|
2024-01-10 10:43:04 +00:00
|
|
|
|
cy.get('input[placeholder="Пример ответа"]')
|
|
|
|
|
.eq(0)
|
|
|
|
|
.type("1")
|
|
|
|
|
.type("{enter}");
|
2023-12-14 22:03:28 +00:00
|
|
|
|
|
|
|
|
|
cy.visit("http://localhost:3000/view");
|
|
|
|
|
cy.wait(500);
|
|
|
|
|
|
2024-01-10 10:43:04 +00:00
|
|
|
|
cy.get("#buttonFurther").should("be.disabled");
|
2023-12-14 22:03:28 +00:00
|
|
|
|
cy.get('input[type="text"]').type("email@invalid.com");
|
|
|
|
|
|
|
|
|
|
cy.wait(500);
|
2024-01-10 10:43:04 +00:00
|
|
|
|
cy.get("#buttonFurther").should("not.be.disabled");
|
2023-12-14 22:03:28 +00:00
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
//Выпадающий список +
|
|
|
|
|
|
2024-01-10 10:43:04 +00:00
|
|
|
|
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}");
|
2023-12-14 22:03:28 +00:00
|
|
|
|
|
|
|
|
|
cy.visit("http://localhost:3000/view");
|
|
|
|
|
cy.wait(500);
|
|
|
|
|
|
2024-01-10 10:43:04 +00:00
|
|
|
|
cy.get("#buttonFurther").should("be.disabled");
|
2023-12-14 22:03:28 +00:00
|
|
|
|
cy.get("#display-select").click();
|
|
|
|
|
cy.get("li").eq(0).click();
|
|
|
|
|
|
|
|
|
|
cy.wait(500);
|
2024-01-10 10:43:04 +00:00
|
|
|
|
cy.get("#buttonFurther").should("not.be.disabled");
|
2023-12-14 22:03:28 +00:00
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
//Дата +
|
|
|
|
|
|
2024-01-10 10:43:04 +00:00
|
|
|
|
cy.get(`[data-cy="select-questiontype-date"]`).click();
|
|
|
|
|
cy.get(
|
|
|
|
|
'[data-cy="checkbox-optional-question"] > .PrivateSwitchBase-input',
|
|
|
|
|
).click();
|
2023-12-14 22:03:28 +00:00
|
|
|
|
|
|
|
|
|
cy.visit("http://localhost:3000/view");
|
|
|
|
|
cy.wait(500);
|
|
|
|
|
|
2024-01-10 10:43:04 +00:00
|
|
|
|
cy.get("#buttonFurther").should("be.disabled");
|
2023-12-14 22:03:28 +00:00
|
|
|
|
cy.get('button[data-cy="open-datepicker"]').click();
|
|
|
|
|
|
|
|
|
|
cy.wait(500);
|
|
|
|
|
|
|
|
|
|
cy.get('button[role="gridcell"]').eq(16).click();
|
|
|
|
|
|
|
|
|
|
cy.wait(500);
|
2024-01-10 10:43:04 +00:00
|
|
|
|
cy.get("#buttonFurther").should("not.be.disabled");
|
2023-12-14 22:03:28 +00:00
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
//Ползунок +
|
|
|
|
|
|
2024-01-10 10:43:04 +00:00
|
|
|
|
cy.get(`[data-cy="select-questiontype-number"]`).click();
|
|
|
|
|
cy.get(
|
|
|
|
|
'[data-cy="checkbox-optional-question"] > .PrivateSwitchBase-input',
|
|
|
|
|
).click();
|
2023-12-14 22:03:28 +00:00
|
|
|
|
|
|
|
|
|
cy.visit("http://localhost:3000/view");
|
|
|
|
|
cy.wait(500);
|
|
|
|
|
|
2024-01-10 10:43:04 +00:00
|
|
|
|
cy.get("#buttonFurther").should("be.disabled");
|
|
|
|
|
|
|
|
|
|
cy.get('div[data-cy="textfield"]').as("textFieldDiv");
|
|
|
|
|
|
|
|
|
|
cy.get("@textFieldDiv").find("input").type("10");
|
2023-12-14 22:03:28 +00:00
|
|
|
|
|
|
|
|
|
cy.wait(500);
|
2024-01-10 10:43:04 +00:00
|
|
|
|
cy.get("#buttonFurther").should("not.be.disabled");
|
2023-12-14 22:03:28 +00:00
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
2024-01-10 10:43:04 +00:00
|
|
|
|
// Загрузка файла +
|
2023-12-14 22:03:28 +00:00
|
|
|
|
|
2024-01-10 10:43:04 +00:00
|
|
|
|
cy.get(`[data-cy="select-questiontype-file"]`).click();
|
|
|
|
|
cy.get(
|
|
|
|
|
'[data-cy="checkbox-optional-question"] > .PrivateSwitchBase-input',
|
|
|
|
|
).click();
|
2023-12-14 22:03:28 +00:00
|
|
|
|
|
|
|
|
|
cy.visit("http://localhost:3000/view");
|
|
|
|
|
cy.wait(500);
|
|
|
|
|
|
2024-01-10 10:43:04 +00:00
|
|
|
|
cy.get("#buttonFurther").should("be.disabled");
|
|
|
|
|
cy.get('label.MuiButtonBase-root input[type="file"]').attachFile(
|
|
|
|
|
"../e2e/image/Bunner.png",
|
|
|
|
|
);
|
2023-12-14 22:03:28 +00:00
|
|
|
|
|
|
|
|
|
cy.wait(500);
|
2024-01-10 10:43:04 +00:00
|
|
|
|
cy.get("#buttonFurther").should("not.be.disabled");
|
2023-12-14 22:03:28 +00:00
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
// Рейтинг
|
|
|
|
|
|
2024-01-10 10:43:04 +00:00
|
|
|
|
cy.get(`[data-cy="select-questiontype-rating"]`).click();
|
|
|
|
|
cy.get(
|
|
|
|
|
'[data-cy="checkbox-optional-question"] > .PrivateSwitchBase-input',
|
|
|
|
|
).click();
|
2023-12-14 22:03:28 +00:00
|
|
|
|
|
|
|
|
|
cy.visit("http://localhost:3000/view");
|
|
|
|
|
cy.wait(500);
|
|
|
|
|
|
2024-01-10 10:43:04 +00:00
|
|
|
|
cy.get("#buttonFurther").should("be.disabled");
|
2023-12-14 22:03:28 +00:00
|
|
|
|
cy.contains("label", "4 Stars").click();
|
|
|
|
|
|
|
|
|
|
cy.wait(500);
|
2024-01-10 10:43:04 +00:00
|
|
|
|
cy.get("#buttonFurther").should("not.be.disabled");
|
2023-12-14 22:03:28 +00:00
|
|
|
|
|
|
|
|
|
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();
|
2023-12-15 22:10:29 +00:00
|
|
|
|
|
|
|
|
|
// Удаления Квиза
|
|
|
|
|
|
|
|
|
|
cy.visit("http://localhost:3000/list");
|
|
|
|
|
cy.wait(500);
|
|
|
|
|
cy.get('[data-cy="delete-quiz"]').each(($button) => {
|
|
|
|
|
cy.wrap($button).click();
|
|
|
|
|
cy.wait(500);
|
2024-01-10 10:43:04 +00:00
|
|
|
|
cy.get("#deleteButton").click();
|
2023-12-15 22:10:29 +00:00
|
|
|
|
});
|
2023-12-14 22:03:28 +00:00
|
|
|
|
});
|
|
|
|
|
});
|