test(app): build layout stores with options and flush before rehydrating

Six call sites still passed the id factories positionally, which this
branch replaced with an options object, so those stores silently used
default ids. The once-only PR test also rehydrated a second store before
the throttled write landed; flush the source first.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Ivan Malison
2026-10-14 19:52:10 -07:00
co-authored by Claude Opus 5
parent 8c726361d4
commit f6b33151d1
@@ -83,7 +83,7 @@ const workspaceLayoutIds = createDeterministicWorkspaceLayoutIds();
const workspaceLayoutStore = createWorkspaceLayoutStore({ ids: workspaceLayoutIds });
it("observes open chats across unmounted workspaces until their tabs close", () => {
const store = createWorkspaceLayoutStore(workspaceLayoutIds);
const store = createWorkspaceLayoutStore({ ids: workspaceLayoutIds });
store.setState({ layoutByWorkspace: {} });
const received: string[][] = [];
const stop = observeOpenWorkspaceAgentIds("server-1", (ids) => received.push(ids), store);
@@ -116,7 +116,7 @@ it("observes open chats across unmounted workspaces until their tabs close", ()
});
it("feeds restored layout to timeline sync as a release signal, not a subscription source", async () => {
const store = createWorkspaceLayoutStore(workspaceLayoutIds);
const store = createWorkspaceLayoutStore({ ids: workspaceLayoutIds });
store.setState({ layoutByWorkspace: {} });
// Launch: layout rehydrates tabs the user opened in earlier sessions.
const restored = store.getState().openTab({
@@ -1277,7 +1277,7 @@ describe("workspace-layout-store actions", () => {
},
}),
);
const restored = createWorkspaceLayoutStore(createDeterministicWorkspaceLayoutIds());
const restored = createWorkspaceLayoutStore({ ids: createDeterministicWorkspaceLayoutIds() });
await restored.persist.rehydrate();
const state = restored.getState();
const layout = state.layoutByWorkspace[workspaceKey];
@@ -1324,7 +1324,7 @@ describe("workspace-layout-store actions", () => {
},
}),
);
const restored = createWorkspaceLayoutStore(createDeterministicWorkspaceLayoutIds());
const restored = createWorkspaceLayoutStore({ ids: createDeterministicWorkspaceLayoutIds() });
await restored.persist.rehydrate();
const layout = restored.getState().layoutByWorkspace[workspaceKey];
expect(collectAllPanes(layout.root).map((pane) => pane.id)).toEqual(["pane_saved_ordinary"]);
@@ -4530,13 +4530,14 @@ describe("workspace-layout-store actions", () => {
it("persists the once-only PR add after closing, and clears it when purging the workspace", async () => {
await AsyncStorage.removeItem("workspace-layout-state");
const source = createWorkspaceLayoutStore(workspaceLayoutIds);
const source = createWorkspaceLayoutStore({ ids: workspaceLayoutIds });
await source.persist.rehydrate();
const workspaceKey = "server-1:pr-once";
const placement = () => ({ placement: { mode: "prefer" as const, paneId: "explorer" } });
source.getState().autoOpenPullRequestTab(workspaceKey, placement);
source.getState().closeTab(workspaceKey, "pull_request");
const restored = createWorkspaceLayoutStore(workspaceLayoutIds);
await source.flushPersistence();
const restored = createWorkspaceLayoutStore({ ids: workspaceLayoutIds });
await restored.persist.rehydrate();
expect(restored.getState().pullRequestTabAutoOpenedByWorkspace[workspaceKey]).toBe(true);
expect(restored.getState().autoOpenPullRequestTab(workspaceKey, placement)).toBeNull();