From f1f35ccaef3291f8eae0bbcb2c6a057ee6ed72e0 Mon Sep 17 00:00:00 2001 From: Turtle Date: Wed, 22 Jul 2026 14:48:34 +0800 Subject: [PATCH] test(e2e): align keyless expectations with the shipped config and scope keys The acp escalation smoke advertises the shipped deepseek-v4-pro; the workspace-context e2e asserts the per-candidate scope key. The PTY harness drops COLORTERM (deterministic banner) and gains configArgs/prepare/inspect for the dsh CLI scenarios. --- examples/acp-agent/tests/escalation.e2e.ts | 2 +- examples/tui-agent/tests/pty-harness.ts | 32 +++++++++++++++---- .../tests/workspace-context.e2e.ts | 3 +- .../tests/workspace-context.spec.ts | 16 +--------- 4 files changed, 30 insertions(+), 23 deletions(-) diff --git a/examples/acp-agent/tests/escalation.e2e.ts b/examples/acp-agent/tests/escalation.e2e.ts index 59d6d75caa..ae53252743 100644 --- a/examples/acp-agent/tests/escalation.e2e.ts +++ b/examples/acp-agent/tests/escalation.e2e.ts @@ -112,7 +112,7 @@ describe('default sandbox composition keyless smoke (real cordis.yml via the Loa // ONE select advertises, current from the configured default preset. const created = await client.newSession({ cwd: workdir, mcpServers: [] }) const advertised = created.configOptions ?? [] - const modelValue = JSON.stringify(['deepseek', 'deepseek-v4-flash']) + const modelValue = JSON.stringify(['deepseek', 'deepseek-v4-pro']) expect(advertised.map(option => [option.id, 'currentValue' in option ? option.currentValue : undefined])) .toEqual([['model', modelValue], ['permission', 'workspace-write']]) // A switch responds with the COMPLETE refreshed state (the spec contract), diff --git a/examples/tui-agent/tests/pty-harness.ts b/examples/tui-agent/tests/pty-harness.ts index 116f7cc9a1..257198b7d2 100644 --- a/examples/tui-agent/tests/pty-harness.ts +++ b/examples/tui-agent/tests/pty-harness.ts @@ -10,6 +10,10 @@ node, launch_args_json, launch_env_json, cwd, actions_json, expected_exit, timeo env = os.environ.copy() env.update(json.loads(launch_env_json)) env.update({"COLUMNS": "100", "LINES": "30"}) +# Deterministic banner: a developer shell's COLORTERM=truecolor would switch the +# banner to the per-letter gradient (one SGR per letter), breaking literal +# DEEPSEEK assertions. The gradient path has its own unit and snapshot coverage. +env.pop("COLORTERM", None) actions = json.loads(actions_json) pid, fd = pty.fork() if pid == 0: @@ -63,12 +67,19 @@ export interface TuiPtySmokeOptions { readonly label: string readonly tempDirPrefix: string readonly binScript: string - readonly configPath: string + /** Config argument; ignored when {@link configArgs} is set. */ + readonly configPath?: string + /** Full argument vector for the bin (e.g. `[]` for a bin with a built-in default config). */ + readonly configArgs?: readonly string[] readonly tsconfigPath: string readonly actions?: readonly TuiPtyAction[] readonly env?: Readonly readonly expectedExitCode?: number readonly timeoutMs?: number + /** Seed the isolated workspace (`cwd`, with `$DSH_HOME` at `.dsh` and the agents home at `.agents`) before launch. */ + readonly prepare?: (cwd: string) => Promise + /** Inspect the workspace after a passing run, before the temp dir is removed. */ + readonly inspect?: (cwd: string) => Promise } function definedEnv(env: NodeJS.ProcessEnv): Record { @@ -135,6 +146,9 @@ async function runWindowsPtySmoke( env: definedEnv({ ...process.env, ...launch.env, + // Match the POSIX driver: no COLORTERM, so the banner never takes the + // truecolor gradient path under a developer's shell. + COLORTERM: undefined, COLUMNS: '100', LINES: '30', }), @@ -175,9 +189,13 @@ export async function runTuiPtySmoke(options: TuiPtySmokeOptions): Promise block.type === 'text').map(block => block.text).join('') diff --git a/packages/context/workspace-context/tests/workspace-context.spec.ts b/packages/context/workspace-context/tests/workspace-context.spec.ts index 620f8f6eee..f902bdaef0 100644 --- a/packages/context/workspace-context/tests/workspace-context.spec.ts +++ b/packages/context/workspace-context/tests/workspace-context.spec.ts @@ -1,5 +1,5 @@ import { chmod, mkdtemp, mkdir, rm, stat, symlink, utimes, writeFile } from 'node:fs/promises' -import { dirname, join } from 'node:path' +import { dirname, join, resolve } from 'node:path' import { tmpdir } from 'node:os' import { describe, expect, it, vi } from 'vitest' import { Context } from 'cordis' @@ -383,20 +383,6 @@ describe('workspace context instruction discovery', () => { } }) - it('loads through a FileSystem provider without a cancellation signal', async () => { - // Direct-library callers may omit `signal`; the fs-backed probe must pass - // no options object rather than `{ signal: undefined }`. - const ctx = new Context() - await ctx.plugin(RecordingFileSystem) - const fs = ctx.fs as RecordingFileSystem - fs.entries.set('/repo/.git', { type: 'directory' }) - fs.entries.set('/repo/AGENTS.md', { type: 'file', content: 'signalless rule' }) - const rendered = await loadBaselineInstructions({ cwd: '/repo', maxBytes: 65536 }, fs) - expect(rendered?.text).toContain('signalless rule') - expect(fs.signals).toHaveLength(0) - await ctx.fiber.dispose() - }) - it('skips a file that becomes unreadable after discovery without failing the request', async () => { const root = await tempRepo() const home = await tempRepo()