Files
at-digitaltwin/page-objects/UsersAccount/ProfileApplicantPage.ts

172 lines
7.4 KiB
TypeScript
Raw Permalink 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.
// page-objects/ProfileApplicantPage.ts
import { Page } from '@playwright/test';
export class ProfileApplicantPage {
readonly page: Page;
constructor(page: Page) {
this.page = page;
}
async goto() {
await this.page.goto('/account/profile');
}
// Профиль
async openBasicInfoEditor() {
await this.page.getByTestId('btn-pensil').nth(0).click();
}
async uploadAvatar(filePath: string) {
const [fileChooser] = await Promise.all([
this.page.waitForEvent('filechooser'),
this.page.getByTestId('ModalUserInfo').getByTestId('btn-pensil').first().click(),
]);
await fileChooser.setFiles(filePath);
}
async fillCity(city: string) {
await this.page.fill('input[name="city"]', city);
}
async saveBasicInfo() {
await this.page.getByTestId('btn-save').click();
}
async openRepresentativeEditor() {
await this.page.getByTestId('btn-pensil').nth(1).click();
}
async fillRepresentative(from: string, fullName: string, phone: string) {
await this.page.fill('input[name="parents.0.from"]', from);
await this.page.fill('input[name="parents.0.fio"]', fullName);
await this.page.fill('input[name="parents.0.phone"]', phone);
}
async saveRepresentative() {
await this.page.locator('button:has-text("Сохранить")').click();
}
async openDisabilityEditor() {
await this.page.getByTestId('btn-pensil').nth(2).click();
}
async selectDisability(disability: string) {
await this.page.getByText(disability).click();
}
async selectDisabilityGroup(group: string) {
await this.page.getByText(group).first().click();
}
async saveDisabilityInfo() {
await this.page.locator('button:has-text("Сохранить")').click();
}
//Тесты
async openTestsPage() {
await this.page.getByRole('main').getByText('Тесты').click()
await this.page.getByText('Тест для позитивного сценария Playwright', { exact: true }).scrollIntoViewIfNeeded();
await this.page.getByRole('button', { name: 'Пройти тест' }).first().click();
await this.page.getByRole('button', { name: 'Начать тест' }).click();
await this.page.locator('.Checkmark_checkmark__58fWm').first().click();
await this.page.getByRole('button', { name: 'next' }).click();
await this.page.locator('.swiper-slide.swiper-slide-active > .Questions_slide__-Yhoj > #questionItem >' +
'.Question_answers__xra74 > #answer > #checkmark > .Checkmark_checkmark__58fWm').click();
await this.page.getByRole('button', { name: 'Завершить тест' }).click();
await this.page.getByRole('button', { name: 'К тестам' }).click();
}
//Портфолио
async openPortfolioPage() {
await this.page.getByRole('main').getByRole('listitem').filter({ hasText: 'Портфолио' }).click();
}
//Достижения
async clickAchievementButton() {
await this.page.locator('button').filter({ hasText: /^\+ Добавить$/ }).click();
}
async fillAchievementInfo() {
await this.page.getByRole('textbox', { name: 'Полное название' }).fill('Тестовое достижение');
await this.page.getByRole('textbox', { name: 'Не выбран' }).click();
await this.page.locator('#modal-main').getByText('2026', { exact: true }).first().click();
}
async uploadAchievement(filePath: string) {
const [fileChooser] = await Promise.all([
this.page.waitForEvent('filechooser'),
await this.page.getByText('Загрузите сертификат').click()
]);
await fileChooser.setFiles(filePath);
}
async clickAchievementSaveButton() {
await this.page.getByTestId('btn-save').click();
}
//Образование
async clickEducationButton() {
await this.page.locator('section').filter({ hasText: 'Образование' }).getByRole('button').click();
}
async fillEducationInfo() {
await this.page.getByRole('textbox', { name: 'Учебное заведение' }).fill('Тестовое заведение');
await this.page.getByRole('textbox', { name: 'Название специальности' }).fill('Тестовая специальность');
await this.page.locator('#yearStart').click();
await this.page.getByText('2020').click();
await this.page.locator('.Checkmark_checkmark__58fWm').click();
await this.page.locator('#yearEnd').click();
await this.page.locator('#scroll').getByText('2026').click();
await this.page.getByRole('textbox', { name: 'Очное' }).click();
await this.page.getByText('Очная', { exact: true }).click();
await this.page.getByRole('textbox', { name: 'Бюджет' }).click();
await this.page.getByText('Бюджет', { exact: true }).click();
await this.page.locator('#educationLevel').click();
await this.page.getByText('Бакалавриат').click();
}
async uploadEducation(filePath: string) {
const [fileChooser] = await Promise.all([
this.page.waitForEvent('filechooser'),
await this.page.getByText('Загрузите документ об образовании').click()
]);
await fileChooser.setFiles(filePath);
}
async clickEducationSaveButton() {
await this.page.getByRole('button', { name: 'Сохранить' }).click();
}
//Опыт работы
async clickWorkExpButton() {
await this.page.locator('section').filter({ hasText: 'Опыт работы + Добавить' }).getByRole('button').click();
}
async fillWorkExpInfo() {
await this.page.getByRole('textbox', { name: 'Полное название' }).fill('Тестовое название компании');
await this.page.getByRole('textbox', { name: 'Название должности' }).fill('Тестовая должность');
await this.page.getByRole('textbox', { name: 'Не выбрано' }).click();
await this.page.getByRole('textbox', { name: 'Не выбрано' }).fill('программист');
await this.page.getByRole('heading', { name: 'Связь, информационные и коммуникационные технологии' }).click();
await this.page.getByText('Программист', { exact: true }).click();
await this.page.getByRole('textbox', { name: 'Описание' }).fill('Тестовое описание опыта работы');
await this.page.getByRole('textbox', { name: '01.01.1999' }).fill('01.01.2020');
}
async uploadWorkExp(filePath: string) {
const [fileChooser] = await Promise.all([
this.page.waitForEvent('filechooser'),
await this.page.getByText('Загрузить подтверждающий документ').click()
]);
await fileChooser.setFiles(filePath);
}
async clickWorkExpSaveButton() {
await this.page.getByRole('button', { name: 'Сохранить' }).click();
}
//Дополнительные ссылки
async clickAdditionalLinksButton() {
await this.page.getByTestId('btn-pensil').click();
await this.page.getByRole('button', { name: 'plusIcon Добавить' }).click();
}
async fillAdditionalLinksInfo() {
await this.page.getByRole('textbox', { name: 'Название' }).fill('Тестовая платформа');
await this.page.getByRole('textbox', { name: 'Вставьте ссылку' }).fill('https://github.com/vsmykov');
}
async clickAdditionalLinksSaveButton() {
await this.page.getByRole('button', { name: 'Сохранить' }).click();
}
}