summaryrefslogtreecommitdiffhomepage
path: root/src/app/store.test.ts
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-10-21 01:04:35 +0900
committerAdam Malczewski <[email protected]>2026-10-21 01:04:35 +0900
commitc61b4d66921e7fe5d7d1e2a988e96785f6aedd9f (patch)
tree8130a35661a66d28197f5f52fff036a6be523656 /src/app/store.test.ts
parentb3a539260aa15efd197ce06c1073f0f25fee0c15 (diff)
downloaddispatch-web-c61b4d66921e7fe5d7d1e2a988e96785f6aedd9f.tar.gz
dispatch-web-c61b4d66921e7fe5d7d1e2a988e96785f6aedd9f.zip
fix(review-1.3): render home tiles before layout revalidation
Diffstat (limited to 'src/app/store.test.ts')
-rw-r--r--src/app/store.test.ts23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/app/store.test.ts b/src/app/store.test.ts
index bfd4039..4c530f1 100644
--- a/src/app/store.test.ts
+++ b/src/app/store.test.ts
@@ -234,6 +234,29 @@ describe("createAppStore", () => {
store.dispose();
});
+ it("probes only the portrait tile layout at boot and injects its cached document", () => {
+ const width = vi.spyOn(window, "innerWidth", "get").mockReturnValue(390);
+ const height = vi.spyOn(window, "innerHeight", "get").mockReturnValue(844);
+ const storage = createFakeStorage();
+ const cached = { version: 2, tiles: [{ id: "a", order: 0, colSpan: 2, rowSpan: 2 }] };
+ storage.setItem("dispatch.tile-layout.tall", JSON.stringify(cached));
+ const fetchImpl = vi.fn(fakeFetchImpl());
+ const store = createAppStore({ socketFactory: fakeSocket, fetchImpl, localStorage: storage });
+ try {
+ expect(store.tileLayout.mode).toBe("tall");
+ expect(store.tileLayout.entries).toEqual(cached.tiles);
+ expect(
+ fetchImpl.mock.calls
+ .map(([url]) => String(url))
+ .filter((url) => url.includes("/home/tile-layout/")),
+ ).toEqual([expect.stringMatching(/\/home\/tile-layout\/tall$/)]);
+ } finally {
+ store.dispose();
+ width.mockRestore();
+ height.mockRestore();
+ }
+ });
+
it("updates catalog when catalog message arrives", () => {
const ws = fakeSocket();
const store = createAppStore({