dsh-codearts-dock 0.0.0-stage → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DISCLAIMER.md +47 -0
- package/LICENSE +21 -0
- package/README.md +169 -2
- package/SECURITY.md +45 -0
- package/THIRD_PARTY_NOTICES.md +64 -0
- package/client.js +3491 -0
- package/cordis.patch.yml +10 -0
- package/docs/DETAIL.md +24 -0
- package/docs/DETAIL.zh.md +24 -0
- package/docs/PUBLISHING.md +43 -0
- package/docs/preview.svg +78 -0
- package/icons/dsh-connect-codearts-128.png +0 -0
- package/icons/dsh-connect-codearts-256.png +0 -0
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +88 -4
- package/scripts/build-market-index.mjs +24 -0
- package/scripts/check-legal.sh +33 -0
- package/scripts/check-release.mjs +29 -0
- package/scripts/test.mjs +11 -0
- package/src/account.js +217 -0
- package/src/accounts.js +481 -0
- package/src/adapter.js +715 -0
- package/src/backup.js +89 -0
- package/src/catalog.js +269 -0
- package/src/checkin.js +271 -0
- package/src/credentials.js +435 -0
- package/src/features.js +79 -0
- package/src/gateway.js +521 -0
- package/src/health.js +15 -0
- package/src/index.js +1029 -0
- package/src/models.js +147 -0
- package/src/paths.js +36 -0
- package/src/preferences.js +87 -0
- package/src/protocol/crypto.js +160 -0
- package/src/protocol/sign.js +176 -0
- package/src/protocol/sm4.js +264 -0
- package/src/protocol/sse.js +134 -0
- package/src/sts.js +118 -0
- package/test/accounts.test.mjs +344 -0
- package/test/adapter.test.mjs +234 -0
- package/test/assembler.test.mjs +86 -0
- package/test/features.test.mjs +240 -0
- package/test/live-probe.mjs +55 -0
- package/test/protocol.test.mjs +167 -0
- package/test/registration.test.mjs +303 -0
- package/test/sm4.test.mjs +64 -0
- package/test/ui.test.mjs +732 -0
- package/test/visual.test.mjs +420 -0
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Visual-contract checks against the reference connector card.
|
|
3
|
+
*
|
|
4
|
+
* The two plugins are both connector cards in the same settings panel, so a
|
|
5
|
+
* user sees them side by side and expects the same visual language. This test
|
|
6
|
+
* pins the VALUES, not just the class names: an earlier audit passed because it
|
|
7
|
+
* matched `.dca-btn` existing while the rule underneath had drifted back to the
|
|
8
|
+
* old padding. Every assertion here is a number or a token taken from the
|
|
9
|
+
* reference's stylesheet.
|
|
10
|
+
*
|
|
11
|
+
* It reads the shipped browser half as text, so it runs without a DOM.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import assert from 'node:assert/strict'
|
|
15
|
+
import { readFileSync } from 'node:fs'
|
|
16
|
+
|
|
17
|
+
const results = []
|
|
18
|
+
const check = (name, fn) => {
|
|
19
|
+
try {
|
|
20
|
+
fn()
|
|
21
|
+
results.push(`✓ ${name}`)
|
|
22
|
+
} catch (error) {
|
|
23
|
+
results.push(`✗ ${name}\n ${error.message}`)
|
|
24
|
+
process.exitCode = 1
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const source = readFileSync(new URL('../client.js', import.meta.url), 'utf8')
|
|
29
|
+
|
|
30
|
+
/** Assert one exact declaration substring appears in the stylesheet. */
|
|
31
|
+
const has = (needle, why) => {
|
|
32
|
+
assert.ok(source.includes(needle), `${why}\n missing: ${needle}`)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
check('buttons use the reference geometry and its inverted primary', () => {
|
|
36
|
+
has('padding:5px 14px;border-radius:8px;min-height:32px', 'button box')
|
|
37
|
+
has('background:var(--dsw-alias-label-primary,#e6e6e6)', 'primary is an inverted surface, not a brand fill')
|
|
38
|
+
// Inline row actions are one step smaller, not a different shape.
|
|
39
|
+
has('font-size:12px;line-height:20px;font-weight:500;\n padding:3px 10px', 'small button')
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
check('inputs are monospace 12/20 on bg-l1', () => {
|
|
43
|
+
has('padding:4px 8px;border-radius:6px', 'input box')
|
|
44
|
+
has('font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace', 'input is monospace')
|
|
45
|
+
has('background:var(--dsw-alias-bg-l1,transparent)', 'input rests on bg-l1')
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
check('cards sit on bg-layer-3 with a border-l2 frame at radius 12', () => {
|
|
49
|
+
has('border-radius:12px;background:var(--dsw-alias-bg-layer-3', 'card surface')
|
|
50
|
+
assert.ok(!source.includes('.dca-card:hover'), 'passive cards do not imply a click action')
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
check('the section switcher is a sticky underlined tab strip, not cards', () => {
|
|
54
|
+
has('padding:7px 11px;margin-bottom:-1px', 'tab geometry')
|
|
55
|
+
has('border-bottom:2px solid transparent', 'tab underline is the state carrier')
|
|
56
|
+
assert.ok(source.includes('position:sticky'), 'the strip must pin above scrolling content')
|
|
57
|
+
assert.ok(
|
|
58
|
+
!source.includes('dca-tab-cell'),
|
|
59
|
+
'card-shaped tab cells are not the reference shape and must not come back',
|
|
60
|
+
)
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
check('the account pool is a grid table with an uppercase header row', () => {
|
|
64
|
+
has('grid-template-areas:', 'pool rows are a grid, so columns reflow on a narrow panel')
|
|
65
|
+
has('text-transform:uppercase', 'header row is uppercase')
|
|
66
|
+
has('font-size:11px;font-weight:600;letter-spacing:.02em', 'header typography')
|
|
67
|
+
has('padding:10px 14px', 'row rhythm')
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
check('one bulk claim button serves the account pool', () => {
|
|
71
|
+
assert.ok(source.includes("'pool.checkinAll': ['一键签到'"), 'the bulk button exists')
|
|
72
|
+
assert.ok(
|
|
73
|
+
!source.includes('dca-pool-col-checkin'),
|
|
74
|
+
'never a per-row claim control',
|
|
75
|
+
)
|
|
76
|
+
// Disabled when there is nothing to claim, so a press that cannot act never
|
|
77
|
+
// looks like a broken button.
|
|
78
|
+
assert.ok(source.includes('disabled: anyBusy || busyId !== null || !anyClaimable'), 'disabled with nothing to claim')
|
|
79
|
+
assert.ok(source.includes("allSigned ? t('pool.allSigned')"), 'explains when the whole pool is already done')
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
check('import lives inside the add-account card, revealed on demand', () => {
|
|
83
|
+
assert.ok(source.includes("className: 'dca-card dca-details dca-add-tools'"), 'the add form is a disclosure when accounts already exist')
|
|
84
|
+
// One card component owns both, so the user never picks a method up front.
|
|
85
|
+
const tools = source.slice(source.indexOf('function AccountTools('))
|
|
86
|
+
const body = tools.slice(0, tools.indexOf('\n /**', 10))
|
|
87
|
+
assert.ok(body.includes("postRoute('/accounts/add'"), 'the pair form')
|
|
88
|
+
assert.ok(body.includes("postRoute('/accounts/import'"), 'the bulk form, same component')
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
check('models render as cards on bg-layer-2, not nowrap table columns', () => {
|
|
92
|
+
has('padding:10px 12px;background:var(--dsw-alias-bg-layer-2', 'model row surface')
|
|
93
|
+
assert.ok(source.includes('.dca-model-off{background:'), 'disabled models keep readable text rather than fading the whole row')
|
|
94
|
+
assert.ok(!source.includes('.dca-model-off{opacity:'), 'the whole model row is not dimmed')
|
|
95
|
+
has('.dca-model-meta{', 'facts collapse onto one meta line')
|
|
96
|
+
assert.ok(!source.includes('dca-table'), 'the six-column table is gone')
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
check('hints and row metadata use the reference type scale', () => {
|
|
100
|
+
has('color:var(--dsw-alias-label-tertiary,#999);font-size:12px;line-height:18px', 'hint line')
|
|
101
|
+
has('font-size:11px;line-height:16px', 'row metadata line')
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
check('check-in is a manual action with no automatic switch or route', () => {
|
|
105
|
+
assert.ok(source.includes("postRoute('/checkin/claim-all', {})"), 'manual claim uses a dedicated route')
|
|
106
|
+
assert.ok(!source.includes('/checkin/auto'), 'the automatic route is gone')
|
|
107
|
+
assert.ok(!source.includes('pool.autoTitle'), 'the automatic switch is gone')
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
check('every class the markup uses has a rule in the stylesheet', () => {
|
|
111
|
+
// THE BUG THIS CATCHES: after a component rebuild the markup kept its class
|
|
112
|
+
// names while the rules for them were gone. `node --check` passes, the client
|
|
113
|
+
// loads, and the page renders unstyled — three separate audits missed it
|
|
114
|
+
// because they asked whether a class was *named*, never whether it was
|
|
115
|
+
// *styled*.
|
|
116
|
+
const css = source.slice(source.indexOf('const CSS = `'), source.indexOf('`\n\n /**'))
|
|
117
|
+
const used = new Set()
|
|
118
|
+
for (const m of source.matchAll(/className: '([^']+)'/g)) {
|
|
119
|
+
for (const cls of m[1].split(/\s+/)) if (cls) used.add(cls)
|
|
120
|
+
}
|
|
121
|
+
const defined = new Set([...css.matchAll(/\.(dca-[a-z0-9-]+)/g)].map((m) => m[1]))
|
|
122
|
+
const unstyled = [...used].filter((cls) => cls.startsWith('dca-') && !defined.has(cls))
|
|
123
|
+
assert.deepEqual(unstyled, [], `classes used but never styled: ${unstyled.join(', ')}`)
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
check('the account row is two lines: identity, then a probe line', () => {
|
|
127
|
+
has('.dca-pool-account-row{', 'identity line')
|
|
128
|
+
has('.dca-pool-probe{', 'probe line')
|
|
129
|
+
has('justify-self:end;text-align:right;font-variant-numeric:tabular-nums', 'credits hug the right')
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
check('narrow settings layouts follow panel width, not viewport width', () => {
|
|
133
|
+
has('.dca-settings{container:dca-settings / inline-size;', 'the settings root defines the query container')
|
|
134
|
+
has('@container dca-settings (max-width:420px)', 'the narrow rules query the panel')
|
|
135
|
+
assert.ok(!/@media\s*\(\s*max-width/.test(source), 'settings must also adapt inside a wide window')
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
check('selection controls retain native checkbox styling', () => {
|
|
139
|
+
has('.dca-model-controls input[type="checkbox"]', 'a real model checkbox input')
|
|
140
|
+
has('accent-color:var(--dsw-alias-brand-primary,#5686fe)', 'sized and drawn by the engine')
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
check('model rows indent their second line to the name', () => {
|
|
144
|
+
has('padding-inline-start:22px', '22px = the checkbox box plus its gap')
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
check('import opens the system picker, and export downloads a file', () => {
|
|
148
|
+
// The reference opens the OS picker straight from the button: a ceremony
|
|
149
|
+
// dialog in front of a dialog the OS is about to show is one click of
|
|
150
|
+
// nothing. Export writes a file rather than a clipboard string, because a
|
|
151
|
+
// button labelled 导出 that leaves nothing on disk is a lie.
|
|
152
|
+
assert.ok(source.includes("fileInput.current?.click()"), 'the import button opens the picker')
|
|
153
|
+
assert.ok(source.includes('type: \'file\''), 'a real file input exists')
|
|
154
|
+
assert.ok(source.includes('anchor.download = name'), 'export triggers a download')
|
|
155
|
+
assert.ok(source.includes('URL.createObjectURL'), 'export builds a Blob URL')
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
check('the import preview shows what will be written before writing it', () => {
|
|
159
|
+
assert.ok(source.includes("postRoute('/accounts/preview'"), 'a preview route is called')
|
|
160
|
+
assert.ok(source.includes('pool.previewTotal'), 'the confirmation states the count')
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
check('the settings nav glyph is registered under the section\'s own id', () => {
|
|
164
|
+
// The shell addresses the glyph by id: an id that does not equal the
|
|
165
|
+
// settings.section id never renders, and nothing reports it. Both come from
|
|
166
|
+
// one inject callback so the pairing cannot drift.
|
|
167
|
+
assert.ok(source.includes("'settings.section.icon'"), 'the icon seat is used')
|
|
168
|
+
assert.ok(
|
|
169
|
+
source.includes("name: 'settings.section.icon', id: 'dsh-connect-codearts'"),
|
|
170
|
+
'the glyph id must equal the section id',
|
|
171
|
+
)
|
|
172
|
+
assert.ok(source.includes('NAV_ICON'), 'the glyph has artwork')
|
|
173
|
+
assert.ok(source.includes("data:image/png;base64,"), 'embedded as a data URL, not fetched at paint time')
|
|
174
|
+
assert.ok(
|
|
175
|
+
source.includes('settings nav icon failed to register (page unaffected)'),
|
|
176
|
+
'a host without the icon seat must still get the page',
|
|
177
|
+
)
|
|
178
|
+
})
|
|
179
|
+
|
|
180
|
+
check('the account pool has no on/off switch: the selected account just serves', () => {
|
|
181
|
+
// The switch was removed on request. Which account serves is not a preference
|
|
182
|
+
// to toggle — the selected account serves every request and a failure is
|
|
183
|
+
// reported as it is, so there is nothing to turn on or off.
|
|
184
|
+
const host = readFileSync(new URL('../src/index.js', import.meta.url), 'utf8')
|
|
185
|
+
assert.ok(!source.includes("postRoute('/pool'"), 'no pool route is called from the card')
|
|
186
|
+
assert.ok(!source.includes('pool.enableHint'), 'its hint is gone too')
|
|
187
|
+
assert.ok(!host.includes("route('/pool'"), 'the host no longer serves that route')
|
|
188
|
+
assert.ok(!host.includes('nextAccountClient'), 'failover wiring is gone with it')
|
|
189
|
+
assert.ok(source.includes("postRoute('/checkin/claim-all'"), 'manual check-in remains')
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
check('the provider is declared, so Settings → Models renders a card for it', () => {
|
|
193
|
+
// THE BUG THIS CATCHES: `registerAdapter` alone makes the route routable and
|
|
194
|
+
// feeds the model picker, but Settings → Models builds its rows from the
|
|
195
|
+
// configurable-provider DIRECTORY. With only an adapter the plugin is
|
|
196
|
+
// half-installed: models selectable, no card in the page where a user manages
|
|
197
|
+
// providers. The two symptoms look unrelated and have one cause.
|
|
198
|
+
const host = readFileSync(new URL('../src/index.js', import.meta.url), 'utf8')
|
|
199
|
+
assert.ok(host.includes('registerConfigurableProviders'), 'the directory entry is declared')
|
|
200
|
+
assert.ok(host.includes('registerModelDiscovery'), 'discovery is offered to that page')
|
|
201
|
+
assert.ok(
|
|
202
|
+
host.includes('registerAdapter'),
|
|
203
|
+
'the adapter is registered too — all three, or the plugin is half-installed',
|
|
204
|
+
)
|
|
205
|
+
})
|
|
206
|
+
|
|
207
|
+
check('a model row carries its own selection and capability switches', () => {
|
|
208
|
+
// The row is where a user decides what this provider may send, so the controls
|
|
209
|
+
// live on the row: selection checkbox, image, and "can disable thinking".
|
|
210
|
+
assert.ok(source.includes('dca-model-check'), 'per-row selection checkbox')
|
|
211
|
+
assert.ok(source.includes("setOverride(model.id, { images:"), 'per-row image switch')
|
|
212
|
+
assert.ok(source.includes("setOverride(model.id, { allowOff:"), 'per-row thinking switch')
|
|
213
|
+
assert.ok(source.includes('dca-model-off'), 'an unticked model recedes but stays visible')
|
|
214
|
+
})
|
|
215
|
+
|
|
216
|
+
check('an unticked model leaves the picker, a reset restores everything', () => {
|
|
217
|
+
// `null` is "offer everything" and is NOT the same as an empty array, which
|
|
218
|
+
// would empty the picker with no way back.
|
|
219
|
+
const host = readFileSync(new URL('../src/index.js', import.meta.url), 'utf8')
|
|
220
|
+
assert.ok(host.includes("route('/models/select'"), 'a save route exists')
|
|
221
|
+
assert.ok(host.includes('enabledIds === null'), 'null is distinguished from an empty list')
|
|
222
|
+
assert.ok(host.includes("emit('llm/models-updated'"), 'the picker is told to reload, without a restart')
|
|
223
|
+
})
|
|
224
|
+
|
|
225
|
+
check('edits are a draft until saved, with a visible dirty marker', () => {
|
|
226
|
+
assert.ok(source.includes('models.dirty'), 'unsaved edits are marked')
|
|
227
|
+
assert.ok(source.includes('models.discard'), 'they can be discarded')
|
|
228
|
+
assert.ok(source.includes("postRoute('/models/select'"), 'saving writes them')
|
|
229
|
+
})
|
|
230
|
+
|
|
231
|
+
check('an account can be renamed from its row', () => {
|
|
232
|
+
// Without a name, several accounts are indistinguishable: the row shows a
|
|
233
|
+
// masked AK, which tells a user nothing about which account is which.
|
|
234
|
+
assert.ok(source.includes('dca-rename-btn'), 'the name is an inline editor trigger')
|
|
235
|
+
assert.ok(source.includes("postRoute('/accounts/rename'"), 'it saves through the route')
|
|
236
|
+
assert.ok(source.includes('renameable === false'), 'a derived label starts the editor EMPTY, not prefilled')
|
|
237
|
+
assert.ok(source.includes("event.key === 'Escape'"), 'Escape cancels — an accidental click must not save')
|
|
238
|
+
assert.ok(source.includes("event.key === 'Enter'"), 'Enter commits')
|
|
239
|
+
})
|
|
240
|
+
|
|
241
|
+
check('save and discard live in a persistent action bar', () => {
|
|
242
|
+
// A bar that appears only once something is dirty moves under the pointer at
|
|
243
|
+
// the exact moment the user is looking for it. The reference keeps it present
|
|
244
|
+
// and disables it, which is also what the shared `.dca-btn` disabled style is
|
|
245
|
+
// for.
|
|
246
|
+
assert.ok(source.includes('dca-model-actions'), 'the bar exists')
|
|
247
|
+
assert.ok(source.includes('dca-model-actions-buttons'), 'buttons sit together at the end')
|
|
248
|
+
assert.ok(source.includes('disabled: !dirty || busy !== null'), 'disabled when there is nothing to save')
|
|
249
|
+
assert.ok(source.includes('position:sticky;bottom:0;z-index:3'), 'the save bar remains at the viewport edge')
|
|
250
|
+
assert.ok(source.includes('dca-save-status'), 'the persistent bar explains saved and unsaved state')
|
|
251
|
+
})
|
|
252
|
+
|
|
253
|
+
check('the composer panel lists every account, not just the serving one', () => {
|
|
254
|
+
// The reference's panel is a table of the whole pool: "which account" and "how
|
|
255
|
+
// many credits" are the same fact about the same thing, so splitting them made
|
|
256
|
+
// the panel read as two unrelated blocks.
|
|
257
|
+
assert.ok(source.includes('dca-pop-table'), 'a real table, so balances align in one column')
|
|
258
|
+
assert.ok(source.includes('dca-pop-num'), 'the figure column is right-aligned and tabular')
|
|
259
|
+
assert.ok(source.includes('dca-pop-dot'), 'each row carries a state dot')
|
|
260
|
+
assert.ok(source.includes('dca-pop-mark-reason'), 'a reason sits UNDER the name, not beside it')
|
|
261
|
+
assert.ok(source.includes("postRoute('/accounts/activate'"), 'a row switches the pool on click')
|
|
262
|
+
assert.ok(source.includes("getRoute('/accounts')"), 'the panel reads the pool, not just /account')
|
|
263
|
+
})
|
|
264
|
+
|
|
265
|
+
check('the panel header carries refresh and settings, in that order', () => {
|
|
266
|
+
// Refresh acts on the table right below it (local, repeatable); settings leaves
|
|
267
|
+
// the panel. A navigating control goes LAST so a press meant for "bring this up
|
|
268
|
+
// to date" cannot land on "leave".
|
|
269
|
+
const head = source.slice(source.indexOf("className: 'dca-pop-head'"))
|
|
270
|
+
const refreshAt = head.indexOf('dca-pop-refresh')
|
|
271
|
+
const settingsAt = head.indexOf('dca-pop-settings')
|
|
272
|
+
assert.ok(refreshAt > 0, 'refresh is in the header')
|
|
273
|
+
assert.ok(settingsAt > refreshAt, 'settings comes after refresh')
|
|
274
|
+
assert.ok(source.includes('dca-pop-refresh-icon-spin'), 'refresh spins while it runs')
|
|
275
|
+
assert.ok(source.includes('dca-pop-soon'), 'a lapsing balance warns on its own line')
|
|
276
|
+
})
|
|
277
|
+
|
|
278
|
+
check('reasoning levels are shown in the reader\'s language, not their ids', () => {
|
|
279
|
+
// The model page printed `model.defaultStrength` raw, so the same level read
|
|
280
|
+
// `high` there and 高 in the picker. One fact must read the same everywhere.
|
|
281
|
+
assert.ok(source.includes('EFFORT_LABELS'), 'a label table exists')
|
|
282
|
+
assert.ok(source.includes('function effortLabel('), 'and a resolver reads it')
|
|
283
|
+
assert.ok(source.includes('isChinese() ? pair[0] : pair[1]'), 'it follows the document language')
|
|
284
|
+
assert.ok(!source.includes('${t(\'models.effort\')} ${model.defaultStrength'), 'the raw id is not printed')
|
|
285
|
+
for (const zh of ['关闭', '低', '中', '高', '最高']) {
|
|
286
|
+
assert.ok(source.includes(`'${zh}'`), `${zh} must be in the label table`)
|
|
287
|
+
}
|
|
288
|
+
})
|
|
289
|
+
|
|
290
|
+
check('the add-account fields are one row, named by their placeholders', () => {
|
|
291
|
+
// Form labels remain visible after input. The drawer is compact when closed,
|
|
292
|
+
// while helper text is revealed only when a user asks for it.
|
|
293
|
+
assert.ok(source.includes("className: 'dca-fields'"), 'the fields share a row')
|
|
294
|
+
assert.ok(source.includes("className: 'dca-form-field'"), 'visible labels remain after typing')
|
|
295
|
+
assert.ok(source.includes("placeholder: t('account.placeholderAk')"), 'the AK field has a useful hint')
|
|
296
|
+
assert.ok(source.includes("htmlFor: 'dca-ak2'"), 'the visible label remains after typing')
|
|
297
|
+
assert.ok(source.includes("type: showSecret ? 'text' : 'password'"), 'the secret can be revealed on demand')
|
|
298
|
+
assert.ok(source.includes("placeholder: t('account.placeholderSk')"), 'so does the SK field')
|
|
299
|
+
})
|
|
300
|
+
|
|
301
|
+
check('the panel has one refresh, in its header, and no instruction label', () => {
|
|
302
|
+
// The bottom refresh duplicated the header one; two controls for one action
|
|
303
|
+
// invite the question of whether they differ. The old label —
|
|
304
|
+
// 「点击查看码道账号与积分」 — was an instruction printed INSIDE the thing it
|
|
305
|
+
// told you to click, which reads as a leftover from the trigger.
|
|
306
|
+
assert.ok(!source.includes("className: 'dca-pop-foot'"), 'no bottom action row')
|
|
307
|
+
assert.ok(!source.includes('点击查看码道账号与积分'), 'the click instruction is gone')
|
|
308
|
+
assert.ok(source.includes("'chip.panelTitle': ['码道账号与积分'"), 'the panel names itself instead')
|
|
309
|
+
assert.ok(source.includes("className: 'dca-pop-refresh'"), 'the header refresh remains')
|
|
310
|
+
// Exactly one refresh control INSIDE THE PANEL. The model page has its own,
|
|
311
|
+
// which is a different surface with its own refresh route.
|
|
312
|
+
const panel = source.slice(source.indexOf('function ComposerChip('))
|
|
313
|
+
const inPanel = [...panel.matchAll(/onClick: refresh/g)].length
|
|
314
|
+
assert.equal(inPanel, 1, `expected one refresh control in the panel, found ${inPanel}`)
|
|
315
|
+
})
|
|
316
|
+
|
|
317
|
+
check('an account row lights up on hover, and the serving row does not', () => {
|
|
318
|
+
// Hover belongs to the SWITCH, not the row: the credits cell is not clickable,
|
|
319
|
+
// so lighting it up would promise an action it cannot perform.
|
|
320
|
+
assert.ok(source.includes('.dca-pop-switch:hover:not(:disabled){background'), 'the row body fills on hover')
|
|
321
|
+
assert.ok(source.includes('.dca-pop-switch:focus-visible'), 'keyboard gets the same affordance')
|
|
322
|
+
assert.ok(source.includes('.dca-pop-switch:active:not(:disabled)'), 'and a pressed state')
|
|
323
|
+
assert.ok(!source.includes('.dca-pop-table tbody tr:hover'), 'the row itself never lights up')
|
|
324
|
+
// The serving row's switch is disabled, so it must not offer a click target.
|
|
325
|
+
assert.ok(source.includes('.dca-pop-row-current .dca-pop-name{font-weight:600}'), 'the serving row reads as current')
|
|
326
|
+
assert.ok(source.includes("className: account.active ? 'dca-pop-row-current'"), 'and is marked')
|
|
327
|
+
})
|
|
328
|
+
|
|
329
|
+
check('the settings button opens this plugin\'s own settings section', () => {
|
|
330
|
+
// Two routes, best first, exactly as the reference does it.
|
|
331
|
+
//
|
|
332
|
+
// Route 1 reads the shell's STORE SEAT — verified against the shipped client:
|
|
333
|
+
// ui-settings-general registers `{ name: 'sidebar.settings', store: shellStore }`
|
|
334
|
+
// whose actions are { open, close, select, openSection }. NOT `settings.section`
|
|
335
|
+
// (that slot lists the pages and carries no store), and NOT
|
|
336
|
+
// `pluginNavigation.openBundle` (that lands on the bundle's PAGE, not the section).
|
|
337
|
+
assert.ok(source.includes("SETTINGS_SLOT = 'sidebar.settings'"), 'reads the real seat slot')
|
|
338
|
+
assert.ok(!source.includes("entries('settings.section')"), 'not the pages slot — it has no store')
|
|
339
|
+
assert.ok(source.includes('actions?.openSection'), 'calls openSection on the shell instance')
|
|
340
|
+
assert.ok(source.includes('openSection(sectionId)'), 'opens the section named by its id')
|
|
341
|
+
assert.ok(
|
|
342
|
+
source.includes("openThroughStoreSeat(softGet, 'dsh-connect-codearts')"),
|
|
343
|
+
'and that id is this plugin\'s own section',
|
|
344
|
+
)
|
|
345
|
+
// The shell pins create() to its one live instance; a bare handle would move a
|
|
346
|
+
// dialog nobody renders. The comment says so, and the code uses create().
|
|
347
|
+
assert.ok(source.includes('seat.create()'), 'goes through the pinned instance')
|
|
348
|
+
// 'shell' + `open` is the older-shell path: the dialog opens without
|
|
349
|
+
// preselection, and route 2 clicks the row.
|
|
350
|
+
assert.ok(source.includes("return 'shell'"), 'reports the partially-opened shell')
|
|
351
|
+
assert.ok(source.includes('actions?.open'), 'falls back to plain open on an older store')
|
|
352
|
+
// Route 2: drive the chrome, guarded so an already-open panel is not toggled shut.
|
|
353
|
+
assert.ok(source.includes('data-shortcut-modal="settings"'), 'the shell\'s own panel attribute')
|
|
354
|
+
assert.ok(source.includes('aria-haspopup="dialog"'), 'the sidebar trigger selector')
|
|
355
|
+
assert.ok(source.includes('=== null) {'), 'only clicks the trigger when the panel is absent')
|
|
356
|
+
assert.ok(!source.includes('navigation.openBundle('), 'the bundle-page route is gone')
|
|
357
|
+
})
|
|
358
|
+
|
|
359
|
+
check('the settings jump is a standing function, not a conditional prop', () => {
|
|
360
|
+
// A click that does nothing beats a button that is sometimes absent: the shell
|
|
361
|
+
// may still be applying when this module runs, so the button must exist always.
|
|
362
|
+
const chip = source.slice(source.indexOf('function ComposerChip('))
|
|
363
|
+
assert.ok(chip.includes('const openSettings = () => {'), 'declared unconditionally')
|
|
364
|
+
assert.ok(!chip.includes('openSettings\n ? h('), 'no render branch on its presence')
|
|
365
|
+
})
|
|
366
|
+
|
|
367
|
+
check('the default thinking level is chosen, not captioned', () => {
|
|
368
|
+
// A caption told the user what upstream decided. A reasoning model's default
|
|
369
|
+
// is a decision the user makes per model, and the picker cannot express a
|
|
370
|
+
// per-model default on its own.
|
|
371
|
+
assert.ok(source.includes("className: 'dca-effort-select'"), 'a select, not a label')
|
|
372
|
+
assert.ok(source.includes("setOverride(model.id, { defaultStrength:"), 'it writes the override')
|
|
373
|
+
assert.ok(source.includes('dca-effort'), 'and carries the inline effort styling')
|
|
374
|
+
})
|
|
375
|
+
|
|
376
|
+
check('an override the model cannot honour is ignored, not sent upstream', () => {
|
|
377
|
+
// A stale preference, or one hand-edited in preferences.json, must not become
|
|
378
|
+
// a request the gateway rejects.
|
|
379
|
+
const catalog = readFileSync(new URL('../src/catalog.js', import.meta.url), 'utf8')
|
|
380
|
+
assert.ok(catalog.includes("(model.strengths ?? []).includes(override.defaultStrength)"), 'the level is validated')
|
|
381
|
+
assert.ok(catalog.includes(': model.defaultStrength'), 'and falls back to upstream')
|
|
382
|
+
})
|
|
383
|
+
|
|
384
|
+
check('the model page reports the EFFECTIVE default, not upstream\'s', () => {
|
|
385
|
+
// Showing one value while the adapter sends another is the "shows A, bills B"
|
|
386
|
+
// trap this plugin keeps guarding against.
|
|
387
|
+
const host = readFileSync(new URL('../src/index.js', import.meta.url), 'utf8')
|
|
388
|
+
assert.ok(host.includes('deps.catalog.effective(model)'), 'the row is the effective model')
|
|
389
|
+
})
|
|
390
|
+
|
|
391
|
+
check('the model catalog has search, active filter, and useful sorting', () => {
|
|
392
|
+
assert.ok(source.includes("type: 'search', className: 'dca-input dca-search'"), 'searches name and id')
|
|
393
|
+
assert.ok(source.includes("'aria-pressed': filter === value"), 'filter state is accessible')
|
|
394
|
+
assert.ok(source.includes("['ratio', 'models.sortRatio']"), 'can compare models by multiplier')
|
|
395
|
+
assert.ok(source.includes('visibleModels.map'), 'only filtered models render')
|
|
396
|
+
})
|
|
397
|
+
|
|
398
|
+
check('diagnostics lead with health and offer redacted copy', () => {
|
|
399
|
+
assert.ok(source.includes('dca-diagnostic-summary'), 'health summary is above machine details')
|
|
400
|
+
assert.ok(source.includes('navigator.clipboard.writeText(reportText)'), 'one action copies the redacted report')
|
|
401
|
+
assert.ok(source.includes("h('details', { className: 'dca-card dca-details' }"), 'technical internals are collapsed')
|
|
402
|
+
})
|
|
403
|
+
|
|
404
|
+
check('settings tab panels stay mounted and have matching controls', () => {
|
|
405
|
+
assert.ok(source.includes('hidden: tab !== id'), 'switching tabs keeps component state')
|
|
406
|
+
assert.ok(source.includes("'aria-controls': `${panelId}-panel-${id}`"), 'each tab points to its own panel')
|
|
407
|
+
assert.ok(source.includes('tabButtons.current[next]?.focus()'), 'keyboard navigation moves focus as well as selection')
|
|
408
|
+
})
|
|
409
|
+
|
|
410
|
+
check('settings routes populate independently and can be retried', () => {
|
|
411
|
+
assert.ok(source.includes('getRoute(path, { signal: controller.signal })'), 'the four reads are cancellable')
|
|
412
|
+
assert.ok(source.includes('if (controller.signal.aborted) return false'), 'a superseded response cannot replace fresh data')
|
|
413
|
+
assert.ok(source.includes('setData((current) => ({ ...current, [path]: mergeCredits(path, current[path], value) }))'), 'fast status does not wait for account probes')
|
|
414
|
+
assert.ok(source.includes('onSaved: loadModels'), 'model saves reload only the model catalog')
|
|
415
|
+
assert.ok(source.includes("t('common.retry')"), 'a failed read can be retried in place')
|
|
416
|
+
})
|
|
417
|
+
|
|
418
|
+
console.log(results.join('\n'))
|
|
419
|
+
if (process.exitCode) console.log('\nvisual: some checks failed')
|
|
420
|
+
else console.log('\nvisual: all checks passed')
|