test(qwen-adapter): cover tab-container placeholder handling
Add query-level cases asserting an internal placeholder yields `unknown`/`qwen_incomplete_response`, and that a resolved sibling field is used as the answer when another field is still a placeholder. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { __qwenTestUtils } from './qwen'
|
||||
import type { AdapterContext } from './base'
|
||||
import { __qwenTestUtils, qwenAdapter } from './qwen'
|
||||
|
||||
const { extractQuestionText } = __qwenTestUtils
|
||||
|
||||
@@ -15,3 +16,81 @@ describe('qwen adapter helpers', () => {
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('qwen adapter query result validation', () => {
|
||||
it('does not submit an internal tab-container placeholder as a successful answer', async () => {
|
||||
const page = {
|
||||
waitForLoadState: async () => undefined,
|
||||
url: () => 'https://www.qianwen.com/chat/demo',
|
||||
goto: async () => undefined,
|
||||
evaluate: async () => ({
|
||||
ok: true as const,
|
||||
url: 'https://www.qianwen.com/chat/demo',
|
||||
question: {
|
||||
model: 'Qwen',
|
||||
deepSearch: '1',
|
||||
enableSearch: true,
|
||||
cardText: '测试问题',
|
||||
},
|
||||
answer: {
|
||||
reqId: 'req-1',
|
||||
status: 'finish',
|
||||
content: {
|
||||
multiLoadIframe: {
|
||||
content: '[(tab_container_1)]',
|
||||
},
|
||||
searchResults: [{ url: 'https://example.com/source', title: '来源' }],
|
||||
},
|
||||
extraInfo: null,
|
||||
communication: null,
|
||||
},
|
||||
}),
|
||||
}
|
||||
const context = {
|
||||
playwright: { page, browser: {} },
|
||||
reportProgress: () => undefined,
|
||||
} as unknown as AdapterContext
|
||||
|
||||
const result = await qwenAdapter.query(context, { question_text: '测试问题' })
|
||||
|
||||
expect(result.status).toBe('unknown')
|
||||
expect(result.error?.code).toBe('qwen_incomplete_response')
|
||||
})
|
||||
|
||||
it('uses a resolved fallback answer when another content field is still a placeholder', async () => {
|
||||
const page = {
|
||||
waitForLoadState: async () => undefined,
|
||||
url: () => 'https://www.qianwen.com/chat/demo',
|
||||
goto: async () => undefined,
|
||||
evaluate: async () => ({
|
||||
ok: true as const,
|
||||
url: 'https://www.qianwen.com/chat/demo',
|
||||
question: {
|
||||
model: 'Qwen',
|
||||
deepSearch: '1',
|
||||
enableSearch: true,
|
||||
cardText: '测试问题',
|
||||
},
|
||||
answer: {
|
||||
reqId: 'req-2',
|
||||
status: 'finish',
|
||||
content: {
|
||||
multiLoadIframe: { content: '[(tab_container_1)]' },
|
||||
barIframe: { content: '这是完整答案。' },
|
||||
},
|
||||
extraInfo: null,
|
||||
communication: null,
|
||||
},
|
||||
}),
|
||||
}
|
||||
const context = {
|
||||
playwright: { page, browser: {} },
|
||||
reportProgress: () => undefined,
|
||||
} as unknown as AdapterContext
|
||||
|
||||
const result = await qwenAdapter.query(context, { question_text: '测试问题' })
|
||||
|
||||
expect(result.status).toBe('succeeded')
|
||||
expect(result.payload?.answer).toBe('这是完整答案。')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user