R: Fix tests

This commit is contained in:
Ivan 2025-03-13 23:56:10 +03:00
parent 8bf829513f
commit 0781dad1cb
2 changed files with 17 additions and 0 deletions

View File

@ -0,0 +1,15 @@
import { type Page } from '@playwright/test';
import { type ILibraryItem } from '../../src/features/library/backend/types';
import { BACKEND_URL } from './constants';
export const dataLibraryItems: ILibraryItem[] = [];
export async function setupLibrary(page: Page) {
await page.route(`${BACKEND_URL}/api/library/all`, async route => {
await route.fulfill({ json: dataLibraryItems });
});
await page.route(`${BACKEND_URL}/api/library/active`, async route => {
await route.fulfill({ json: dataLibraryItems });
});
}

View File

@ -1,6 +1,7 @@
import { test as base } from '@playwright/test'; import { test as base } from '@playwright/test';
import { setupAuth } from './mocks/auth'; import { setupAuth } from './mocks/auth';
import { setupLibrary } from './mocks/library';
import { setupUsers } from './mocks/users'; import { setupUsers } from './mocks/users';
export { expect } from '@playwright/test'; export { expect } from '@playwright/test';
@ -8,6 +9,7 @@ export const test = base.extend({
page: async ({ page }, use) => { page: async ({ page }, use) => {
await setupAuth(page); await setupAuth(page);
await setupUsers(page); await setupUsers(page);
await setupLibrary(page);
await use(page); await use(page);
} }