frontPanel/cypress/e2e/quizHomePageFields.cy.ts
2024-04-26 17:41:36 +03:00

139 lines
5.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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"]').click();
cy.wait(1000);
cy.get('button[data-cy="select-quiz-layout-standard"]').click();
cy.get("#contentButton").click();
cy.get("#headingInput").type("Заголовок заголовка");
cy.get("#textInput").type("У нас тут какой-то текст");
cy.get("#buttonTextInput").type("Нажми на кнопку");
cy.get("#phoneInput").type("8-800-000-00-00");
cy.get("#companyInput").type("Наш слоган - слоган наш");
cy.get("#websiteInput").type("http://vk:3000/edit");
cy.get("#legalInformationInput").type("У наших документов есть данные");
cy.get(`button[data-cy="button-preview"]`).click();
cy.wait(2000);
// проверка введёных значений
cy.get(`[data-cy="heading"]`)
.should("exist")
.and("have.text", "Заголовок заголовка");
cy.get(`[data-cy="text"]`)
.should("exist")
.and("have.text", "У нас тут какой-то текст");
cy.get(`[data-cy="phonenumber"`)
.should("exist")
.and("have.text", "8-800-000-00-00");
cy.get(`[data-cy="startpage-button"]`)
.should("exist")
.and("have.text", "Нажми на кнопку");
cy.get(`[data-cy="company"]`)
.should("exist")
.and("have.text", "Наш слоган - слоган наш");
cy.get(`[data-cy="legalInformation"]`)
.should("exist")
.and("have.text", "У наших документов есть данные");
cy.get(`button[data-cy="button-preview"]`).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('[data-cy="quiz-variant-question-answer"]')
.eq(0)
.type("1")
.type("{enter}");
cy.get('button[data-cy="back-button"]').scrollIntoView().wait(500).click();
cy.wait(1000);
cy.visit("http://localhost:3000/view");
cy.wait(2000);
//проверка введёных значений
cy.get(`[data-cy="heading"]`)
.should("exist")
.and("have.text", "Заголовок заголовка");
cy.get(`[data-cy="text"]`)
.should("exist")
.and("have.text", "У нас тут какой-то текст");
cy.get(`[data-cy="phonenumber"`)
.should("exist")
.and("have.text", "8-800-000-00-00");
cy.get(`[data-cy="startpage-button"]`)
.should("exist")
.and("have.text", "Нажми на кнопку");
cy.get(`[data-cy="company"]`)
.should("exist")
.and("have.text", "Наш слоган - слоган наш");
cy.get(`[data-cy="legalInformation"]`)
.should("exist")
.and("have.text", "У наших документов есть данные");
cy.visit("http://localhost:3000/edit");
cy.wait(2000);
cy.get(`[data-cy="publish-button"]`).click();
cy.wait(500);
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.contains("p", "Заголовок заголовка").should("exist");
cy.wait(100);
cy.contains("p", "У нас тут какой-то текст").should("exist");
cy.wait(100);
cy.contains("p", "8-800-000-00-00").should("exist");
cy.wait(100);
cy.contains("p", "Наш слоган - слоган наш").should("exist");
cy.wait(100);
cy.contains("p", "У наших документов есть данные").should("exist");
cy.wait(100);
cy.get(`button`).should("exist").and("have.text", "Нажми на кнопку");
});
cy.visit("http://localhost:3000/list");
cy.wait(2000);
cy.get('[data-cy="quiz-card"] h5')
.should("exist")
.and("have.text", "Заголовок заголовка");
});
});