27 lines
888 B
TypeScript
27 lines
888 B
TypeScript
|
|
import type { Page } from '@playwright/test';
|
||
|
|
|
||
|
|
// Profil-IDs auf kochwas-dev: 1 = Hendrik, 2 = Verena, 3 = Leana.
|
||
|
|
// Die Tests hardcoden Hendrik als Standard, weil die Dev-DB diese
|
||
|
|
// Profile stabil enthaelt.
|
||
|
|
export const HENDRIK_ID = 1;
|
||
|
|
export const VERENA_ID = 2;
|
||
|
|
export const LEANA_ID = 3;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Setzt das aktive Profil in localStorage, BEVOR die Seite geladen wird.
|
||
|
|
* addInitScript laeuft vor jedem Skript der Seite — damit ist das Profil
|
||
|
|
* schon da, wenn profileStore.load() das erste Mal liest.
|
||
|
|
*/
|
||
|
|
export async function setActiveProfile(page: Page, id: number): Promise<void> {
|
||
|
|
await page.addInitScript(
|
||
|
|
(pid) => window.localStorage.setItem('kochwas.activeProfileId', String(pid)),
|
||
|
|
id
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function clearActiveProfile(page: Page): Promise<void> {
|
||
|
|
await page.addInitScript(() =>
|
||
|
|
window.localStorage.removeItem('kochwas.activeProfileId')
|
||
|
|
);
|
||
|
|
}
|