fix(browser): normalize selected script manifest roots on Windows (#1078)
* fix(browser): normalize selected script manifest roots on Windows * test(browser): keep manifest fixtures valid across Windows drives
This commit is contained in:
@@ -1,4 +1,10 @@
|
||||
import { expect } from "vitest";
|
||||
import { expect, onTestFinished } from "vitest";
|
||||
import { Client } from "@modelcontextprotocol/client";
|
||||
import {
|
||||
StdioClientTransport,
|
||||
getDefaultEnvironment,
|
||||
} from "@modelcontextprotocol/client/stdio";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { mkdir, writeFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { webSourceLocationFixture } from "../fixtures/webSourceLocation.js";
|
||||
@@ -12,7 +18,7 @@ cliTest(
|
||||
const fixture = webSourceLocationFixture();
|
||||
await mkdir(join(root, "files", "modules"), { recursive: true });
|
||||
await writeFile(join(root, "files", "modules", "main.js"), fixture.source);
|
||||
const manifest = join(root, "manifest.json");
|
||||
const manifest = join(root, "manifest.json").replaceAll("\\", "/");
|
||||
const map = join(root, "app.js.map");
|
||||
await writeFile(manifest, JSON.stringify(fixture.manifest));
|
||||
await writeFile(map, fixture.sourceMap.text);
|
||||
@@ -44,6 +50,40 @@ cliTest(
|
||||
runtime: { id: "node-v8" },
|
||||
},
|
||||
});
|
||||
const transport = new StdioClientTransport({
|
||||
command: process.execPath,
|
||||
args: [
|
||||
fileURLToPath(new URL("../../scripts/rea.mjs", import.meta.url)),
|
||||
"mcp",
|
||||
],
|
||||
env: { ...getDefaultEnvironment(), REA_LOG_LEVEL: "silent" },
|
||||
stderr: "pipe",
|
||||
});
|
||||
const client = new Client({
|
||||
name: "source-location-cli-parity",
|
||||
version: "1",
|
||||
});
|
||||
onTestFinished(async () => {
|
||||
try {
|
||||
await client.close();
|
||||
} finally {
|
||||
await transport.close();
|
||||
}
|
||||
});
|
||||
await client.connect(transport);
|
||||
const mcpResponse = await client.callTool({
|
||||
name: "trace_web_source_location",
|
||||
arguments: {
|
||||
manifest_path: manifest,
|
||||
script_index: 0,
|
||||
source_map: { path: map, url: fixture.sourceMap.url },
|
||||
generated_position: { line: 1, column: 0 },
|
||||
},
|
||||
});
|
||||
expect(mcpResponse.isError, JSON.stringify(mcpResponse)).not.toBe(true);
|
||||
expect(mcpResponse.structuredContent).toMatchObject({
|
||||
evidence: response.json,
|
||||
});
|
||||
const invalid = await cli.run({
|
||||
arguments: [
|
||||
"trace-web-source-location",
|
||||
|
||||
Reference in New Issue
Block a user