test(snapshot): keep dsh run plugin metadata static

This commit is contained in:
Tianyi Cui
2026-08-08 02:20:11 +08:00
parent 21c380be52
commit 33a7b1284e
2 changed files with 12 additions and 7 deletions

View File

@@ -5,4 +5,4 @@
- insert:
- id: cli-mock-llm
name: !!js process.env.DSH_RUN_MOCK_PLUGIN_URL
name: './snapshot-fixtures/cli-mock-llm.ts'

View File

@@ -1,8 +1,8 @@
import { readFile, readdir, writeFile } from 'node:fs/promises'
import { copyFile, mkdir, readFile, readdir, writeFile } from 'node:fs/promises'
import { createServer } from 'node:http'
import type { IncomingMessage, ServerResponse } from 'node:http'
import { delimiter, dirname, join } from 'node:path'
import { fileURLToPath, pathToFileURL } from 'node:url'
import { fileURLToPath } from 'node:url'
import {
normalizeSessionLog,
normalizeStdout,
@@ -54,9 +54,7 @@ const reasoningConfigPath = fileURLToPath(new URL('./fixtures/cli.cordis.yml', i
const deepseekDefaultsConfigPath = fileURLToPath(new URL('./fixtures/deepseek-defaults.cordis.yml', import.meta.url))
const dshRunOverlayPath = fileURLToPath(new URL('./fixtures/dsh-run.cordis.yml', import.meta.url))
const dshRunSessionExpected = join(snapshotsDir, 'dsh-run', 'session.expected.jsonl')
const cliMockLlmPluginUrl = pathToFileURL(
fileURLToPath(new URL('./fixtures/cli-mock-llm.ts', import.meta.url)),
).href
const cliMockLlmPluginPath = fileURLToPath(new URL('./fixtures/cli-mock-llm.ts', import.meta.url))
const refreshing = process.env.DSH_SNAPSHOT === 'refresh'
interface JsonObject {
@@ -209,11 +207,18 @@ describe('headless stream-json snapshots', () => {
binArgs: ['run', '--patch', dshRunOverlayPath, task],
tsconfigPath,
env: {
DSH_RUN_MOCK_PLUGIN_URL: cliMockLlmPluginUrl,
DSH_PERMISSION_MODE: 'danger-full-access',
DSH_TELEMETRY_DISABLED: '1',
NODE_OPTIONS: [process.env.NODE_OPTIONS, '--disable-warning=ExperimentalWarning'].filter(Boolean).join(' '),
},
prepare: async (cwd) => {
const fixtureDir = join(cwd, '.dsh', 'profiles', 'headless', 'snapshot-fixtures')
await mkdir(fixtureDir, { recursive: true })
await Promise.all([
copyFile(cliMockLlmPluginPath, join(fixtureDir, 'cli-mock-llm.ts')),
writeFile(join(fixtureDir, 'package.json'), '{"type":"module"}\n'),
])
},
inspect: async (cwd) => {
const logs = await persistedLogs(cwd, join(cwd, '.dsh', 'sessions'))
expect(logs).toHaveLength(1)