Добавил тест на правильность отображения вопросов в превью и тестовом просмотре

This commit is contained in:
ArtChaos189 2024-01-11 18:37:01 +03:00
parent 5366ab6fce
commit f23ffd7213
5 changed files with 503 additions and 1 deletions

@ -0,0 +1,495 @@
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("#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")
.type("{enter}");
// превью
cy.get(`button[data-cy="button-preview"]`).click();
cy.wait(2000);
cy.get(".MuiTypography-h6")
.should("exist")
.and("have.text", "Заголовок вопроса");
cy.get(":nth-child(1) > .MuiFormControlLabel-root")
.should("exist")
.and("have.text", "1");
cy.get(":nth-child(2) > .MuiFormControlLabel-root")
.should("exist")
.and("have.text", "2");
cy.get(`button[data-cy="button-preview"]`).click();
cy.visit("http://localhost:3000/view");
cy.wait(2000);
// проверка введёных значений
cy.get(".MuiTypography-h5")
.should("exist")
.and("have.text", "Заголовок вопроса");
cy.get(":nth-child(1) > .MuiFormControlLabel-root")
.should("exist")
.and("have.text", "1");
cy.get(":nth-child(2) > .MuiFormControlLabel-root")
.should("exist")
.and("have.text", "2");
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("#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")
.type("{enter}");
// превью
cy.get(`button[data-cy="button-preview"]`).click();
cy.wait(2000);
cy.get(".MuiTypography-h6")
.should("exist")
.and("have.text", "Заголовок вопроса");
cy.get(".MuiFormControlLabel-label").contains("1").should("exist");
cy.get(".MuiFormControlLabel-label").contains("2").should("exist");
cy.get(`button[data-cy="button-preview"]`).click();
cy.visit("http://localhost:3000/view");
cy.wait(2000);
// проверка введёных значений
cy.get(".MuiTypography-h5")
.should("exist")
.and("have.text", "Заголовок вопроса");
cy.get(".MuiFormControlLabel-label").contains("1").should("exist");
cy.get(".MuiFormControlLabel-label").contains("2").should("exist");
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("#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")
.type("{enter}");
// превью
cy.get(`button[data-cy="button-preview"]`).click();
cy.wait(2000);
cy.get(".MuiTypography-h6")
.should("exist")
.and("have.text", "Заголовок вопроса");
cy.get(".MuiFormControlLabel-label").contains("1").should("exist");
cy.get(".MuiFormControlLabel-label").contains("2").should("exist");
cy.get(`button[data-cy="button-preview"]`).click();
cy.visit("http://localhost:3000/view");
cy.wait(2000);
// проверка введёных значений
cy.get(".MuiTypography-h5")
.should("exist")
.and("have.text", "Заголовок вопроса");
cy.get(".MuiFormControlLabel-label").contains("1").should("exist");
cy.get(".MuiFormControlLabel-label").contains("2").should("exist");
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("#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")
.type("{enter}");
// превью
cy.get(`button[data-cy="button-preview"]`).click();
cy.wait(2000);
cy.get(".MuiTypography-h6")
.should("exist")
.and("have.text", "Заголовок вопроса");
cy.get(".MuiFormControlLabel-label").contains("1").should("exist");
cy.get(".MuiFormControlLabel-label").contains("2").should("exist");
cy.get(`button[data-cy="button-preview"]`).click();
cy.visit("http://localhost:3000/view");
cy.wait(2000);
// проверка введёных значений
cy.get(".MuiTypography-h5")
.should("exist")
.and("have.text", "Заголовок вопроса");
cy.get(".MuiFormControlLabel-label").contains("1").should("exist");
cy.get(".MuiFormControlLabel-label").contains("2").should("exist");
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("#questionTitle").type("Заголовок вопроса");
cy.get('input[placeholder="Пример ответа"]')
.eq(0)
.type("1")
.type("{enter}");
// превью
cy.get(`button[data-cy="button-preview"]`).click();
cy.wait(2000);
cy.get(".MuiTypography-h6")
.should("exist")
.and("have.text", "Заголовок вопроса");
cy.get('input[placeholder="1"]').should("exist");
cy.get(`button[data-cy="button-preview"]`).click();
cy.visit("http://localhost:3000/view");
cy.wait(2000);
// проверка введёных значений
cy.get(".MuiTypography-h5")
.should("exist")
.and("have.text", "Заголовок вопроса");
cy.get('input[placeholder="1"]').should("exist");
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("#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")
.type("{enter}");
// превью
cy.get(`button[data-cy="button-preview"]`).click();
cy.wait(2000);
cy.get(".MuiTypography-h6")
.should("exist")
.and("have.text", "Заголовок вопроса");
cy.get(".MuiFormControlLabel-label").contains("1").should("exist");
cy.get(".MuiFormControlLabel-label").contains("2").should("exist");
cy.get(`button[data-cy="button-preview"]`).click();
cy.visit("http://localhost:3000/view");
cy.wait(2000);
// проверка введёных значений
cy.get(".MuiTypography-h5")
.should("exist")
.and("have.text", "Заголовок вопроса");
cy.get(".MuiFormControlLabel-label").contains("1").should("exist");
cy.get(".MuiFormControlLabel-label").contains("2").should("exist");
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.get("#questionTitle").type("Заголовок вопроса");
// превью
cy.get(`button[data-cy="button-preview"]`).click();
cy.wait(2000);
cy.get(".MuiTypography-h6")
.should("exist")
.and("have.text", "Заголовок вопроса");
cy.get(`button[data-cy="button-preview"]`).click();
cy.visit("http://localhost:3000/view");
cy.wait(2000);
// проверка введёных значений
cy.get(".MuiTypography-h5")
.should("exist")
.and("have.text", "Заголовок вопроса");
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.get("#questionTitle").type("Заголовок вопроса");
// превью
cy.get(`button[data-cy="button-preview"]`).click();
cy.wait(2000);
cy.get(".MuiTypography-h6")
.should("exist")
.and("have.text", "Заголовок вопроса");
cy.get(".MuiTypography-p")
.should("exist")
.and("have.text", "Заголовок вопроса");
cy.get(`button[data-cy="button-preview"]`).click();
cy.visit("http://localhost:3000/view");
cy.wait(2000);
// проверка введёных значений
cy.get(".MuiTypography-h5")
.should("exist")
.and("have.text", "Заголовок вопроса");
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.get("#questionTitle").type("Заголовок вопроса");
// превью
cy.get(`button[data-cy="button-preview"]`).click();
cy.wait(2000);
cy.get(".MuiTypography-h6")
.should("exist")
.and("have.text", "Заголовок вопроса");
cy.get(`button[data-cy="button-preview"]`).click();
cy.visit("http://localhost:3000/view");
cy.wait(2000);
// проверка введёных значений
cy.get(".MuiTypography-h5")
.should("exist")
.and("have.text", "Заголовок вопроса");
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-page"]`).click();
cy.get(
'[data-cy="checkbox-optional-question"] > .PrivateSwitchBase-input',
).click();
cy.get("#questionTitle").type("Заголовок вопроса");
cy.get("#addText").type("Добавляю текст");
// превью
cy.get(`button[data-cy="button-preview"]`).click();
cy.wait(2000);
cy.get(".MuiTypography-h6")
.should("exist")
.and("have.text", "Заголовок вопроса");
cy.get(".MuiTypography-p")
.should("exist")
.and("have.text", "Добавляю текст");
cy.get(`button[data-cy="button-preview"]`).click();
cy.visit("http://localhost:3000/view");
cy.wait(2000);
// проверка введёных значений
cy.get(".MuiTypography-h5")
.should("exist")
.and("have.text", "Заголовок вопроса");
cy.get(".MuiTypography-p")
.should("exist")
.and("have.text", "Добавляю текст");
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.get("#questionTitle").type("Заголовок вопроса");
// превью
cy.get(`button[data-cy="button-preview"]`).click();
cy.wait(2000);
cy.get(".MuiTypography-h6")
.should("exist")
.and("have.text", "Заголовок вопроса");
cy.get(`button[data-cy="button-preview"]`).click();
cy.visit("http://localhost:3000/view");
cy.wait(2000);
// проверка введёных значений
cy.get(".MuiTypography-h5")
.should("exist")
.and("have.text", "Заголовок вопроса");
cy.wait(500);
cy.get('[data-cy="delete-question"]').click();
cy.wait(5000);
cy.get('[data-cy="create-question"]').click();
});
});

@ -133,6 +133,7 @@ export default function QuestionsPageCard({
}}
>
<TextField
id="questionTitle"
defaultValue={question.title}
placeholder={"Заголовок вопроса"}
onChange={({ target }: { target: HTMLInputElement }) =>

@ -80,6 +80,7 @@ export default function PageOptions({ disableInput, question }: Props) {
}}
>
<CustomTextField
id="addText"
placeholder={"Можно добавить текст"}
text={question.content.text}
onChange={({ target }) => setText(target.value)}

@ -50,7 +50,11 @@ export const DescriptionForm = () => {
mb: "19px",
}}
>
<CustomTextField placeholder="Заголовок вопроса" text={""} />
<CustomTextField
id="questionTitle"
placeholder="Заголовок вопроса"
text={""}
/>
<IconButton>
<ExpandMoreIcon />
</IconButton>

@ -119,6 +119,7 @@ export const EmailSettingsCard = ({ quizExpand }: Props) => {
Тема письма
</Typography>
<TextField
id="questionTitle"
value={quiz.config.resultInfo.theme}
placeholder={"Заголовок вопроса"}
onChange={({ target }: { target: HTMLInputElement }) => {