Jelajahi Sumber

fix(test): repair alpha fixture and Windows gates

Tianyi Cui 3 minggu lalu
induk
melakukan
aa97372fe4

+ 1 - 1
apps/web/tests/navigation-panes.e2e.ts

@@ -28,7 +28,7 @@ const SEARCH_EXPECTED = join(SNAPSHOT_DIR, 'search-results.expected.md')
 const TERMINAL_EXPECTED = join(SNAPSHOT_DIR, 'terminal-card.expected.md')
 const MODE = webSnapshotMode()
 const SEED_ID = 'navigation-panes-web-e2e'
-const EXPORTED_LOG_FILE = `session.v${String(SESSION_FORMAT_VERSION)}.jsonl`
+const EXPORTED_LOG_FILE = 'session.jsonl'
 
 // Turn 1 leads with a distinctive word: the session-title fallback takes the
 // first words of the first message, so the sidebar-search scenario has a

+ 0 - 1
apps/web/tests/question-composer.e2e.ts

@@ -107,7 +107,6 @@ function cancelledFixture(fixture: string): string {
     message.content[0].isError = true
     data.error = {
       name: 'UserQuestionError',
-      message: 'the user cancelled ask_user_question',
       code: 'ASK_CANCELLED',
     }
     replaced = true

+ 10 - 5
apps/web/tests/scaffold.ts

@@ -62,7 +62,7 @@ import type {
   LlmModelInfo, LlmProviderInfo, LlmResolvedModelInfo, RetryPolicyConfig, StreamChunk,
 } from '@deepseek-ai/dsh-llm'
 import type { ReplayHandle } from '@deepseek-ai/dsh-llm-replay'
-import { installLlmReplay, parseSessionLog } from '@deepseek-ai/dsh-llm-replay'
+import { installLlmReplay, parseSessionLog, parseSessionLogForReplay } from '@deepseek-ai/dsh-llm-replay'
 import {
   packChunkRuns,
   SESSION_FORMAT_VERSION,
@@ -671,7 +671,7 @@ export async function launchWebScaffold(options: LaunchOptions = {}): Promise<We
       if (headerType !== 'session') {
         throw new Error('replayProvidersOnly fixture must open with a session header row')
       }
-      const recorded = parseSessionLog(fixtureText)
+      const recorded = parseSessionLogForReplay(fixtureText, options.replayFixture)
       const hasModelCall = recorded.some(event => (
         event.type === 'assistant/chunk' || event.type === 'request/header' || event.type === 'tool/call'
       ))
@@ -994,9 +994,10 @@ export function realizeSeedFixture(scaffold: WebScaffold, fixtureText: string, i
 /**
  * Parse a committed web seed fixture through the replay reader.
  * @param fixtureText - session JSONL fixture contents.
+ * @param fixturePath - exact source path for the closed replay-only alpha-refusal policy.
  * @returns the original header line, parsed header, and logical events.
  */
-export function parseSeedFixture(fixtureText: string): {
+export function parseSeedFixture(fixtureText: string, fixturePath?: string): {
   headerLine: string
   header: Record<string, unknown>
   events: SessionEvent[]
@@ -1005,7 +1006,10 @@ export function parseSeedFixture(fixtureText: string): {
   if (headerLine === undefined) throw new Error('seed fixture has no session header')
   const header = JSON.parse(headerLine) as Record<string, unknown>
   if (header.type !== 'session') throw new Error('seed fixture must start with a session header')
-  return { headerLine, header, events: parseSessionLog(fixtureText) }
+  const events = fixturePath === undefined
+    ? parseSessionLog(fixtureText)
+    : parseSessionLogForReplay(fixtureText, fixturePath)
+  return { headerLine, header, events }
 }
 
 /**
@@ -1030,8 +1034,9 @@ export async function seedSession(
   fixtureText: string,
   id: string,
   agentPreset?: string,
+  fixturePath?: string,
 ): Promise<SessionId> {
-  const decoded = parseSeedFixture(realizeSeedFixture(scaffold, fixtureText, id))
+  const decoded = parseSeedFixture(realizeSeedFixture(scaffold, fixtureText, id), fixturePath)
   const events = decoded.events
   if (events.length === 0) throw new Error('seed fixture has no events')
   const last = events[events.length - 1]!

+ 1 - 1
apps/web/tests/schedule-after.e2e.ts

@@ -610,7 +610,7 @@ describe.skipIf(MODE === 'record')('web e2e: active Schedule catalog', () => {
       replayFixture: CATALOG_FIXTURE,
       replayProvidersOnly: true,
     })
-    await seedSession(scaffold, fixture, CATALOG_SESSION_ID, 'standard')
+    await seedSession(scaffold, fixture, CATALOG_SESSION_ID, 'standard', CATALOG_FIXTURE)
     const workspace = await scaffold.ctx.workspaceRegistry.create(scaffold.workspaceCwd)
     await workspace.attachSession(CATALOG_SESSION_ID)
 

+ 1 - 1
packages/session/session-persistence-jsonl/tests/jsonl.spec.ts

@@ -640,7 +640,7 @@ describe('JsonlSessionPersistence: immutable format generations', () => {
     const highest = generationLogPath(root, header.cwd, header.id, 4, 'zstd')
     await writeFile(highest, 'newer')
 
-    await expect(ctx.sessionPersistence.list()).rejects.toThrow(highest)
+    await expect(ctx.sessionPersistence.list()).rejects.toThrow(JSON.stringify(highest))
   })
 
   it('surfaces a file occupying the targeted Session-directory path', async () => {