mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-26 04:50:36 +03:00
T: Implement backend mocking for tests
This commit is contained in:
parent
b43c46e6c6
commit
da9745125e
|
@ -1,9 +1,14 @@
|
||||||
import { expect, test } from '@playwright/test';
|
import { expect, test } from '@playwright/test';
|
||||||
|
|
||||||
|
import { authAnonymous } from './mocks/auth';
|
||||||
|
|
||||||
test('should load the homepage and display login button', async ({ page }) => {
|
test('should load the homepage and display login button', async ({ page }) => {
|
||||||
|
await authAnonymous(page);
|
||||||
|
|
||||||
await page.goto('/');
|
await page.goto('/');
|
||||||
await expect(page).toHaveTitle('Концепт Портал');
|
await expect(page).toHaveTitle('Концепт Портал');
|
||||||
await expect(page.getByRole('heading', { name: 'Портал' })).toBeVisible();
|
await expect(page.getByRole('heading', { name: 'Портал' })).toBeVisible();
|
||||||
|
|
||||||
await page.click('.h-full > .mr-1');
|
await page.click('.h-full > .mr-1');
|
||||||
await expect(page.getByText('Логин или email')).toBeVisible();
|
await expect(page.getByText('Логин или email')).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
1
rsconcept/frontend/tests/constants.ts
Normal file
1
rsconcept/frontend/tests/constants.ts
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export const BACKEND_URL = 'http://localhost:8000';
|
9
rsconcept/frontend/tests/mocks/auth.ts
Normal file
9
rsconcept/frontend/tests/mocks/auth.ts
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
import { Page } from '@playwright/test';
|
||||||
|
|
||||||
|
import { BACKEND_URL } from '../constants';
|
||||||
|
|
||||||
|
export async function authAnonymous(page: Page) {
|
||||||
|
await page.route(`${BACKEND_URL}/users/api/auth`, async route => {
|
||||||
|
await route.fulfill({ json: { id: null } });
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user