test: verify portable workspace registry end to end
This commit is contained in:
@@ -112,6 +112,45 @@ test("session listing permits all scope only to admins", async () => {
|
||||
expect(seen).toEqual([false, true]);
|
||||
});
|
||||
|
||||
test("an administrator session listing retains revisions referenced by resumable manifests", async () => {
|
||||
const retained = vi.fn(async () => {});
|
||||
const retainedRevision = "a".repeat(40);
|
||||
const app = buildApp(loadConfig({ AUTH_MODE: "upstream", THT_HARNESS_DIR: "../harness" }), {
|
||||
thtRunner: {
|
||||
withPrincipal: () => ({ sessionList: async () => [
|
||||
{ id: "open", status: "open", archived: false, workspace_revision: retainedRevision },
|
||||
{ id: "finalized", status: "finalized", archived: false, workspace_revision: "b".repeat(40) },
|
||||
{ id: "archived", status: "closed", archived: true, workspace_revision: "c".repeat(40) },
|
||||
] }),
|
||||
} as any,
|
||||
workspaceRegistry: { reconcileSnapshotRetention: retained } as any,
|
||||
});
|
||||
|
||||
const response = await app.inject({
|
||||
method: "GET", url: "/sessions?scope=all",
|
||||
headers: { ...aliceHeaders, "x-thoth-is-admin": "1" },
|
||||
});
|
||||
|
||||
expect(response.statusCode).toBe(200);
|
||||
expect(retained).toHaveBeenCalledWith([retainedRevision]);
|
||||
});
|
||||
|
||||
test("the single local installation listing reconciles its resumable workspace pins", async () => {
|
||||
const retained = vi.fn(async () => {});
|
||||
const retainedRevision = "d".repeat(40);
|
||||
const app = buildApp(loadConfig({ THT_HARNESS_DIR: "../harness" }), {
|
||||
thtRunner: {
|
||||
sessionList: async () => [{ id: "open", status: "closed", archived: false, workspace_revision: retainedRevision }],
|
||||
} as any,
|
||||
workspaceRegistry: { reconcileSnapshotRetention: retained } as any,
|
||||
});
|
||||
|
||||
const response = await app.inject({ method: "GET", url: "/sessions" });
|
||||
|
||||
expect(response.statusCode).toBe(200);
|
||||
expect(retained).toHaveBeenCalledWith([retainedRevision]);
|
||||
});
|
||||
|
||||
test("A, B, and admin requests preserve owner isolation through session route mutations", async () => {
|
||||
const owners = new Map([["a", "alice"], ["b", "bob"]]);
|
||||
const closed: Array<{ id: string; subject: string }> = [];
|
||||
|
||||
@@ -498,6 +498,30 @@ test("keeps the last valid snapshot when a pulled commit has invalid YAML", asyn
|
||||
});
|
||||
});
|
||||
|
||||
test("retains a historical snapshot while a resumable manifest still references its revision", async () => {
|
||||
const remote = await fixture();
|
||||
const root = join(remote.root, "registry");
|
||||
const registry = new WorkspaceRegistry(config(root, remote.remote));
|
||||
await registry.bootstrap();
|
||||
|
||||
writeFileSync(join(remote.source, "workspaces", "psd-clinical.yaml"), validYaml.replace(
|
||||
"name: Policlinico San Donato", "name: Updated Policlinico San Donato",
|
||||
));
|
||||
await git(remote.source, ["add", "workspaces/psd-clinical.yaml"]);
|
||||
await git(remote.source, ["commit", "-m", "Update workspace"]);
|
||||
await git(remote.source, ["push", "origin", "main"]);
|
||||
const currentCommit = await gitOutput(remote.source, ["rev-parse", "HEAD"]);
|
||||
await registry.pull();
|
||||
|
||||
await registry.reconcileSnapshotRetention([remote.initialCommit]);
|
||||
expect(existsSync(registry.snapshotPath(remote.initialCommit, "psd-clinical"))).toBe(true);
|
||||
expect(existsSync(registry.snapshotPath(currentCommit, "psd-clinical"))).toBe(true);
|
||||
|
||||
await registry.reconcileSnapshotRetention([]);
|
||||
expect(existsSync(registry.snapshotPath(remote.initialCommit, "psd-clinical"))).toBe(false);
|
||||
expect(existsSync(registry.snapshotPath(currentCommit, "psd-clinical"))).toBe(true);
|
||||
});
|
||||
|
||||
test("does not bypass an existing live advisory repository lock", async () => {
|
||||
const remote = await fixture();
|
||||
const root = join(remote.root, "registry");
|
||||
|
||||
Reference in New Issue
Block a user