mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-01 06:02:56 +00:00
* fix(app): preserve project selection across hosts Rendered project identity and persisted equivalence were conflated after duplicate-project handling. Keep them separate so host changes resolve selectable equivalents deterministically without resetting legacy sidebar identity. * fix(app): restore selected clone after host round trip Keep manual origin and current destination placements separately so switching back restores the chosen checkout while archive gaps preserve the active host selection. * fix(app): key status icons by project view * fix(app): preserve origin during archive gaps
86 lines
2.5 KiB
TypeScript
86 lines
2.5 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
getProjectRemoveReadiness,
|
|
removeProjectFromHosts,
|
|
type ProjectRemoveProject,
|
|
} from "./project-remove";
|
|
|
|
const project: ProjectRemoveProject = {
|
|
hosts: [
|
|
{ serverId: "host-a", projectId: "prj_host_a" },
|
|
{ serverId: "host-b", projectId: "prj_host_b" },
|
|
],
|
|
};
|
|
|
|
function createProjectRemoveClient() {
|
|
const removedProjectKeys: string[] = [];
|
|
return {
|
|
removedProjectKeys,
|
|
client: {
|
|
async removeProject(projectKey: string): Promise<{ removedWorkspaceIds: string[] }> {
|
|
removedProjectKeys.push(projectKey);
|
|
return { removedWorkspaceIds: [] };
|
|
},
|
|
},
|
|
};
|
|
}
|
|
|
|
describe("project remove policy", () => {
|
|
it("requires every host to support project removal", () => {
|
|
const readiness = getProjectRemoveReadiness({
|
|
project,
|
|
supportsProjectRemove: (serverId) => serverId === "host-a",
|
|
});
|
|
|
|
expect(readiness).toEqual({
|
|
kind: "needs_host_update",
|
|
serverIds: ["host-b"],
|
|
});
|
|
});
|
|
|
|
it("removes the project from every participating host", async () => {
|
|
const hostA = createProjectRemoveClient();
|
|
const hostB = createProjectRemoveClient();
|
|
const readiness = getProjectRemoveReadiness({
|
|
project,
|
|
supportsProjectRemove: () => true,
|
|
});
|
|
|
|
expect(readiness).toEqual({
|
|
kind: "ready",
|
|
targets: [
|
|
{ serverId: "host-a", projectId: "prj_host_a" },
|
|
{ serverId: "host-b", projectId: "prj_host_b" },
|
|
],
|
|
});
|
|
|
|
const outcome = await removeProjectFromHosts({
|
|
targets: readiness.kind === "ready" ? readiness.targets : [],
|
|
getClient: (serverId) => {
|
|
if (serverId === "host-a") return hostA.client;
|
|
if (serverId === "host-b") return hostB.client;
|
|
return null;
|
|
},
|
|
});
|
|
|
|
expect(outcome).toEqual({ kind: "removed", serverIds: ["host-a", "host-b"] });
|
|
expect(hostA.removedProjectKeys).toEqual(["prj_host_a"]);
|
|
expect(hostB.removedProjectKeys).toEqual(["prj_host_b"]);
|
|
});
|
|
|
|
it("reports disconnected hosts before sending any remove request", async () => {
|
|
const hostA = createProjectRemoveClient();
|
|
|
|
const outcome = await removeProjectFromHosts({
|
|
targets: [
|
|
{ serverId: "host-a", projectId: "prj_host_a" },
|
|
{ serverId: "host-b", projectId: "prj_host_b" },
|
|
],
|
|
getClient: (serverId) => (serverId === "host-a" ? hostA.client : null),
|
|
});
|
|
|
|
expect(outcome).toEqual({ kind: "host_disconnected", serverIds: ["host-b"] });
|
|
expect(hostA.removedProjectKeys).toEqual([]);
|
|
});
|
|
});
|