mirror of
https://github.com/getpaseo/paseo.git
synced 2026-07-29 12:01:31 +00:00
fix(projects): retain archived reference errors
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { describe, expect, test, vi } from "vitest";
|
||||
import { describe, expect, test } from "vitest";
|
||||
import type { PersistedProjectRecord } from "./workspace-registry.js";
|
||||
import { resolveProjectReference } from "./project-reference.js";
|
||||
|
||||
@@ -36,12 +36,29 @@ describe("resolveProjectReference", () => {
|
||||
rootPath: "/new/app",
|
||||
});
|
||||
const registry = {
|
||||
get: vi.fn().mockResolvedValue(archivedLegacyProject),
|
||||
list: vi.fn().mockResolvedValue([archivedLegacyProject, activeProject]),
|
||||
get: async () => archivedLegacyProject,
|
||||
list: async () => [archivedLegacyProject, activeProject],
|
||||
};
|
||||
|
||||
await expect(resolveProjectReference(reference, registry, ["/new/app"])).resolves.toEqual(
|
||||
activeProject,
|
||||
);
|
||||
});
|
||||
|
||||
test("preserves an archived direct project when there is no active replacement", async () => {
|
||||
const archivedProject = project({
|
||||
projectId: "archived-project-id",
|
||||
projectKey: "remote:github.com/acme/app",
|
||||
rootPath: "/old/app",
|
||||
archivedAt: "2026-02-01T00:00:00.000Z",
|
||||
});
|
||||
const registry = {
|
||||
get: async () => archivedProject,
|
||||
list: async () => [archivedProject],
|
||||
};
|
||||
|
||||
await expect(resolveProjectReference(archivedProject.projectId, registry)).resolves.toEqual(
|
||||
archivedProject,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -20,5 +20,5 @@ export async function resolveProjectReference(
|
||||
);
|
||||
if (matches.length === 1) return matches[0] ?? null;
|
||||
}
|
||||
return candidates.length === 1 ? (candidates[0] ?? null) : null;
|
||||
return candidates.length === 1 ? (candidates[0] ?? null) : direct;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user