ConceptPortal-public/rsconcept/frontend/tests/auth.spec.ts
2025-03-20 15:01:35 +03:00

39 lines
1.7 KiB
TypeScript
Raw 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.

import { authAdmin, setupLogin, setupLogout } from './mocks/auth';
import { expect, test } from './setup';
test('should display error message when login with wrong credentials', async ({ page }) => {
await setupLogin(page);
await page.goto('/login');
await page.getByRole('textbox', { name: 'Логин или email' }).fill('123');
await page.getByRole('textbox', { name: 'Пароль' }).fill('123');
await page.getByRole('button', { name: 'Войти' }).click();
await expect(page.getByText('На Портале отсутствует такое сочетание имени пользователя и пароля')).toBeVisible();
await expect(page.getByRole('button', { name: 'Войти' })).toBeEnabled();
});
test('should login as admin successfully', async ({ page }) => {
await setupLogin(page);
await page.goto('/login');
await page.getByRole('textbox', { name: 'Логин или email' }).fill('admin');
await page.getByRole('textbox', { name: 'Пароль' }).fill('password');
await page.getByRole('button', { name: 'Войти' }).click();
await expect(page.getByText('Вы вошли в систему как admin')).toBeVisible();
await expect(page.getByRole('button', { name: 'Войти' })).toHaveCount(0);
});
test('logout procedure and consequence', async ({ page }) => {
authAdmin();
await setupLogout(page);
await page.goto('/');
await page.getByRole('button', { name: 'Пользователь' }).click();
await page.getByRole('button', { name: 'Выход из приложения' }).click();
await page.getByRole('button', { name: 'Перейти на страницу логина' }).click();
await expect(page.getByRole('button', { name: 'Войти' })).toBeVisible();
});