Improve startup provider snapshots and dev harness
This commit is contained in:
@@ -6,26 +6,32 @@ vi.hoisted(() => {
|
||||
|
||||
import {
|
||||
resolveWorkspaceHeader,
|
||||
resolveWorkspaceHeaderRenderState,
|
||||
shouldRenderMissingWorkspaceDescriptor,
|
||||
} from "./workspace-header-source";
|
||||
import { createSidebarWorkspaceEntry } from "@/hooks/use-sidebar-workspaces-list";
|
||||
import type { WorkspaceDescriptor } from "@/stores/session-store";
|
||||
|
||||
function createWorkspaceDescriptor(input: Partial<WorkspaceDescriptor> = {}): WorkspaceDescriptor {
|
||||
return {
|
||||
id: "/repo/main",
|
||||
projectId: "remote:github.com/getpaseo/paseo",
|
||||
projectDisplayName: "getpaseo/paseo",
|
||||
projectRootPath: "/repo/main",
|
||||
workspaceDirectory: "/repo/main",
|
||||
projectKind: "git",
|
||||
workspaceKind: "local_checkout",
|
||||
name: "feat/workspace-sot",
|
||||
status: "running",
|
||||
diffStat: null,
|
||||
scripts: [],
|
||||
...input,
|
||||
};
|
||||
}
|
||||
|
||||
describe("workspace source of truth consumption", () => {
|
||||
it("uses the same descriptor name in header and sidebar row", () => {
|
||||
const workspace: WorkspaceDescriptor = {
|
||||
id: "/repo/main",
|
||||
projectId: "remote:github.com/getpaseo/paseo",
|
||||
projectDisplayName: "getpaseo/paseo",
|
||||
projectRootPath: "/repo/main",
|
||||
workspaceDirectory: "/repo/main",
|
||||
projectKind: "git",
|
||||
workspaceKind: "checkout",
|
||||
name: "feat/workspace-sot",
|
||||
status: "running",
|
||||
diffStat: null,
|
||||
scripts: [],
|
||||
};
|
||||
const workspace = createWorkspaceDescriptor();
|
||||
|
||||
const header = resolveWorkspaceHeader({ workspace });
|
||||
const sidebarWorkspace = createSidebarWorkspaceEntry({
|
||||
@@ -39,6 +45,104 @@ describe("workspace source of truth consumption", () => {
|
||||
expect(sidebarWorkspace.statusBucket).toBe("running");
|
||||
});
|
||||
|
||||
it("keeps the header skeleton while the workspace descriptor is missing", () => {
|
||||
expect(
|
||||
resolveWorkspaceHeaderRenderState({
|
||||
workspace: null,
|
||||
checkoutState: { kind: "pending" },
|
||||
}),
|
||||
).toEqual({ kind: "skeleton" });
|
||||
});
|
||||
|
||||
it("keeps git workspace headers skeletoned until checkout status resolves", () => {
|
||||
expect(
|
||||
resolveWorkspaceHeaderRenderState({
|
||||
workspace: createWorkspaceDescriptor({ projectKind: "git" }),
|
||||
checkoutState: { kind: "pending" },
|
||||
}),
|
||||
).toEqual({ kind: "skeleton" });
|
||||
});
|
||||
|
||||
it("renders known non-git workspace identity while checkout status is pending", () => {
|
||||
expect(
|
||||
resolveWorkspaceHeaderRenderState({
|
||||
workspace: createWorkspaceDescriptor({
|
||||
projectKind: "non_git",
|
||||
workspaceKind: "directory",
|
||||
name: "notes",
|
||||
projectDisplayName: "Local folders",
|
||||
}),
|
||||
checkoutState: { kind: "pending" },
|
||||
}),
|
||||
).toEqual({
|
||||
kind: "ready",
|
||||
title: "notes",
|
||||
subtitle: "Local folders",
|
||||
shouldShowSubtitle: true,
|
||||
isGitCheckout: false,
|
||||
currentBranchName: null,
|
||||
});
|
||||
});
|
||||
|
||||
it("renders git checkout headers with branch affordance after checkout status resolves", () => {
|
||||
expect(
|
||||
resolveWorkspaceHeaderRenderState({
|
||||
workspace: createWorkspaceDescriptor(),
|
||||
checkoutState: {
|
||||
kind: "ready",
|
||||
checkout: { isGit: true, currentBranch: "feat/workspace-sot" },
|
||||
},
|
||||
}),
|
||||
).toEqual({
|
||||
kind: "ready",
|
||||
title: "feat/workspace-sot",
|
||||
subtitle: "getpaseo/paseo",
|
||||
shouldShowSubtitle: true,
|
||||
isGitCheckout: true,
|
||||
currentBranchName: "feat/workspace-sot",
|
||||
});
|
||||
});
|
||||
|
||||
it("renders non-git checkout headers without branch affordance after checkout status resolves", () => {
|
||||
expect(
|
||||
resolveWorkspaceHeaderRenderState({
|
||||
workspace: createWorkspaceDescriptor({
|
||||
projectKind: "non_git",
|
||||
workspaceKind: "directory",
|
||||
name: "notes",
|
||||
projectDisplayName: "notes",
|
||||
}),
|
||||
checkoutState: {
|
||||
kind: "ready",
|
||||
checkout: { isGit: false, currentBranch: null },
|
||||
},
|
||||
}),
|
||||
).toEqual({
|
||||
kind: "ready",
|
||||
title: "notes",
|
||||
subtitle: "notes",
|
||||
shouldShowSubtitle: false,
|
||||
isGitCheckout: false,
|
||||
currentBranchName: null,
|
||||
});
|
||||
});
|
||||
|
||||
it("renders descriptor identity after checkout status errors", () => {
|
||||
expect(
|
||||
resolveWorkspaceHeaderRenderState({
|
||||
workspace: createWorkspaceDescriptor(),
|
||||
checkoutState: { kind: "error" },
|
||||
}),
|
||||
).toEqual({
|
||||
kind: "ready",
|
||||
title: "feat/workspace-sot",
|
||||
subtitle: "getpaseo/paseo",
|
||||
shouldShowSubtitle: true,
|
||||
isGitCheckout: false,
|
||||
currentBranchName: null,
|
||||
});
|
||||
});
|
||||
|
||||
it("renders explicit missing state only after workspace hydration", () => {
|
||||
expect(
|
||||
shouldRenderMissingWorkspaceDescriptor({
|
||||
|
||||
Reference in New Issue
Block a user