Sfoglia il codice sorgente

test: 修复回显契约扩散到的类型化 fake 与断言

creatixchu 2 settimane fa
parent
commit
5657066b1d

+ 2 - 2
packages/api/session-controller/tests/session-pending-submissions.client.spec.ts

@@ -99,7 +99,7 @@ describe('beginSubmission', () => {
 describe('prompt-coupled retirement', () => {
   it('a rejected identified prompt retires its echo immediately alongside promptError', async () => {
     const { api, session } = makeSession()
-    api.onPrompt = () => Promise.resolve(err({ code: 'agent-busy', message: '忙', details: {} }))
+    api.onPrompt = () => Promise.resolve(err({ code: 'agent-busy', message: '忙', details: { reason: 'busy' } }))
     const retirements: PendingSubmissionRetirement[] = []
     const handle = session.beginSubmission({
       text: '失败的',
@@ -122,7 +122,7 @@ describe('prompt-coupled retirement', () => {
 
   it('an unidentified prompt failure leaves registered echoes alone', async () => {
     const { api, session } = makeSession()
-    api.onPrompt = () => Promise.resolve(err({ code: 'agent-busy', message: '忙', details: {} }))
+    api.onPrompt = () => Promise.resolve(err({ code: 'agent-busy', message: '忙', details: { reason: 'busy' } }))
     session.beginSubmission({ text: '还在', images: [] })
     await session.prompt([{ type: 'text', text: '另一个' }], 'queue')
     expect(session.getSnapshot().pendingSubmissions).toHaveLength(1)

+ 1 - 0
packages/client/ui-conversation/tests/conversation-registry.client.spec.ts

@@ -44,6 +44,7 @@ function fakeSession(): SessionFace {
     projections: { faceOf: () => createSnapshotStore<unknown>(undefined) },
     getSnapshot: () => snapshot.getSnapshot(),
     subscribe: listener => snapshot.subscribe(listener),
+    beginSubmission: () => ({ requestId: 'test-req' as never, abandon: () => {} }),
     prompt: () => Promise.reject(new Error('unused fake Session operation')),
     readAttachment: () => Promise.reject(new Error('unused fake Session operation')),
     updateQueue: () => Promise.reject(new Error('unused fake Session operation')),

+ 1 - 0
packages/client/ui-conversation/tests/queue-dock.client.spec.tsx

@@ -39,6 +39,7 @@ function snapshotWith(queue: QueuedMessage[]): SessionSnapshot {
   return {
     sessionId: SID, queue, running: true, removed: false, openState: 'open', openError: null,
     hasMore: false, loadingOlder: false, promptError: null, blank: false, subagent: null,
+    pendingSubmissions: [],
     lastAgentError: null, promptAttempted: true, awaitingFirstTurn: false,
   }
 }

+ 4 - 1
packages/client/ui-trajectory/tests/table.client.spec.tsx

@@ -13,7 +13,10 @@ import { t, tZh } from './locale.client.ts'
 const renderImagesStub: RenderMessageImages = ({ images }) => (
   <div data-testid="record-images" data-count={images.length}>
     {images.map((image, index) => (
-      <span key={index} data-attachment-id={image.attachment.attachmentId} />
+      <span
+        key={index}
+        data-attachment-id={'attachment' in image ? image.attachment.attachmentId : image.preview.url}
+      />
     ))}
   </div>
 )

+ 1 - 0
packages/client/ui-user-questions/tests/plan-review-panel.client.spec.tsx

@@ -27,6 +27,7 @@ type AttentionState = Parameters<Parameters<QuestionComposerProps['useSessionPen
 const sessionState: SessionState = {
   sessionId: SID,
   queue: [],
+  pendingSubmissions: [],
   running: false,
   subagent: null,
   removed: false,