morse-code / tests /e2e /smoke.spec.js
RemiFabre
feat: initial Reachy Mini Morse Code app
843a4b2
Raw
History Blame Contribute Delete
1.6 kB
import { test, expect } from "@playwright/test";
// Fatal = the module graph failed to load (bad import URL, syntax error,
// missing global). We tolerate runtime warnings the host shell may emit
// before sign-in, but not these.
const FATAL = /(SyntaxError|ReferenceError|is not defined|Failed to fetch dynamically imported module|Unexpected token)/;
test("standalone page loads the module graph (host shell mounts, no fatal errors)", async ({ page }) => {
const fatals = [];
page.on("pageerror", (e) => { if (FATAL.test(String(e))) fatals.push(String(e)); });
page.on("console", (m) => { if (m.type() === "error" && FATAL.test(m.text())) fatals.push(m.text()); });
await page.goto("/");
// mountHost() renders the host shell (sign-in / picker) into #root.
// We only assert the module graph executed far enough to populate it.
await expect.poll(
async () => page.locator("#root").evaluate((n) => n.childElementCount),
{ timeout: 30_000 },
).toBeGreaterThan(0);
expect(fatals, `fatal load errors:\n${fatals.join("\n")}`).toEqual([]);
});
test("embedded boot path imports cleanly (no module-load error)", async ({ page }) => {
const fatals = [];
page.on("pageerror", (e) => { if (FATAL.test(String(e))) fatals.push(String(e)); });
// ?embedded=1 runs bootEmbed(): connectToHost() will not complete without
// a host, but importing it + our whole module graph must not throw.
await page.goto("/?embedded=1");
await page.waitForTimeout(4000);
expect(fatals, `fatal load errors:\n${fatals.join("\n")}`).toEqual([]);
});