diff --git a/.DS_Store b/.DS_Store index 11a20f3..50d15c7 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/fixtures/.DS_Store b/fixtures/.DS_Store index 5008ddf..8ddcf34 100644 Binary files a/fixtures/.DS_Store and b/fixtures/.DS_Store differ diff --git a/fixtures/achievement_information.pdf b/fixtures/achievement_information.pdf new file mode 100644 index 0000000..7353fd7 Binary files /dev/null and b/fixtures/achievement_information.pdf differ diff --git a/fixtures/education_information.pdf b/fixtures/education_information.pdf new file mode 100644 index 0000000..4d3b2f1 Binary files /dev/null and b/fixtures/education_information.pdf differ diff --git a/fixtures/workExp_information.pdf b/fixtures/workExp_information.pdf new file mode 100644 index 0000000..490fda3 Binary files /dev/null and b/fixtures/workExp_information.pdf differ diff --git a/page-objects/LoginPage.ts b/page-objects/LoginPage.ts index d831392..516069b 100644 --- a/page-objects/LoginPage.ts +++ b/page-objects/LoginPage.ts @@ -10,7 +10,7 @@ export class LoginPage { } async goto() { - await this.page.goto('/authorization'); // или '/auth', если маршрут другой + await this.page.goto('/authorization'); } async fillLogin(login: string) { diff --git a/page-objects/UsersAccount/ProfileApplicantPage.ts b/page-objects/UsersAccount/ProfileApplicantPage.ts index 89ce0c5..ad7ccac 100644 --- a/page-objects/UsersAccount/ProfileApplicantPage.ts +++ b/page-objects/UsersAccount/ProfileApplicantPage.ts @@ -13,6 +13,7 @@ export class ProfileApplicantPage { await this.page.goto('/account/profile'); } +// Профиль async openBasicInfoEditor() { await this.page.getByTestId('btn-pensil').nth(0).click(); } @@ -62,4 +63,110 @@ export class ProfileApplicantPage { 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(); + } +} \ No newline at end of file diff --git a/temp/user.json b/temp/user.json index 473c7aa..a034c18 100644 --- a/temp/user.json +++ b/temp/user.json @@ -1 +1 @@ -{"email":"testuser1770382880998@virgilian.com","password":"!Test123456","login":"user_9im58j","mailToken":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpYXQiOjE3NzAzODI4ODEsInJvbGVzIjpbIlJPTEVfVVNFUiJdLCJhZGRyZXNzIjoidGVzdHVzZXIxNzcwMzgyODgwOTk4QHZpcmdpbGlhbi5jb20iLCJpZCI6IjY5ODVlNjIxNTMzYjdmZmY5YjBkZWZhOCIsIm1lcmN1cmUiOnsic3Vic2NyaWJlIjpbIi9hY2NvdW50cy82OTg1ZTYyMTUzM2I3ZmZmOWIwZGVmYTgiXX19.mO_8aGsS6FxHX53EzTXbnm063zSeKfaqR79Ls280VY54rE2Hhb32RtoD8ECYynRAeJZJekXzGZnD0ciBSFz3zA"} \ No newline at end of file +{"email":"testuser1770898568523@dollicons.com","password":"!Test123456","login":"user_vwqo3m","mailToken":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpYXQiOjE3NzA4OTg1NjksInJvbGVzIjpbIlJPTEVfVVNFUiJdLCJhZGRyZXNzIjoidGVzdHVzZXIxNzcwODk4NTY4NTIzQGRvbGxpY29ucy5jb20iLCJpZCI6IjY5OGRjNDg5MDNlZTQ5OWNkYjBhZDY3NCIsIm1lcmN1cmUiOnsic3Vic2NyaWJlIjpbIi9hY2NvdW50cy82OThkYzQ4OTAzZWU0OTljZGIwYWQ2NzQiXX19._iJUK5fg6n4nuG16K1yKqheaNd7ItjXctNAyu7F-kLHIaluoFU73dItBWgszKoZgrbD5gc1GBG3YK5V-5ds-qQ"} \ No newline at end of file diff --git a/tests/ui/account/profile-applicant.spec.ts b/tests/ui/account/profile-applicant.spec.ts index 5990726..024422e 100644 --- a/tests/ui/account/profile-applicant.spec.ts +++ b/tests/ui/account/profile-applicant.spec.ts @@ -4,40 +4,90 @@ import path from 'path'; import { LoginPage } from '../../../page-objects/LoginPage'; import { ProfileApplicantPage } from '../../../page-objects/UsersAccount/ProfileApplicantPage'; -test('UI: Личный кабинет абитуриента — заполнение профиля', async ({ page }) => { - const user = JSON.parse(fs.readFileSync('temp/user.json', 'utf-8')); - const loginPage = new LoginPage(page); - const profilePage = new ProfileApplicantPage(page); +test.describe('UI: Личный кабинет абитуриента', () => { + test.beforeEach(async ({ page }) => { + const user = JSON.parse(fs.readFileSync('temp/user.json', 'utf-8')); + const loginPage = new LoginPage(page); + const profilePage = new ProfileApplicantPage(page); - // Авторизация - await loginPage.goto(); - await loginPage.fillLogin(user.login); - await loginPage.fillPassword(user.password); - await loginPage.submit(); - await expect(page).toHaveURL(/.*\/account\/profile/); + await loginPage.goto(); + await loginPage.fillLogin(user.login); + await loginPage.fillPassword(user.password); + await loginPage.submit(); + await expect(page).toHaveURL(/.*\/account\/profile/); - // Открытие редактирования базовой информации - await profilePage.goto(); - await profilePage.openBasicInfoEditor(); - await profilePage.uploadAvatar(path.resolve('fixtures', 'avatar.png')); // добавь этот файл в проект - await profilePage.fillCity('Таганрог'); - await profilePage.saveBasicInfo(); + await profilePage.goto(); + }); - // Редактирование представителя - await profilePage.openRepresentativeEditor(); - await profilePage.fillRepresentative( - 'Мать', - 'Иванова Мария Петровна', - '+7 (900) 123-45-67' -); - await profilePage.saveRepresentative(); + test('UI: Личный кабинет абитуриента — заполнение профиля', async ({ page }) => { + const loginPage = new LoginPage(page); + const profilePage = new ProfileApplicantPage(page); + await profilePage.openBasicInfoEditor(); + await profilePage.uploadAvatar(path.resolve('fixtures', 'avatar.png')); + await profilePage.fillCity('Таганрог'); + await profilePage.saveBasicInfo(); + await profilePage.openRepresentativeEditor(); + await profilePage.fillRepresentative( + 'Мать', + 'Иванова Мария Петровна', + '+7 (900) 123-45-67' + ); + await profilePage.saveRepresentative(); + await profilePage.openDisabilityEditor(); + await profilePage.selectDisability('Нарушение слуха'); + await profilePage.selectDisabilityGroup('I группа'); + await profilePage.saveDisabilityInfo(); - // Редактирование инвалидности - await profilePage.openDisabilityEditor(); - await profilePage.selectDisability('Нарушение слуха'); - await profilePage.selectDisabilityGroup('I группа'); - await profilePage.saveDisabilityInfo(); + await expect(page).toHaveURL(/.*\/account\/profile/); + }); + + test('UI: Личный кабинет абитуриента — прохождение теста', async ({ page }) => { + const loginPage = new LoginPage(page); + const profilePage = new ProfileApplicantPage(page); + await profilePage.openTestsPage(); + await expect(page.getByRole('button', { name: 'Посмотреть результаты' })).toBeVisible(); + + }); + + test('UI: Личный кабинет абитуриента — заполнение портфолио', async ({ page }) => { + const loginPage = new LoginPage(page); + const profilePage = new ProfileApplicantPage(page); + + //Достижения + await profilePage.openPortfolioPage(); + await profilePage.clickAchievementButton(); + await profilePage.fillAchievementInfo(); + await profilePage.uploadAchievement(path.resolve('fixtures', 'achievement_information.pdf')); + await profilePage.clickAchievementSaveButton(); + + await expect(page.getByRole('heading', { name: 'Тестовое достижение' })).toBeVisible(); + await expect(page.getByText('2026', { exact: true })).toBeVisible(); + await expect(page.getByRole('link', { name: 'achievement_information.pdf' })).toBeVisible(); + + //Образование + await profilePage.clickEducationButton(); + await profilePage.fillEducationInfo(); + await profilePage.uploadEducation(path.resolve('fixtures', 'education_information.pdf')); + await profilePage.clickEducationSaveButton(); + + await expect(page.getByRole('heading', { name: 'Тестовое заведение' })).toBeVisible(); + await expect(page.getByRole('heading', { name: 'Тестовая специальность' })).toBeVisible(); + await expect(page.getByText('- 2026')).toBeVisible(); + await expect(page.getByText('Форма обучения: Очная')).toBeVisible(); + await expect(page.getByText('Основа обучения: Бюджет')).toBeVisible(); + await expect(page.getByText('Уровень образования: Бакалавриат')).toBeVisible(); + + //Опыт работы + await profilePage.clickWorkExpButton(); + await profilePage.fillWorkExpInfo(); + await profilePage.uploadWorkExp(path.resolve('fixtures', 'workExp_information.pdf')); + await profilePage.clickWorkExpSaveButton(); + + //Дополнительные ссылки + await profilePage.clickAdditionalLinksButton(); + await profilePage.fillAdditionalLinksInfo(); + await profilePage.clickAdditionalLinksSaveButton(); + }) + +}) - // Проверка, что остались на профиле - await expect(page).toHaveURL(/.*\/account\/profile/); -});