|
1 | | -import { |
2 | | - afterAll, |
3 | | - afterEach, |
4 | | - beforeAll, |
5 | | - beforeEach, |
6 | | - expect, |
7 | | - test, |
8 | | -} from "bun:test"; |
9 | | -import { GlobalRegistrator } from "@happy-dom/global-registrator"; |
10 | | -import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; |
11 | | -import { |
12 | | - createMemoryHistory, |
13 | | - createRootRoute, |
14 | | - createRouter, |
15 | | - RouterProvider, |
16 | | -} from "@tanstack/react-router"; |
17 | | -import { cleanup, fireEvent, render } from "@testing-library/react"; |
18 | | -import { Route as OnboardingRoute } from "@/routes/_authed/onboarding"; |
19 | | -import { settleReactWork } from "./settle-react-work"; |
| 1 | +import { expect, test } from "bun:test"; |
| 2 | +import { readFileSync } from "node:fs"; |
20 | 3 |
|
21 | 4 | /** |
22 | | - * Onboarding's second slide promised "Each Bot has its own computer". Bots now share one computer |
| 5 | + * Onboarding's introduction promised "Each Bot has its own computer". Bots now share one computer |
23 | 6 | * per person, each with its own browser and folder there, and only an Isolated Bot gets a computer |
24 | | - * of its own, so the slide says what every Bot does get. |
| 7 | + * of its own, so the scene says what every Bot does get. |
25 | 8 | * |
26 | | - * Mounts the real onboarding route as a memory router's root, the way `agent-roster-error.test.tsx` |
27 | | - * mounts home, and walks to the slide with the person's own click. |
| 9 | + * Read from the route's source rather than rendered: the introduction is an `AnimatePresence` loop, |
| 10 | + * and under happy-dom an exiting scene never reports finished (see `collapse.tsx`), so a render |
| 11 | + * never reaches the second scene. What regressed was the words, and this pins the words. |
28 | 12 | */ |
| 13 | +const onboarding = readFileSync( |
| 14 | + new URL("../src/routes/_authed/onboarding.tsx", import.meta.url), |
| 15 | + "utf8", |
| 16 | +); |
29 | 17 |
|
30 | | -beforeAll(() => GlobalRegistrator.register({ url: "http://localhost/" })); |
31 | | -afterEach(cleanup); |
32 | | -afterAll(async () => { |
33 | | - await settleReactWork(); |
34 | | - GlobalRegistrator.unregister(); |
35 | | -}); |
36 | | - |
37 | | -const originalFetch = globalThis.fetch; |
38 | | -beforeEach(() => { |
39 | | - globalThis.fetch = (async () => |
40 | | - new Response(null, { status: 500 })) as unknown as typeof fetch; |
41 | | -}); |
42 | | -afterEach(() => { |
43 | | - globalThis.fetch = originalFetch; |
44 | | -}); |
45 | | - |
46 | | -test("the computer slide says what every Bot gets, not a computer of its own", async () => { |
47 | | - const rootRoute = createRootRoute({ |
48 | | - component: OnboardingRoute.options.component, |
49 | | - }); |
50 | | - const router = createRouter({ |
51 | | - routeTree: rootRoute, |
52 | | - history: createMemoryHistory({ initialEntries: ["/"] }), |
53 | | - }); |
54 | | - const view = render( |
55 | | - <QueryClientProvider |
56 | | - client={ |
57 | | - new QueryClient({ defaultOptions: { queries: { retry: false } } }) |
58 | | - } |
59 | | - > |
60 | | - <RouterProvider router={router as never} /> |
61 | | - </QueryClientProvider>, |
62 | | - ); |
63 | | - |
64 | | - fireEvent.click( |
65 | | - await view.findByRole("button", { name: "Continue" }, { timeout: 5000 }), |
66 | | - ); |
67 | | - |
68 | | - const heading = await view.findByRole( |
69 | | - "heading", |
70 | | - { level: 1, name: "Each Bot has its own browser and files" }, |
71 | | - { timeout: 5000 }, |
72 | | - ); |
73 | | - expect(heading).toBeTruthy(); |
74 | | - expect(view.queryByText(/its own computer/i)).toBeNull(); |
| 18 | +test("onboarding says what every Bot gets, not a computer of its own", () => { |
| 19 | + expect(onboarding).toContain("Each Bot has its own browser and files"); |
| 20 | + expect(onboarding).not.toMatch(/Each Bot has its own computer/); |
75 | 21 | }); |
0 commit comments