fix: Trash removed

This commit is contained in:
IlyaDoronin 2024-02-05 18:18:17 +03:00
parent cc743f5915
commit d88fad5cb8
2 changed files with 5 additions and 263 deletions

@ -1,253 +0,0 @@
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="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");
cy.get('[data-cy="next-step"]').click();
//проверяем все поля на пустоту страницы результата
cy.get(`[data-cy="expand-question"]`).eq(0).click();
cy.wait(200);
cy.get("#after-the-contact-form").click();
cy.get("#heading-result").should("have.value", "");
cy.get("#headline-is-bolder").should("have.value", "");
cy.get("#heading-description").should("have.value", "");
cy.get(`[data-cy="add-button"]`).click();
cy.wait(200);
cy.get("#button-text-result").should("have.value", "");
cy.get("#link-page-result").should("have.value", "");
//перемещаемся на странице тестового просмотра
cy.visit("http://localhost:3000/view");
cy.get(".MuiFormControlLabel-label").contains("1").click();
cy.get("#buttonFurther").click();
cy.wait(1000);
cy.get("#name-input").type("Name");
cy.get("#email-input").type("valid_user@exammple.com");
cy.get("#phone-input").type("+2682585");
cy.get('input[type="checkbox"]').click();
cy.wait(200);
cy.get("#get-results").click();
//проверяем что страница результатов не отобразилась
cy.wait(2000);
cy.get("#find-out-more-button").should("not.exist");
//поселе чего заполняем все поля в результате
cy.visit("http://localhost:3000/edit");
cy.get("#heading-result").type("Результат");
cy.get("#headline-is-bolder").type("Заголовок пожирнее");
cy.get("#heading-description").type("Описание обычного заголовка");
cy.get(`[data-cy="add-button"]`).click();
cy.wait(200);
cy.get("#button-text-result").type("Узнать подробнее");
//переходим на страницу тестового просмотра
cy.visit("http://localhost:3000/view");
cy.get(".MuiFormControlLabel-label").contains("1").click();
cy.get("#buttonFurther").click();
cy.wait(1000);
cy.get("#name-input").type("Name");
cy.get("#email-input").type("valid_user@exammple.com");
cy.get("#phone-input").type("+2682585");
cy.get('input[type="checkbox"]').click();
cy.wait(200);
cy.get("#get-results").click();
cy.wait(2000);
cy.contains("p", "Заголовок пожирнее").should("exist");
//Переключаем показывания результата до формы контактов
cy.visit("http://localhost:3000/edit");
cy.get(`[data-cy="expand-question"]`).eq(0).click();
cy.wait(200);
cy.get("#before-contact-form").click();
cy.wait(2000);
cy.visit("http://localhost:3000/view");
cy.get(".MuiFormControlLabel-label").contains("1").click();
cy.get("#buttonFurther").click();
cy.wait(2000);
cy.contains("p", "Заголовок пожирнее").should("exist");
//тоже самое тольок теперь очищаем поля формы результатов
cy.visit("http://localhost:3000/edit");
cy.get("#heading-result").clear();
cy.get("#headline-is-bolder").clear();
cy.get("#heading-description").clear();
cy.get("#button-text-result").clear();
cy.visit("http://localhost:3000/view");
cy.get(".MuiFormControlLabel-label").contains("1").click();
cy.get("#buttonFurther").click();
cy.wait(2000);
cy.get("#find-out-more-button").should("not.exist");
// проверяем на страницы в публикации с не заполнеными полями до форм контактов
cy.visit("http://localhost:3000/edit");
cy.wait(2000);
cy.get('[data-cy="publish-button"]').click();
cy.wait(1000);
let linkText;
cy.get('[data-cy="link-test"]')
.invoke("text")
.then((text) => {
linkText = text;
});
cy.wait(2000).then(() => {
cy.visit(linkText);
});
cy.origin("https://s.hbpn.link", () => {
// <команды, направленные на https://s.hbpn.link, идут здесь>
cy.get(".MuiFormControlLabel-label").contains("1").click();
cy.get(".MuiButton-containedPrimary").contains("Далее").click();
cy.wait(2000);
cy.contains("p", "Заголовок пожирнее").should("not.exist");
});
// теперь поля заполненны
cy.visit("http://localhost:3000/edit");
cy.get("#heading-result").type("Результат");
cy.get("#headline-is-bolder").type("Заголовок пожирнее");
cy.get("#heading-description").type("Описание обычного заголовка");
cy.get(`[data-cy="add-button"]`).click();
cy.wait(200);
cy.get("#button-text-result").type("Узнать подробнее");
cy.wait(2000).then(() => {
cy.visit(linkText);
});
cy.origin("https://s.hbpn.link", () => {
// <команды, направленные на https://s.hbpn.link, идут здесь>
cy.get(".MuiFormControlLabel-label").contains("1").click();
cy.get(".MuiButton-containedPrimary").contains("Далее").click();
cy.wait(2000);
cy.contains("p", "Заголовок пожирнее").should("exist");
});
// проверяем на страницы в публикации с заполнеными полями после форм контактов
cy.visit("http://localhost:3000/edit");
cy.wait(2000);
cy.get(`[data-cy="expand-question"]`).eq(0).click();
cy.wait(200);
cy.get("#after-the-contact-form").click();
cy.wait(2000);
cy.wait(2000).then(() => {
cy.visit(linkText);
});
cy.origin("https://s.hbpn.link", () => {
// <команды, направленные на https://s.hbpn.link, идут здесь>
cy.get(".MuiFormControlLabel-label").contains("1").click();
cy.get(".MuiButton-containedPrimary").contains("Далее").click();
cy.wait(2000);
cy.get('input[placeholder="имя"]').type("Name");
cy.get('input[placeholder="Email"]').type("valid_user@exammple.com");
cy.get('input[placeholder="номер телефона"]').type("+2682585");
cy.get('input[type="checkbox"]').click();
cy.wait(200);
cy.contains("button", "Получить результаты").click();
cy.wait(2000);
cy.contains("p", "Заголовок пожирнее").should("exist");
cy.contains("p", "Заголовок пожирнее").should("exist");
});
// проверяем на страницы в публикации с пустыми полями после форм контактов
cy.visit("http://localhost:3000/edit");
cy.get("#heading-result").clear();
cy.get("#headline-is-bolder").clear();
cy.get("#heading-description").clear();
cy.get("#button-text-result").clear();
cy.wait(2000).then(() => {
cy.visit(linkText);
});
cy.origin("https://s.hbpn.link", () => {
// <команды, направленные на https://s.hbpn.link, идут здесь>
cy.get(".MuiFormControlLabel-label").contains("1").click();
cy.get(".MuiButton-containedPrimary").contains("Далее").click();
cy.wait(2000);
cy.get('input[placeholder="имя"]').type("Name");
cy.get('input[placeholder="Email"]').type("valid_user@exammple.com");
cy.get('input[placeholder="номер телефона"]').type("+2682585");
cy.get('input[type="checkbox"]').click();
cy.wait(200);
cy.contains("button", "Получить результаты").click();
cy.wait(2000);
cy.wait(2000);
cy.contains("p", "Заголовок пожирнее").should("not.exist");
});
});
});

@ -167,19 +167,14 @@ export const reorderQuestions = (
setProducedState(
(state) => {
// Сортировка вопросов, что бы type: result были в конце для избежания багов
state.questions.sort((question, previousQuestion) =>
question.type === "result" && previousQuestion.type !== "result"
? 1
: question.type !== "result" && previousQuestion.type === "result"
? -1
: 0,
);
const [removed] = state.questions.splice(sourceIndex, 1);
state.questions.splice(destinationIndex, 0, removed);
},
{ type: "reorderQuestions", sourceIndex, destinationIndex },
{
type: "reorderQuestions",
sourceIndex,
destinationIndex,
},
);
updateQuestionOrders();