From a08e40b9245081817a3fa682d2797c7b3d2c4e82 Mon Sep 17 00:00:00 2001 From: N0zoM1z0 <161784452+N0zoM1z0@users.noreply.github.com> Date: Wed, 11 Nov 2026 08:46:30 +0000 Subject: [PATCH] test(reference): verify relocated dangling-directory commitments through CLI Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com> --- .../cli/referenceSourceSymlinkPaths.test.ts | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/boundary/cli/referenceSourceSymlinkPaths.test.ts b/tests/boundary/cli/referenceSourceSymlinkPaths.test.ts index fa456eb667..fa9594212f 100644 --- a/tests/boundary/cli/referenceSourceSymlinkPaths.test.ts +++ b/tests/boundary/cli/referenceSourceSymlinkPaths.test.ts @@ -7,6 +7,7 @@ import { writeFile, } from "node:fs/promises"; import { join } from "node:path"; +import { z } from "zod"; import { expect } from "vitest"; import { historicalSourceGraphSchema } from "../../../src/domain/referenceSourceGraph.js"; @@ -132,3 +133,40 @@ cliTest.skipIf(process.platform === "win32")( ); }, ); + +for (const target of ["sub/missing", "sub/missing/", "sub/"]) { + cliTest.skipIf(process.platform === "win32")( + `retains relocated source commitments for ${target}`, + async ({ cli }) => { + const work = await createTestTempDirectory("rea-reference-relocation-"); + const commitments = []; + for (const side of ["left", "right"]) { + const root = join(work, side); + await mkdir(join(root, "sub"), { recursive: true }); + await writeFile(join(root, "sub", "keep.txt"), "keep\n"); + await symlink(target, join(root, "link")); + const reply = await cli.run({ + arguments: [ + "import-reference-source", + root, + "--detail=summary", + "--json", + ], + }); + expect(reply.exitCode, reply.stderr).toBe(0); + const parsed = z + .object({ + manifest: z.object({ + root_sha256: z.string(), + graph_sha256: z.string(), + manifest_id: z.string(), + }), + }) + .parse(reply.json); + commitments.push(parsed.manifest); + expect(await readlink(join(root, "link"))).toBe(target); + } + expect(commitments[0]).toEqual(commitments[1]); + }, + ); +}