|
| 1 | +// @ts-check |
| 2 | +// |
| 3 | +const { test, expect } = require('@playwright/test'); |
| 4 | + |
| 5 | +test('wrong login', async ({ page }) => { |
| 6 | + await page.goto('http://localhost:5001/'); |
| 7 | + |
| 8 | + expect(page.getByText(/Нет аккаунта?/)).toBeVisible(); |
| 9 | + expect(page.getByAltText(/Войти/)).toBeVisible(); |
| 10 | + expect(page.getByText(/Регистрация/)).toBeVisible(); |
| 11 | + expect(await page.getByText(/Войти/).count()).toEqual(2); |
| 12 | + |
| 13 | + await page.locator('#username').fill('test'); |
| 14 | + await page.locator('#password').fill('test'); |
| 15 | + await page.getByRole('button', { name: 'Войти' }).click(); |
| 16 | + expect(await page.getByText(/Скрытая страница!/).count()).toEqual(0); |
| 17 | + expect(page.getByText(/Неверные имя пользователя или пароль/)).toBeVisible(); |
| 18 | +}); |
| 19 | + |
| 20 | +test('registration page, success login', async ({ page }) => { |
| 21 | + await page.goto('http://localhost:5001/'); |
| 22 | + |
| 23 | + await page.getByText(/Регистрация/).click(); |
| 24 | + expect(page.getByLabel(/Имя пользователя/)).toBeVisible(); |
| 25 | + expect(page.getByLabel(/Пароль/)).toBeVisible(); |
| 26 | + expect(page.getByLabel(/Подтвердите пароль/)).toBeVisible(); |
| 27 | + expect(page.getByText(/Регистрация/)).toBeVisible(); |
| 28 | + expect(page.getByAltText(/Регистрация/)).toBeVisible(); |
| 29 | + |
| 30 | + await page.locator('#username').fill('playwright'); |
| 31 | + await page.locator('#password').fill('password'); |
| 32 | + await page.locator('#confirmPassword').fill('password'); |
| 33 | + await page.getByRole('button', { name: 'Зарегистрироваться' }).click(); |
| 34 | + expect(page.getByText(/Скрытая страница!/)).toBeVisible(); |
| 35 | + |
| 36 | + await page.getByRole('button', { name: 'Выйти' }).click(); |
| 37 | + |
| 38 | + await page.locator('#username').fill('admin'); |
| 39 | + await page.locator('#password').fill('admin'); |
| 40 | + await page.getByRole('button', { name: 'Войти' }).click(); |
| 41 | + expect(page.getByText(/Скрытая страница!/)).toBeVisible(); |
| 42 | +}); |
0 commit comments