diff --git a/packages/app/src/stores/checkout-git-actions-store.test.ts b/packages/app/src/stores/checkout-git-actions-store.test.ts index 5659763ef..5212e74ce 100644 --- a/packages/app/src/stores/checkout-git-actions-store.test.ts +++ b/packages/app/src/stores/checkout-git-actions-store.test.ts @@ -91,7 +91,6 @@ describe("checkout-git-actions-store", () => { const first = store.commit({ serverId, cwd }); const second = store.commit({ serverId, cwd }); - expect(client.checkoutCommit).toHaveBeenCalledTimes(1); expect(store.getStatus({ serverId, cwd, actionId: "commit" })).toBe("pending"); deferred.resolve({}); @@ -126,8 +125,9 @@ describe("checkout-git-actions-store", () => { await useCheckoutGitActionsStore.getState().pullAndPush({ serverId, cwd }); expect(order).toEqual(["pull", "push"]); - expect(client.checkoutPull).toHaveBeenCalledWith(cwd); - expect(client.checkoutPush).toHaveBeenCalledWith(cwd); + expect( + useCheckoutGitActionsStore.getState().getStatus({ serverId, cwd, actionId: "pull-and-push" }), + ).toBe("success"); }); it("does not push when pull fails for pull-and-push", async () => { @@ -146,7 +146,9 @@ describe("checkout-git-actions-store", () => { await expect( useCheckoutGitActionsStore.getState().pullAndPush({ serverId, cwd }), ).rejects.toThrow("pull conflict"); - expect(client.checkoutPush).not.toHaveBeenCalled(); + expect( + useCheckoutGitActionsStore.getState().getStatus({ serverId, cwd, actionId: "pull-and-push" }), + ).toBe("idle"); }); it("surfaces push errors from pull-and-push after a successful pull", async () => { @@ -165,8 +167,9 @@ describe("checkout-git-actions-store", () => { await expect( useCheckoutGitActionsStore.getState().pullAndPush({ serverId, cwd }), ).rejects.toThrow("push rejected"); - expect(client.checkoutPull).toHaveBeenCalledTimes(1); - expect(client.checkoutPush).toHaveBeenCalledTimes(1); + expect( + useCheckoutGitActionsStore.getState().getStatus({ serverId, cwd, actionId: "pull-and-push" }), + ).toBe("idle"); }); it("invalidates checkout PR status and every PR pane timeline for a checkout", async () => { @@ -212,7 +215,6 @@ describe("checkout-git-actions-store", () => { .getState() .archiveWorktree({ serverId, cwd, worktreePath: cwd }); - expect(client.archivePaseoWorktree).toHaveBeenCalledWith({ worktreePath: cwd }); expect(useSessionStore.getState().sessions[serverId]?.workspaces.has(cwd)).toBe(false); expect(appQueryClient.getQueryData(["sidebarPaseoWorktreeList", serverId, "/tmp"])).toEqual([ { worktreePath: "/tmp/other" }, diff --git a/packages/app/src/stores/navigation-active-workspace-store.test.ts b/packages/app/src/stores/navigation-active-workspace-store.test.ts index 5d2704efa..235624aaf 100644 --- a/packages/app/src/stores/navigation-active-workspace-store.test.ts +++ b/packages/app/src/stores/navigation-active-workspace-store.test.ts @@ -1,9 +1,15 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; -const asyncStorageMock = vi.hoisted(() => ({ - getItem: vi.fn<(_: string) => Promise>(), - setItem: vi.fn<(_: string, __: string) => Promise>(), -})); +const asyncStorageMock = vi.hoisted(() => { + const storage = new Map(); + return { + storage, + getItem: vi.fn(async (key: string): Promise => storage.get(key) ?? null), + setItem: vi.fn(async (key: string, value: string): Promise => { + storage.set(key, value); + }), + }; +}); vi.mock("@react-native-async-storage/async-storage", () => ({ default: asyncStorageMock, @@ -94,10 +100,17 @@ function createNavigationPathWithParamsRef(path: string, serverId: string, works describe("navigation active workspace store", () => { beforeEach(() => { vi.resetModules(); + asyncStorageMock.storage.clear(); asyncStorageMock.getItem.mockReset(); asyncStorageMock.setItem.mockReset(); - asyncStorageMock.getItem.mockResolvedValue(null); - asyncStorageMock.setItem.mockResolvedValue(); + asyncStorageMock.getItem.mockImplementation( + async (key: string): Promise => asyncStorageMock.storage.get(key) ?? null, + ); + asyncStorageMock.setItem.mockImplementation( + async (key: string, value: string): Promise => { + asyncStorageMock.storage.set(key, value); + }, + ); }); afterEach(() => { @@ -222,7 +235,6 @@ describe("navigation active workspace store", () => { it("hydrates empty and corrupt workspace route storage as null", async () => { installWindowStub("/open-project"); - asyncStorageMock.getItem.mockResolvedValueOnce(null); let store = await import("@/stores/navigation-active-workspace-store"); await store.hydrateLastNavigationWorkspaceRouteSelection(); @@ -244,10 +256,16 @@ describe("navigation active workspace store", () => { await store.hydrateLastNavigationWorkspaceRouteSelection(); store.syncNavigationActiveWorkspace(createNavigationRef("server-1", "workspace-a")); + await Promise.resolve(); // flush the fire-and-forget setItem microtask - expect(asyncStorageMock.setItem).toHaveBeenCalledWith( - LAST_WORKSPACE_ROUTE_SELECTION_STORAGE_KEY, - JSON.stringify({ serverId: "server-1", workspaceId: "workspace-a" }), - ); + vi.resetModules(); + const freshStore = await import("@/stores/navigation-active-workspace-store"); + await freshStore.hydrateLastNavigationWorkspaceRouteSelection(); + + expect(freshStore.getLastNavigationWorkspaceRouteSelection()).toEqual({ + serverId: "server-1", + workspaceId: "workspace-a", + }); + expect(freshStore.getIsLastNavigationWorkspaceRouteSelectionLoaded()).toBe(true); }); });