test: Add 8 people voice tests

This commit is contained in:
2026-04-18 14:19:59 +02:00
parent bd21568726
commit 167c45ba8d
17 changed files with 2044 additions and 232 deletions

View File

@@ -3,6 +3,15 @@ import { type BrowserContext, type Page } from '@playwright/test';
const SERVER_ENDPOINTS_STORAGE_KEY = 'metoyou_server_endpoints';
const REMOVED_DEFAULT_KEYS_STORAGE_KEY = 'metoyou_removed_default_server_keys';
export interface SeededEndpointInput {
id: string;
name: string;
url: string;
isActive?: boolean;
isDefault?: boolean;
status?: string;
}
interface SeededEndpointStorageState {
key: string;
removedKey: string;
@@ -17,21 +26,32 @@ interface SeededEndpointStorageState {
}
function buildSeededEndpointStorageState(
port: number = Number(process.env.TEST_SERVER_PORT) || 3099
endpointsOrPort: ReadonlyArray<SeededEndpointInput> | number = Number(process.env.TEST_SERVER_PORT) || 3099
): SeededEndpointStorageState {
const endpoint = {
id: 'e2e-test-server',
name: 'E2E Test Server',
url: `http://localhost:${port}`,
isActive: true,
isDefault: false,
status: 'unknown'
};
const endpoints = Array.isArray(endpointsOrPort)
? endpointsOrPort.map((endpoint) => ({
id: endpoint.id,
name: endpoint.name,
url: endpoint.url,
isActive: endpoint.isActive ?? true,
isDefault: endpoint.isDefault ?? false,
status: endpoint.status ?? 'unknown'
}))
: [
{
id: 'e2e-test-server',
name: 'E2E Test Server',
url: `http://localhost:${endpointsOrPort}`,
isActive: true,
isDefault: false,
status: 'unknown'
}
];
return {
key: SERVER_ENDPOINTS_STORAGE_KEY,
removedKey: REMOVED_DEFAULT_KEYS_STORAGE_KEY,
endpoints: [endpoint]
endpoints
};
}
@@ -59,6 +79,15 @@ export async function installTestServerEndpoint(
await context.addInitScript(applySeededEndpointStorageState, storageState);
}
export async function installTestServerEndpoints(
context: BrowserContext,
endpoints: ReadonlyArray<SeededEndpointInput>
): Promise<void> {
const storageState = buildSeededEndpointStorageState(endpoints);
await context.addInitScript(applySeededEndpointStorageState, storageState);
}
/**
* Seed localStorage with a single signal endpoint pointing at the test server.
* Must be called AFTER navigating to the app origin (localStorage is per-origin)
@@ -79,3 +108,12 @@ export async function seedTestServerEndpoint(
await page.evaluate(applySeededEndpointStorageState, storageState);
}
export async function seedTestServerEndpoints(
page: Page,
endpoints: ReadonlyArray<SeededEndpointInput>
): Promise<void> {
const storageState = buildSeededEndpointStorageState(endpoints);
await page.evaluate(applySeededEndpointStorageState, storageState);
}