From 257a53c97e55bad3cbea7faea034d338a8555edb Mon Sep 17 00:00:00 2001 From: Vlad Smykov Date: Thu, 29 Jan 2026 14:36:41 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20Lo?= =?UTF-8?q?ginPage,=D0=B0=20=D1=82=D0=B0=D0=BA=D0=B6=D0=B5=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=B7=D0=B8=D1=82=D0=B8=D0=B2=D0=BD=D1=8B=D0=B5=20UI,=20API=20?= =?UTF-8?q?=D1=82=D0=B5=D1=81=D1=82=D1=8B=20=D0=B4=D0=BB=D1=8F=20=D0=B0?= =?UTF-8?q?=D0=B2=D1=82=D0=BE=D1=80=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D0=B8=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5?= =?UTF-8?q?=D0=BB=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fixtures/users.ts | 8 ++++++ package.json | 1 + page-objects/LoginPage.ts | 31 ++++++++++++++++++++++ tests/api/auth/login-applicant.api.spec.ts | 18 +++++++++++++ tests/ui/auth/login-applicant.spec.ts | 18 +++++++++++++ 5 files changed, 76 insertions(+) create mode 100644 fixtures/users.ts create mode 100644 page-objects/LoginPage.ts create mode 100644 tests/api/auth/login-applicant.api.spec.ts create mode 100644 tests/ui/auth/login-applicant.spec.ts diff --git a/fixtures/users.ts b/fixtures/users.ts new file mode 100644 index 0000000..b02b59b --- /dev/null +++ b/fixtures/users.ts @@ -0,0 +1,8 @@ +// fixtures/users.ts +export const testUsers = { + applicant: { + login: 'autotestapplicant', + password: '!Test123456', + id: '85d99f9f-1abd-45e8-a952-8da45ee7e63f', + }, +}; diff --git a/package.json b/package.json index c1b3e90..aefef72 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "test:clean": "rm -rf allure-results allure-report playwright-report", "test:ui": "npx playwright test tests/ui", "test:api": "npx playwright test tests/api", + "test:login": "npx playwright test tests/ui/auth/login-applicant.spec.ts", "report": "npx playwright show-report", "allure:report": "allure generate ./allure-results --clean -o ./allure-report && allure open ./allure-report" }, diff --git a/page-objects/LoginPage.ts b/page-objects/LoginPage.ts new file mode 100644 index 0000000..d831392 --- /dev/null +++ b/page-objects/LoginPage.ts @@ -0,0 +1,31 @@ +// page-objects/LoginPage.ts + +import { Page } from '@playwright/test'; + +export class LoginPage { + readonly page: Page; + + constructor(page: Page) { + this.page = page; + } + + async goto() { + await this.page.goto('/authorization'); // или '/auth', если маршрут другой + } + + async fillLogin(login: string) { + await this.page.fill('input[name="login"]', login); + } + + async fillPassword(password: string) { + await this.page.fill('input[name="password"]', password); + } + + async submit() { + await this.page.click('button[type="submit"]'); + } + + async assertSuccessfulLogin() { + await this.page.waitForURL('**/account/profile'); // или '/', если перебрасывает на главную + } +} diff --git a/tests/api/auth/login-applicant.api.spec.ts b/tests/api/auth/login-applicant.api.spec.ts new file mode 100644 index 0000000..9e5900f --- /dev/null +++ b/tests/api/auth/login-applicant.api.spec.ts @@ -0,0 +1,18 @@ +import { test, expect } from '@playwright/test'; +import axios from 'axios'; + +const BASE_URL = 'https://rumc.dev.rdcenter.ru/api'; + +test('API: успешная авторизация абитуриента', async () => { + const payload = { + login: 'autotestapplicant', + password: '!Test123456', + }; + + const res = await axios.post(`${BASE_URL}/auth/login`, payload); + + expect(res.status).toBe(200); + expect(res.data).toHaveProperty('access_token'); + + console.log('✅ Авторизация успешна. Access token:', res.data.access_token); +}); diff --git a/tests/ui/auth/login-applicant.spec.ts b/tests/ui/auth/login-applicant.spec.ts new file mode 100644 index 0000000..aa88a66 --- /dev/null +++ b/tests/ui/auth/login-applicant.spec.ts @@ -0,0 +1,18 @@ +// tests/ui/auth/login-applicant.spec.ts + +import { test, expect } from '@playwright/test'; +import { LoginPage } from '../../../page-objects/LoginPage'; +import { testUsers } from '../../../fixtures/users'; + +test('UI: успешная авторизация абитуриента', async ({ page }) => { + const loginPage = new LoginPage(page); + const user = testUsers.applicant; + + await loginPage.goto(); + await loginPage.fillLogin(user.login); + await loginPage.fillPassword(user.password); + await loginPage.submit(); + await loginPage.assertSuccessfulLogin(); + + await expect(page).toHaveURL(/\/account\/profile$/); +});