test(cua-mcp): compare resolved working directories

The Windows coverage job failed on the new working-directory assertion: realpath expands the
runner's 8.3 short temporary path (RUNNER~1) while the program's process.cwd() keeps the spelling
it was started with. Both sides are now resolved before comparison in the composition test and in
the profile end-to-end test; macOS still needs the resolution because its temporary directory is a
symlink. The parsed window id is annotated as the string it has been since window ids became strings.
This commit is contained in:
Yichen Jiang committed 2026-11-11 13:37:36 +08:00
1 parent b2e064fecb
commit 69f53d442b
2 files changed
+9 -6

No files matched your search

@@ -73,11 +73,13 @@ describe.skipIf(!existsSync(bin))('cua-mcp profile', { retry: 0 }, () => {
} }) as CallResult
expect(first.isError).toBeUndefined()
expect(first.content.map(block => block.type)).toEqual(['text', 'image'])
const state = JSON.parse(textOf(first.content[0])) as { visits: number; window: number; pid: number; cwd: string }
const state = JSON.parse(textOf(first.content[0])) as { visits: number; window: string; pid: number; cwd: string }
expect(state).toMatchObject({ visits: 1, window: '7' })
// Without DSH_CUA_WORKSPACE the profile creates its workspace inside the Harness home and starts programs there.
expect(state.cwd).toBe(await realpath(join(home, 'cua-mcp', 'workspace')))
expect(state.cwd).not.toBe(await realpath(launch))
// Both spellings are resolved: the temporary directory is a symlink on macOS and an 8.3 short name on Windows.
const programDirectory = await realpath(state.cwd)
expect(programDirectory).toBe(await realpath(join(home, 'cua-mcp', 'workspace')))
expect(programDirectory).not.toBe(await realpath(launch))
const image = first.content[1]
if (image?.type !== 'image') throw new Error('expected an image block')
expect(image.mimeType).toMatch(/^image\//)
@@ -214,11 +214,12 @@ describe('Computer Use MCP composition', () => {
+ 'inspect(JSON.stringify({ visits, window: win.windowId, pid: process.pid, cwd: process.cwd() }), await win.getScreenshot())', { description: 'Open the fixture' })
expect(first.isError).not.toBe(true)
// A program result is the program's own output: the inspected text, then the screenshot the program observed.
const result = JSON.parse(texts(first)[0] ?? '') as { visits: number; window: number; pid: number; cwd: string }
const result = JSON.parse(texts(first)[0] ?? '') as { visits: number; window: string; pid: number; cwd: string }
expect(result).toMatchObject({ visits: 1, window: '7' })
expect(result.pid).not.toBe(process.pid)
// Programs start in the directory the connection's Agent was created in.
expect(result.cwd).toBe(await realpath(directory))
// Programs start in the directory the connection's Agent was created in. Both spellings are resolved: the
// temporary directory is a symlink on macOS and an 8.3 short name on Windows.
expect(await realpath(result.cwd)).toBe(await realpath(directory))
const image = first.content[1]
if (image?.type !== 'image') throw new Error(`expected an image block, got ${JSON.stringify(image)}`)
expect(image.mimeType).toMatch(/^image\//)