Hide setup action when no setup ran
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { beforeEach, describe, expect, it } from "vitest";
|
||||
import { useWorkspaceSetupStore } from "./workspace-setup-store";
|
||||
import { shouldShowWorkspaceSetup, useWorkspaceSetupStore } from "./workspace-setup-store";
|
||||
|
||||
describe("workspace-setup-store", () => {
|
||||
beforeEach(() => {
|
||||
@@ -38,4 +38,65 @@ describe("workspace-setup-store", () => {
|
||||
|
||||
expect(useWorkspaceSetupStore.getState().pendingWorkspaceSetup).toBeNull();
|
||||
});
|
||||
|
||||
it("hides empty successful setup snapshots", () => {
|
||||
expect(
|
||||
shouldShowWorkspaceSetup({
|
||||
workspaceId: "workspace-1",
|
||||
status: "completed",
|
||||
detail: {
|
||||
type: "worktree_setup",
|
||||
worktreePath: "/Users/test/project",
|
||||
branchName: "main",
|
||||
log: "",
|
||||
commands: [],
|
||||
},
|
||||
error: null,
|
||||
updatedAt: Date.now(),
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("shows setup snapshots with commands or errors", () => {
|
||||
expect(
|
||||
shouldShowWorkspaceSetup({
|
||||
workspaceId: "workspace-1",
|
||||
status: "completed",
|
||||
detail: {
|
||||
type: "worktree_setup",
|
||||
worktreePath: "/Users/test/project",
|
||||
branchName: "main",
|
||||
log: "done\n",
|
||||
commands: [
|
||||
{
|
||||
index: 1,
|
||||
command: "npm install",
|
||||
cwd: "/Users/test/project",
|
||||
log: "done\n",
|
||||
status: "completed",
|
||||
exitCode: 0,
|
||||
},
|
||||
],
|
||||
},
|
||||
error: null,
|
||||
updatedAt: Date.now(),
|
||||
}),
|
||||
).toBe(true);
|
||||
|
||||
expect(
|
||||
shouldShowWorkspaceSetup({
|
||||
workspaceId: "workspace-1",
|
||||
status: "failed",
|
||||
detail: {
|
||||
type: "worktree_setup",
|
||||
worktreePath: "/Users/test/project",
|
||||
branchName: "main",
|
||||
log: "",
|
||||
commands: [],
|
||||
},
|
||||
error: "Failed to parse paseo.json",
|
||||
updatedAt: Date.now(),
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -23,6 +23,13 @@ export interface WorkspaceSetupSnapshot extends WorkspaceSetupProgressPayload {
|
||||
updatedAt: number;
|
||||
}
|
||||
|
||||
export function shouldShowWorkspaceSetup(snapshot: WorkspaceSetupSnapshot | null): boolean {
|
||||
if (!snapshot) {
|
||||
return false;
|
||||
}
|
||||
return snapshot.error !== null || snapshot.detail.commands.length > 0;
|
||||
}
|
||||
|
||||
interface WorkspaceSetupStoreState {
|
||||
pendingWorkspaceSetup: PendingWorkspaceSetup | null;
|
||||
snapshots: Record<string, WorkspaceSetupSnapshot>;
|
||||
|
||||
Reference in New Issue
Block a user