test(web): follow master's slot fixture and cast rules after the merge

The Plugins page spec's configuration bodies take the view positionally
as master's fixture does, the companion and section specs read a slot
entry's injected face through a Pick of the members they assert instead
of a double assertion, and the no-unknown-casts baseline drops the
entries retired with the moved settings tests.
This commit is contained in:
Yichen Jiang committed 2026-09-21 17:13:17 +08:00
1 parent ecb66a3497
commit 873140cff3
12 files changed
+14 -26

No files matched your search

@@ -541,9 +541,9 @@ describe('PluginManagerPage', () => {
describe('configuration pages', () => {
const bodies: SlotBodies = {
'plugins.item:bash': ({ view }) => view === 'summary' ? 'Limits every command.' : <form aria-label="bash form" />,
'plugins.bundle.config:dsh-better-sidebar': ({ view }) => view === 'page' ? <form aria-label="sidebar form" /> : null,
'plugins.row.config:dsh-better-sidebar#sidebar': ({ view }) => view === 'summary' ? 'The sidebar row.' : <form aria-label="row form" />,
'plugins.item:bash': view => view === 'summary' ? 'Limits every command.' : <form aria-label="bash form" />,
'plugins.bundle.config:dsh-better-sidebar': view => view === 'page' ? <form aria-label="sidebar form" /> : null,
'plugins.row.config:dsh-better-sidebar#sidebar': view => view === 'summary' ? 'The sidebar row.' : <form aria-label="row form" />,
}
it('lists an official plugin after the official bundles with its summary, and opens its page', () => {
@@ -59,7 +59,7 @@ describe('ui-settings-agent-loop apply', () => {
expect(entry.options).toMatchObject({ id: 'agent-loop', order: 20 })
expect(resolveSlotLabel(entry.options.label)).toBe('Agent 循环')
expect(entry.locale).toBe(NS)
const face = (entry.inject as unknown as () => AgentLoopCardFace)()
const face = (entry.inject as () => Pick<AgentLoopCardFace, 'hooks'>)()
expect(Object.keys(face.hooks)).toEqual(['agentLoopCard'])
})
@@ -23,7 +23,7 @@ function field(text: string, rest: Partial<SettingsFieldState> = {}): SettingsFi
function renderCard(state: Partial<AgentLoopCardState> = {}, view: 'summary' | 'page' = 'page') {
const store = createSnapshotStore<AgentLoopCardState>({ ...settled, maxParallelToolCalls: field('10'), ...state })
const actions = { edit: vi.fn(), resetField: vi.fn(), save: vi.fn(), discard: vi.fn() }
const props = { ...actions, view, t, useAgentLoopCard: bindSnapshotSelector(store) } as unknown as AgentLoopCardProps
const props = { ...actions, view, t, useAgentLoopCard: bindSnapshotSelector(store) } as AgentLoopCardProps
render(<AgentLoopCard {...props} />)
return actions
}
@@ -59,7 +59,7 @@ describe('ui-settings-plugins apply', () => {
await ctx.plugin({ inject: [...inject], apply }).await()
const section = slots.entries('settings.section')[0]!
const sectionFace = (section.inject as unknown as () => PluginsSettingsSectionInjected)()
const sectionFace = (section.inject as () => Pick<PluginsSettingsSectionInjected, 'hooks'>)()
const initialTabs = sectionFace.hooks.tabs.getSnapshot()
expect(initialTabs).toEqual([])
expect(sectionFace.hooks.tabs.getSnapshot()).toBe(initialTabs)
@@ -18,7 +18,7 @@ function renderSection(rows: readonly PluginsSettingsTabEntry[]) {
renderSlot: (_name: string, _owner: unknown, options: { only?: string }) => (
<span>{options.only}</span>
),
} as unknown as PluginsSettingsSectionProps
} as PluginsSettingsSectionProps
render(<PluginsSettingsSection {...props} />)
}
@@ -66,7 +66,7 @@ describe('ui-settings-shell apply', () => {
expect(entry.options).toMatchObject({ id: 'shell', order: 10 })
expect(resolveSlotLabel(entry.options.label)).toBe('终端')
expect(entry.locale).toBe(NS)
const face = (entry.inject as unknown as () => ShellCardFace)()
const face = (entry.inject as () => Pick<ShellCardFace, 'hooks'>)()
expect(Object.keys(face.hooks)).toEqual(['shellCard'])
expect(face.hooks.shellCard.getSnapshot()).toMatchObject({ available: false, dirty: false })
})
@@ -25,7 +25,7 @@ function renderCard(state: Partial<ShellCardState> = {}, view: 'summary' | 'page
...settled, timeoutMs: field('60000'), maxOutputBytes: field('64000'), ...state,
})
const actions = { edit: vi.fn(), resetField: vi.fn(), save: vi.fn(), discard: vi.fn() }
const props = { ...actions, view, t, useShellCard: bindSnapshotSelector(store) } as unknown as ShellCardProps
const props = { ...actions, view, t, useShellCard: bindSnapshotSelector(store) } as ShellCardProps
render(<ShellCard {...props} />)
return actions
}
@@ -64,7 +64,7 @@ describe('ui-settings-subagent apply', () => {
expect(entry.options).toMatchObject({ id: 'subagent', order: 30 })
expect(resolveSlotLabel(entry.options.label)).toBe('Subagent')
expect(entry.locale).toBe(NS)
const face = (entry.inject as unknown as () => SubagentCardFace)()
const face = (entry.inject as () => Pick<SubagentCardFace, 'hooks'>)()
expect(Object.keys(face.hooks).sort()).toEqual(['subagentLimitsCard', 'subagentModelSelectionCard'])
})
@@ -66,7 +66,7 @@ function renderSubagent(
t,
useSubagentLimitsCard: bindSnapshotSelector(limits),
useSubagentModelSelectionCard: bindSnapshotSelector(models),
} as unknown as SubagentCardProps
} as SubagentCardProps
render(<SubagentCard {...props} />)
return { actions, limits, models }
}
@@ -65,7 +65,7 @@ describe('ui-settings-web-search apply', () => {
expect(entry.options).toMatchObject({ id: 'web-search', order: 40 })
expect(resolveSlotLabel(entry.options.label)).toBe('网页搜索')
expect(entry.locale).toBe(NS)
const face = (entry.inject as unknown as () => WebSearchCardFace)()
const face = (entry.inject as () => Pick<WebSearchCardFace, 'hooks'>)()
expect(Object.keys(face.hooks)).toEqual(['webSearchCard'])
})
@@ -36,7 +36,7 @@ describe('WebSearchCard', () => {
...state,
})
const actions = cardActions()
const props = { ...actions, view: 'page', t, useWebSearchCard: bindSnapshotSelector(store) } as unknown as WebSearchCardProps
const props = { ...actions, view: 'page', t, useWebSearchCard: bindSnapshotSelector(store) } as WebSearchCardProps
render(<WebSearchCard {...props} />)
return actions
}
@@ -45,7 +45,7 @@ describe('WebSearchCard', () => {
const store = createSnapshotStore<WebSearchCardState>({
...settled, baseURL: field(''), maxUses: field('5'), apiKey: field(''), apiKeyConfigured: false, apiKeyWritable: true,
})
const props = { ...cardActions(), view: 'summary', t, useWebSearchCard: bindSnapshotSelector(store) } as unknown as WebSearchCardProps
const props = { ...cardActions(), view: 'summary', t, useWebSearchCard: bindSnapshotSelector(store) } as WebSearchCardProps
render(<WebSearchCard {...props} />)
expect(document.body.textContent).toBe(en.description)
-12
View File
@@ -688,18 +688,6 @@
"79c53da50aa08004e201cebca842267ae2650a543b435a7906960f6492c2398b": 1,
"a3c1509d552d0102e118f3071a234002a5c83c30ca6923f8a87e9e3733ce0dcf": 1
},
"packages/client/ui-settings-plugins/tests/apply.client.spec.ts": {
"3d455f54ba188122f29085e9d462bebbca24c517057052f346229efd175e6e3c": 1
},
"packages/client/ui-settings-plugins/tests/section.client.spec.tsx": {
"0d8472724f1363e2891409f0a3a4add1cff1ca68b49e3c553457ad69deb9743c": 2,
"203a19d9e599f039376a58265a2e59a5350752ca21ed2502095b3bc73cd45c6a": 1,
"878e5d009eb310a1e5574351c795dfa691449b162d027f7639220075957a5b18": 1,
"9f2da941345134a519a3be6744a11f5e6a1fcaa70ab3ac6ca40f8ddec52e172f": 1,
"ab5c523f935fc83dfa5acb5919ea34b578739a4703cf30de5382aaba06250af7": 1,
"fc819a8f00497253d2231099c726434b4ed85f9677af7d287111e52c09f005a7": 1,
"fd37ca50cf574f86f8640694f4e2bc7466e97e9d54869402a08cceab69dee52c": 1
},
"packages/client/ui-settings/tests/schema.client.spec.ts": {
"0584be4cde4cd33049ef7c02e9d1562a30ec48ef2176f2f22b328b5be2903407": 1
},