Record the admitted selected path separately from canonical artifact identity in successful and partial Evidence. Anchor relative inputs consistently across both CLI routes using the existing caller-path owner. Adapt shared client verifier assertions and boundary coverage from PR #5261, and the dedicated-route anchoring correction proposed in PR #5265. Historical parsing remains independent of live paths, including legacy records without the parameter. Validation: 118 focused tests in eight files, static and docs checks, discovery, and installed Gemini CLI 0.29.5 loopback verification of 207 schemas/241 examples passed. Synthetic static-analysis fixtures; no live Google API or native target execution. Fixes #5258 Co-authored-by: kwakhyun <khyun2348@naver.com> Co-authored-by: vishal-tambi <tambivishal3@gmail.com>
56 lines
2.1 KiB
TypeScript
56 lines
2.1 KiB
TypeScript
import { mkdir, realpath, symlink, writeFile } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
import { expect, it } from "vitest";
|
|
|
|
import { assertJavaScriptApplicationInputPaths } from "../../../scripts/lib/javascript-application-paths.mjs";
|
|
import { javascriptApplicationAnalysisResultSchema } from "../../../src/domain/javascript/javascriptApplicationAnalysis.js";
|
|
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
|
import { analyzeJavaScriptApplication } from "../../support/javascriptApplicationScope.js";
|
|
|
|
it("checks caller and canonical paths independently in real JavaScript analysis Evidence", async () => {
|
|
const root = await createTestTempDirectory("rea-js-client-paths-");
|
|
const directory = join(root, "app α测试");
|
|
const inputPath = join(root, "selected app");
|
|
await mkdir(directory);
|
|
await writeFile(join(directory, "main.js"), "export const observed = 7;\n");
|
|
await symlink(
|
|
directory,
|
|
inputPath,
|
|
process.platform === "win32" ? "junction" : "dir",
|
|
);
|
|
const canonicalPath = await realpath(inputPath);
|
|
const result = await analyzeJavaScriptApplication({ input_path: inputPath });
|
|
if (!result.ok) throw result.error;
|
|
const evidence = {
|
|
...result.value,
|
|
normalized_result: javascriptApplicationAnalysisResultSchema.parse(
|
|
result.value.normalized_result,
|
|
),
|
|
};
|
|
|
|
await expect(
|
|
assertJavaScriptApplicationInputPaths(evidence, inputPath),
|
|
).resolves.toBeUndefined();
|
|
|
|
for (const parameters of [{}, { input_path: canonicalPath }])
|
|
await expect(
|
|
assertJavaScriptApplicationInputPaths(
|
|
{ ...evidence, parameters },
|
|
inputPath,
|
|
),
|
|
).rejects.toThrow("must retain the caller's input_path");
|
|
|
|
await expect(
|
|
assertJavaScriptApplicationInputPaths(
|
|
{ ...evidence, subject: { local_path: inputPath } },
|
|
inputPath,
|
|
),
|
|
).rejects.toThrow("subject must identify the resolved artifact");
|
|
await expect(
|
|
assertJavaScriptApplicationInputPaths(
|
|
{ ...evidence, normalized_result: { input_path: inputPath } },
|
|
inputPath,
|
|
),
|
|
).rejects.toThrow("result must identify the resolved artifact");
|
|
});
|