Open History to see the last commit
1import { expect, it } from 'vitest'
2import docs from './fixtures/native-reasoning-docs.json'
3import {
4 applyDashscopeThinking,
5 parseDashscopeThinking,
6 DASHSCOPE_THINKING_URL,
7} from './dashscope-thinking.ts'
8
9it('reads mandatory budget mode only for native thinking-only models in explicit budget families', () => {
10 const parsed = parseDashscopeThinking(docs[DASHSCOPE_THINKING_URL])
11 for (const rawId of [
12 'qwen3.7-max-2026-05-17',
13 'qwen3.8-2.4t-a95b',
14 'qwen3.6-35b-a3b',
15 'qwen3.7-max-preview',
16 'kimi-k2.7-code',
17 'glm-5.3',
18 'qwen3-next-80b-a3b-thinking',
19 'qwen3-30b-a3b-thinking-2507',
20 'qwen3-235b-a22b-thinking-2507',
21 ]) {
22 const model = applyDashscopeThinking(
23 { rawId, activity: 'chat' },
24 { ...parsed, hash: 'source' },
25 )
26 expect(model.reasoning).toEqual({
27 mode: 'budget',
28 mandatory: rawId === 'qwen3.6-35b-a3b' ? null : true,
29 })
30 expect(model.requestMap).toBeUndefined()
31 }
32 expect(
33 applyDashscopeThinking(
34 { rawId: 'qwq-plus', activity: 'chat' },
35 { ...parsed, hash: 'source' },
36 ).reasoning,
37 ).toBeUndefined()
38 expect(
39 applyDashscopeThinking(
40 { rawId: 'qwen3-unpublished', activity: 'chat' },
41 { ...parsed, hash: 'source' },
42 ).reasoning,
43 ).toBeUndefined()
44})
45it('does not derive budget scope from code examples or malformed scope declarations', () => {
46 const text = docs[DASHSCOPE_THINKING_URL]
47 expect(() =>
48 parseDashscopeThinking(
49 text.replace(
50 /Applicable to [^\n]+? series models\./,
51 'Applicable to invalid family labels series models.',
52 ),
53 ),
54 ).toThrow()
55 const fenced = parseDashscopeThinking(
56 text.replace(/ {2}`thinking_budget`Parameter[^\n]+/, '```\n$&\n```'),
57 )
58 expect(Object.values(fenced.models).some((model) => model.budget)).toBe(false)
59})
60
61it('states no budget or replay scope once the page drops both tips (2026-10-27)', () => {
62 const text = docs[DASHSCOPE_THINKING_URL]
63 .replace(/<Tip>\s*`thinking_budget`Parameter[\s\S]*?<\/Tip>/, '')
64 .replace(/<Tip>\s*`preserve_thinking`This Parameter[\s\S]*?<\/Tip>/, '')
65 expect(text).not.toMatch(/Applicable to|This Parameter only supports/)
66 const parsed = parseDashscopeThinking(text)
67 expect(parsed.replay).toBeNull()
68 expect(parsed.budgetScope).toBe(false)
69 expect(Object.values(parsed.models).some((model) => model.budget)).toBe(false)
70 const doc = { ...parsed, hash: 'source' }
71 // Hybrid rows are still stated; the request map (replay flag) is kept.
72 const hybrid = applyDashscopeThinking(
73 { rawId: 'qwen3.7-max', activity: 'chat' },
74 doc,
75 )
76 expect(hybrid.reasoning).toEqual({ mode: 'toggle', mandatory: false })
77 expect(hybrid.absent).toEqual({ requestMap: 'unavailable' })
78 // A thinking-only row keeps its stored budget mode rather than nulling it.
79 const only = applyDashscopeThinking(
80 { rawId: 'qwen3.7-max-preview', activity: 'chat' },
81 doc,
82 )
83 expect(only.reasoning).toBeUndefined()
84 expect(only.capabilities).toEqual(['reasoning'])
85 expect(only.absent).toEqual({
86 requestMap: 'unavailable',
87 reasoning: 'unavailable',
88 })
89 // An unlisted chat row only keeps its request map.
90 expect(
91 applyDashscopeThinking({ rawId: 'qwen-turbo', activity: 'chat' }, doc)
92 .absent,
93 ).toEqual({ requestMap: 'unavailable' })
94 // With both tips present nothing is marked.
95 expect(
96 applyDashscopeThinking(
97 { rawId: 'qwen3.7-max-preview', activity: 'chat' },
98 { ...parseDashscopeThinking(docs[DASHSCOPE_THINKING_URL]), hash: 'h' },
99 ).absent,
100 ).toBeUndefined()
101})
102
103it('rejects negated native budget applicability and thinking-only declarations', () => {
104 const text = docs[DASHSCOPE_THINKING_URL]
105 expect(() =>
106 parseDashscopeThinking(
107 text.replace(
108 'Applicable to Qwen3.8',
109 'Do not assume Applicable to Qwen3.8',
110 ),
111 ),
112 ).toThrow('negated native budget')
113 expect(() =>
114 parseDashscopeThinking(
115 text.replace(
116 'Supports thinking mode only',
117 'Does not support thinking mode only',
118 ),
119 ),
120 ).toThrow('negated native model mode')
121})