test: 修复回显契约扩散到的类型化 fake 与断言
This commit is contained in:
1 parent
cf47b7e059
commit
5657066b1d
5 files changed
+9
-3
No files matched your search
@@ -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)
|
||||
|
||||
@@ -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')),
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
)
|
||||
|
||||
@@ -27,6 +27,7 @@ type AttentionState = Parameters<Parameters<QuestionComposerProps['useSessionPen
|
||||
const sessionState: SessionState = {
|
||||
sessionId: SID,
|
||||
queue: [],
|
||||
pendingSubmissions: [],
|
||||
running: false,
|
||||
subagent: null,
|
||||
removed: false,
|
||||
|
||||
Reference in new issue
Block a user