Добавлен UI тест для позитивной проверки восстановления пароля, также добавлена фильтрация писем для почтового сервиса
This commit is contained in:
44
tests/ui/auth/recover-password.spec.ts
Normal file
44
tests/ui/auth/recover-password.spec.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { LoginPage } from '../../../page-objects/LoginPage';
|
||||
import fs from 'fs';
|
||||
import {
|
||||
waitForConfirmationCode
|
||||
} from '../../../utils/mailTmApi';
|
||||
|
||||
test('UI: восстановление пароля', async ({ page }) => {
|
||||
// Загружаем email пользователя из файла temp/user.json
|
||||
const loginPage = new LoginPage(page);
|
||||
const user = JSON.parse(fs.readFileSync('temp/user.json', 'utf-8'));
|
||||
const newPassword = '!Test12345678';
|
||||
|
||||
// Переход на главную
|
||||
await loginPage.goto();
|
||||
|
||||
// Нажимаем "Забыли пароль?"
|
||||
await page.getByText('Забыли пароль?').click();
|
||||
await expect(page).toHaveURL(/.*confirmation-code/);
|
||||
|
||||
// Вводим почту
|
||||
await page.fill('input[name="email"]', user.email);
|
||||
await page.getByRole('button', { name: 'Далее' }).click();
|
||||
|
||||
// Получаем код из почты
|
||||
const code = await waitForConfirmationCode(user.email, user.mailToken, 'recover');
|
||||
expect(code).toMatch(/^\d{6}$/);
|
||||
console.log('✅ Код получен:', code);
|
||||
// Вводим код
|
||||
await page.fill('input[name="code"]', code);
|
||||
await page.getByRole('button', { name: 'Далее' }).click();
|
||||
|
||||
// Вводим новый пароль
|
||||
await page.fill('input[name="password"]', newPassword);
|
||||
await page.fill('input[name="passwordRepeat"]', newPassword);
|
||||
await page.getByRole('button', { name: 'Далее' }).click();
|
||||
|
||||
// Проверяем успешную авторизацию
|
||||
await expect(page).toHaveURL(/.*\/account\/profile/);
|
||||
|
||||
// (необязательно) обновляем сохранённый пароль
|
||||
//user.password = newPassword;
|
||||
//fs.writeFileSync('temp/user.json', JSON.stringify(user));
|
||||
});
|
||||
@@ -44,7 +44,7 @@ test('Полная регистрация абитуриента с подтве
|
||||
await registerPage.submit();
|
||||
|
||||
await expect(page).toHaveURL(/confirmation-code/);
|
||||
const code = await waitForConfirmationCode(token, 60000);
|
||||
const code = await waitForConfirmationCode(email, token, 'register', 60000);
|
||||
|
||||
await page.fill('input[name="code"]', code);
|
||||
await page.click('button.RecoverPassword_button__5QDxM');
|
||||
|
||||
@@ -46,7 +46,7 @@ test('Полная регистрация выпускника с подтвер
|
||||
|
||||
await page.waitForTimeout(5000);
|
||||
await expect(page).toHaveURL(/confirmation-code/);
|
||||
const code = await waitForConfirmationCode(token, 60000);
|
||||
const code = await waitForConfirmationCode(email, token, 'register', 60000);
|
||||
|
||||
await page.fill('input[name="code"]', code);
|
||||
await page.click('button.RecoverPassword_button__5QDxM');
|
||||
|
||||
@@ -78,7 +78,7 @@ test('Полная регистрация организации с подтве
|
||||
await registerPage.submitGeneral();
|
||||
|
||||
await expect(page).toHaveURL(/confirmation-code/);
|
||||
const code = await waitForConfirmationCode(token, 60000);
|
||||
const code = await waitForConfirmationCode(email, token, 'register', 60000);
|
||||
|
||||
await page.fill('input[name="code"]', code);
|
||||
await page.click('button.RecoverPassword_button__5QDxM');
|
||||
|
||||
Reference in New Issue
Block a user