diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 434e9d9fbb..6caa441dc5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -705,6 +705,7 @@ jobs: app/tests/artifacts-kit.test.ts app/tests/artifacts-screens.test.tsx app/tests/board-row-layout.test.tsx + app/tests/boot-screen.test.ts app/tests/bot-file-links-browser.test.tsx app/tests/bot-long-instructions-layout.test.tsx app/tests/bot-owner-lists-layout.test.tsx diff --git a/app/index.html b/app/index.html index 6e707612c7..8dd7b5784b 100644 --- a/app/index.html +++ b/app/index.html @@ -55,9 +55,232 @@ } } catch {} + + +
+
+

Loading…

+
+

OpenBot couldn't load

+

Check your connection.

+ +
+
diff --git a/app/tests/boot-screen.fixture.tsx b/app/tests/boot-screen.fixture.tsx new file mode 100644 index 0000000000..c7c86aace6 --- /dev/null +++ b/app/tests/boot-screen.fixture.tsx @@ -0,0 +1,13 @@ +import { createRoot } from "react-dom/client"; + +/** + * The app as `boot-screen.test.ts` serves it: React drawing into `#root`, as `main.tsx` does, and + * nothing else. What the screen before the app reacts to is the first thing drawn there. + */ +const root = document.getElementById("root"); +if (root) + createRoot(root).render( +
+ OpenBot is up +
, + ); diff --git a/app/tests/boot-screen.test.ts b/app/tests/boot-screen.test.ts new file mode 100644 index 0000000000..05f2017dbc --- /dev/null +++ b/app/tests/boot-screen.test.ts @@ -0,0 +1,444 @@ +import { afterAll, beforeAll, describe, expect } from "bun:test"; +import { existsSync, mkdirSync, readFileSync } from "node:fs"; +import { dirname, join } from "node:path"; +import type { Browser, BrowserType, Page, Route } from "playwright-core"; +import { compile } from "tailwindcss"; +import { type Mode, scheme } from "../../tokens/src/scheme"; +import { test } from "./renderer-crash"; + +/** + * THE SCREEN BEFORE THE APP: NEVER A BLANK WHITE PAGE. + * + * FOUND ON OPENBOT CLOUD, 3 DEC 2026. On a conference's Wi-Fi, OpenBot in a phone's Home Screen app + * stayed plain white for two minutes, with nothing to press. Every request that reached OpenBot was + * answered: the app's code had not arrived, and until it does `index.html` drew nothing at all. Now + * the page draws its ground in the person's theme at once, "Loading…" after a second, and "OpenBot + * couldn't load" with Try again when the app's code or styles fail to download or the app hasn't + * started ten seconds in, as Gmail does. It goes the moment the app draws. + * + * The page is the app's real `index.html`, with its entry script and stylesheet where Vite's build + * puts them, a React app standing in for `main.tsx` (`boot-screen.fixture.tsx`) and the app's real + * stylesheet. The connection is the test's: a file that downloads, one that fails, one that never + * answers. In Chromium and in WebKit, the engine of Safari and of a phone's Home Screen app. + * + * OPENBOT_APP_BROWSER=1 bun test app/tests/boot-screen.test.ts + * + * Chromium by default; OPENBOT_APP_ENGINES=chromium,webkit adds WebKit, as CI runs it. With + * OPENBOT_APP_SHOTS= the screens are saved as boot----.png. + */ +const asked = process.env.OPENBOT_APP_BROWSER === "1"; +const shots = process.env.OPENBOT_APP_SHOTS; +const engines = (process.env.OPENBOT_APP_ENGINES ?? "chromium") + .split(",") + .map((engine) => engine.trim()) + .filter((engine) => engine === "chromium" || engine === "webkit") as ( + | "chromium" + | "webkit" +)[]; + +const APP = join(import.meta.dir, ".."); +const ORIGIN = "https://openbot.test"; +const HTML = readFileSync(join(APP, "index.html"), "utf8"); +const THEMES = ["light", "dark"] as const satisfies readonly Mode[]; +const WIDTHS = { + phone: { width: 390, height: 844 }, + desktop: { width: 1280, height: 800 }, +}; + +const FAILED = "OpenBot couldn't load"; + +/** The boot screen's stylesheet, as written in `index.html`. */ +function bootStyles(): string { + const style = /