Files
geograsim/.dontDeploy/playwright/tests/stufe1-smoke/sim-platform-context.spec.js
T
Adminator 1e51ef7def Nachtrag: alle bisher untracked Ordner + hängende Änderungen mit-committen
- Konzept/, didaktik_geografie/, didaktik_simulation/, v2-modules/, v2-platform/
- 12 code-workspace-Files
- STATUS-*.md
- viele M/D/R-Änderungen an bereits getrackten Files
- .gitignore verstärkt: **/.humaninput/, **/secret_keys.txt

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-07-08 02:27:02 +02:00

56 lines
2.3 KiB
JavaScript

// @ts-check
const { test, expect } = require('@playwright/test');
const paths = require('../../fixtures/known-paths.json');
/**
* Stufe 1 · Sim-Plattform-Kontext
*
* Pro aktive Sim:
* - window.__GGS__ ist gesetzt mit den richtigen Feldern
* (sessionId / simId / baseUrl / basePath / apiUrl) — das ist der
* Regressionstest gegen den Weltküche-Bug vom 2026-06-10 (Wrapper
* injizierte WK_* statt __GGS__).
* - live-client.js wird geladen (per Script-Tag oder __GGS_LIVE_INITIALIZED__).
* - window.GGS_LIVE_STATE existiert als Funktion (nicht hart erforderlich
* bei jeder Sim, aber wir reporten welche es nicht haben).
*/
for (const sim of paths.sims_wrapper.active) {
test(`Sim ${sim} · __GGS__ + live-client + GGS_LIVE_STATE`, async ({ page }) => {
await page.goto(`/${sim}`);
// 1) __GGS__ muss existieren und simId enthalten
const ctx = await page.evaluate(() => {
// @ts-ignore
return window['__GGS__'] || null;
});
expect(ctx, `__GGS__ fehlt in ${sim}`).not.toBeNull();
expect(ctx.simId, `__GGS__.simId fehlt in ${sim}`).toBeTruthy();
// baseUrl muss zumindest als String existieren (kann leer sein auf Prod)
expect(typeof ctx.baseUrl, `__GGS__.baseUrl fehlt in ${sim}`).toBe('string');
// 2) live-client-Script muss geladen sein (entweder als <script> oder
// durch das Initialized-Flag)
const liveLoaded = await page.evaluate(() => {
const scripts = Array.from(document.querySelectorAll('script[src]')).map(s => s['src']);
const hasScript = scripts.some(s => s.includes('live-client.js'));
// @ts-ignore
const hasFlag = !!window['__GGS_LIVE_INITIALIZED__'];
return { hasScript, hasFlag };
});
expect(liveLoaded.hasScript || liveLoaded.hasFlag, `live-client.js fehlt in ${sim}`).toBe(true);
// 3) GGS_LIVE_STATE als Funktion exponiert — wir warten kurz, weil
// manche Sims den State erst nach DOMContentLoaded definieren.
await page.waitForTimeout(800);
const hasState = await page.evaluate(() => {
// @ts-ignore
return typeof window['GGS_LIVE_STATE'] === 'function';
});
// Nur Soft-Warnung, da nicht jede Sim heute schon einen State hat
if (!hasState) {
console.warn(`[soft] ${sim}: GGS_LIVE_STATE noch nicht exponiert`);
}
});
}