Initial commit: added Playwright tests
This commit is contained in:
83
page-objects/RecoverPage.ts
Normal file
83
page-objects/RecoverPage.ts
Normal file
@@ -0,0 +1,83 @@
|
||||
import { type Page, type Locator } from '@playwright/test';
|
||||
|
||||
export class RecoverPage {
|
||||
readonly page: Page;
|
||||
|
||||
// Этап 1: Ввод email
|
||||
readonly emailInput: Locator;
|
||||
readonly continueButton: Locator;
|
||||
readonly continueButton2: Locator;
|
||||
|
||||
// Этап 2: Ввод кода
|
||||
readonly codeInputs: Locator;
|
||||
readonly resendButton: Locator;
|
||||
|
||||
// Этап 3: Ввод нового пароля
|
||||
readonly newPasswordInput: Locator;
|
||||
readonly repeatPasswordInput: Locator;
|
||||
readonly submitPasswordButton: Locator;
|
||||
|
||||
// --- Ошибки ---
|
||||
readonly emailFormatError: Locator;
|
||||
readonly codeError: Locator;
|
||||
readonly passwordError: Locator;
|
||||
readonly passwordRepeatError: Locator;
|
||||
readonly mismatchPasswordError: Locator;
|
||||
|
||||
constructor(page: Page) {
|
||||
this.page = page;
|
||||
|
||||
// Этап 1
|
||||
this.emailInput = page.getByPlaceholder('Email');
|
||||
this.continueButton = page.getByRole('button', { name: 'Далее' });
|
||||
|
||||
// Этап 2
|
||||
this.codeInputs = page.locator('input[type="text"]'); // предполагаем, 6 полей или одно поле с 6 символами
|
||||
this.resendButton = page.getByRole('button', { name: 'Отправить код повторно' });
|
||||
|
||||
// Этап 3
|
||||
this.newPasswordInput = page.getByPlaceholder('Придумайте пароль');
|
||||
this.repeatPasswordInput = page.getByPlaceholder('Повторите пароль');
|
||||
this.submitPasswordButton = page.getByRole('button', { name: 'Продолжить' });
|
||||
this.continueButton2 = page.getByRole('button', { name: 'Продолжить' });
|
||||
|
||||
// Ошибки
|
||||
this.emailFormatError = page.getByText('Некорректный email*', { exact: true });
|
||||
this.codeError = page.getByText('Ошибка подтверждения', { exact: true });
|
||||
this.passwordError = page.getByText('Некорректный пароль', { exact: true });
|
||||
this.passwordRepeatError = page.getByText('Поле обязательно для заполнения', { exact: true });
|
||||
this.mismatchPasswordError = page.getByText('Пароли не совпадают', { exact: true });
|
||||
}
|
||||
|
||||
async goto() {
|
||||
await this.page.goto('/recoverpassword');
|
||||
}
|
||||
|
||||
async enterEmail(email: string) {
|
||||
await this.emailInput.fill(email);
|
||||
await this.continueButton.click();
|
||||
}
|
||||
|
||||
async enterVerificationCode(code: string) {
|
||||
// Если это один input — просто заполни его
|
||||
if (await this.codeInputs.count() === 1) {
|
||||
await this.codeInputs.first().fill(code);
|
||||
} else {
|
||||
// Если 6 отдельных инпутов, разделяем
|
||||
for (let i = 0; i < code.length; i++) {
|
||||
await this.codeInputs.nth(i).fill(code[i]);
|
||||
}
|
||||
}
|
||||
await this.continueButton2.click();
|
||||
}
|
||||
|
||||
async resendCode() {
|
||||
await this.resendButton.click();
|
||||
}
|
||||
|
||||
async enterNewPassword(password: string, repeat: string) {
|
||||
await this.newPasswordInput.fill(password);
|
||||
await this.repeatPasswordInput.fill(repeat);
|
||||
await this.submitPasswordButton.click();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user