The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { expect, it, vi } from "vite-plus/test"; |
| 2 | |
| 3 | import { createLaunchSplashHomeRows, splashCanHide } from "./home-launch-splash"; |
| 4 | |
| 5 | const launched = { |
| 6 | preferencesReady: true, |
| 7 | shellCachesRead: true, |
| 8 | homeRowsPending: false, |
| 9 | waitEnded: false, |
| 10 | }; |
| 11 | |
| 12 | it.each([ |
| 13 | { |
| 14 | name: "hides when the cached shells are read and no rows wait for layout", |
| 15 | input: launched, |
| 16 | hides: true, |
| 17 | }, |
| 18 | { |
| 19 | name: "waits while Home still lays out the cached rows", |
| 20 | input: { ...launched, homeRowsPending: true }, |
| 21 | hides: false, |
| 22 | }, |
| 23 | { |
| 24 | name: "waits for the cached shells when Home has no rows yet", |
| 25 | input: { ...launched, shellCachesRead: false }, |
| 26 | hides: false, |
| 27 | }, |
| 28 | { |
| 29 | name: "stops waiting for rows at the limit", |
| 30 | input: { ...launched, homeRowsPending: true, waitEnded: true }, |
| 31 | hides: true, |
| 32 | }, |
| 33 | { |
| 34 | name: "stops waiting for a cache read that fails at the limit", |
| 35 | input: { ...launched, shellCachesRead: false, homeRowsPending: true, waitEnded: true }, |
| 36 | hides: true, |
| 37 | }, |
| 38 | { |
| 39 | name: "waits for preferences even after the limit", |
| 40 | input: { ...launched, preferencesReady: false, waitEnded: true }, |
| 41 | hides: false, |
| 42 | }, |
| 43 | ])("the launch splash $name", ({ input, hides }) => { |
| 44 | expect(splashCanHide(input)).toBe(hides); |
| 45 | }); |
| 46 | |
| 47 | it("the launch splash is held only while a Home list has rows to lay out", () => { |
| 48 | const rows = createLaunchSplashHomeRows(); |
| 49 | const onChange = vi.fn(); |
| 50 | rows.subscribe(onChange); |
| 51 | |
| 52 | const release = rows.hold(); |
| 53 | expect(rows.pending()).toBe(true); |
| 54 | // The server answered with no rows, or the list unmounted, before its first layout. |
| 55 | release(); |
| 56 | expect(rows.pending(), "a list that lost its rows releases the splash").toBe(false); |
| 57 | expect(onChange).toHaveBeenCalledTimes(2); |
| 58 | |
| 59 | const releaseLater = rows.hold(); |
| 60 | const releaseOther = rows.hold(); |
| 61 | releaseLater(); |
| 62 | release(); |
| 63 | expect(rows.pending(), "another list still has rows to lay out").toBe(true); |
| 64 | |
| 65 | rows.settle(); |
| 66 | expect(rows.pending()).toBe(false); |
| 67 | releaseOther(); |
| 68 | rows.hold(); |
| 69 | expect(rows.pending(), "a list that mounts after the launch holds nothing").toBe(false); |
| 70 | }); |