Files
tom goriunovandGitHub 4b42c5fa70 Call the API logout endpoint when the user logs out (#2469)
* Call the API logout endpoint when the user logs out

* fix tests

* one more fix
2024-12-16 13:22:09 +01:00

29 lines
876 B
TypeScript

import type { TestFixture, Page } from '@playwright/test';
import config from 'configs/app';
import { buildExternalAssetFilePath } from 'configs/app/utils';
export type MockConfigResponseFixture = (envName: string, envValue: string, content: unknown, isImage?: boolean) => Promise<string>;
const fixture: TestFixture<MockConfigResponseFixture, { page: Page }> = async({ page }, use) => {
await use(async(envName, envValue, content, isImage) => {
const url = config.app.baseUrl + buildExternalAssetFilePath(envName, envValue);
if (isImage && typeof content === 'string') {
await page.route(url, (route) => route.fulfill({
status: 200,
path: content,
}));
} else {
await page.route(url, (route) => route.fulfill({
status: 200,
json: content,
}));
}
return url;
});
};
export default fixture;