20c19d15f4
Modern.js SSR intercepts all routes before any Express middleware, so the API proxy runs as a separate Express server on port 8080. Modern.js runs on 8081. The proxy uses curl subprocesses which go through the system HTTPS proxy (GOST) with a proper TLS fingerprint that the Aeroflot WAF accepts. Usage: node scripts/dev-server.mjs (replaces pnpm dev for full-stack) Also: remove stray e2e-angular test directory, fix env default to same-origin /api.
61 lines
1.6 KiB
TypeScript
61 lines
1.6 KiB
TypeScript
/* eslint-disable react-hooks/rules-of-hooks */
|
|
import { test as base, Page } from '@playwright/test';
|
|
import { mockAngularAPIs } from './angular-api-mock';
|
|
|
|
export type CrossAppFixtures = {
|
|
locale: string;
|
|
app: 'angular' | 'react';
|
|
localePath: (path: string) => string;
|
|
page: Page;
|
|
};
|
|
|
|
/**
|
|
* Mock APIs for both Angular and React apps.
|
|
* Both apps use the same backend API endpoints.
|
|
*/
|
|
export async function mockAllAPIs(page: Page): Promise<void> {
|
|
await mockAngularAPIs(page);
|
|
}
|
|
|
|
const ANGULAR_LOCALE_MAP: Record<string, string> = {
|
|
'ru-ru': 'ru',
|
|
'en-us': 'en',
|
|
'es-es': 'es',
|
|
'fr-fr': 'fr',
|
|
'it-it': 'it',
|
|
'ja-jp': 'ja',
|
|
'ko-kr': 'ko',
|
|
'zh-cn': 'zh',
|
|
'de-de': 'de',
|
|
};
|
|
|
|
export const test = base.extend<CrossAppFixtures>({
|
|
locale: ['ru-ru', { option: true }],
|
|
app: [
|
|
// eslint-disable-next-line no-empty-pattern
|
|
async ({}, use, testInfo) => {
|
|
const projectName = testInfo.project.name;
|
|
const app = projectName.startsWith('angular-') ? 'angular' : 'react';
|
|
await use(app as 'angular' | 'react');
|
|
},
|
|
{ auto: true },
|
|
],
|
|
localePath: async ({ locale, app }, use) => {
|
|
await use((path: string) => {
|
|
const cleanPath = path.startsWith('/') ? path.slice(1) : path;
|
|
// Angular app doesn't use locale in URL path
|
|
if (app === 'angular') {
|
|
return `/${cleanPath}`;
|
|
}
|
|
return `/${locale}/${cleanPath}`;
|
|
});
|
|
},
|
|
page: async ({ page }, use) => {
|
|
// Apply API mocks for both Angular and React
|
|
await mockAllAPIs(page);
|
|
await use(page);
|
|
},
|
|
});
|
|
|
|
export { expect } from '@playwright/test';
|