From 873140cff3ed54c58d3925bddb772c44279b069a Mon Sep 17 00:00:00 2001 From: Yichen Jiang Date: Mon, 21 Sep 2026 17:13:17 +0800 Subject: [PATCH] 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. --- .../tests/components.client.spec.tsx | 6 +++--- .../tests/apply.client.spec.ts | 2 +- .../tests/card.client.spec.tsx | 2 +- .../ui-settings-plugins/tests/apply.client.spec.ts | 2 +- .../tests/section.client.spec.tsx | 2 +- .../ui-settings-shell/tests/apply.client.spec.ts | 2 +- .../ui-settings-shell/tests/card.client.spec.tsx | 2 +- .../ui-settings-subagent/tests/apply.client.spec.ts | 2 +- .../ui-settings-subagent/tests/card.client.spec.tsx | 2 +- .../tests/apply.client.spec.ts | 2 +- .../tests/card.client.spec.tsx | 4 ++-- scripts/no-unknown-casts.baseline.json | 12 ------------ 12 files changed, 14 insertions(+), 26 deletions(-) diff --git a/packages/client/ui-plugin-manager/tests/components.client.spec.tsx b/packages/client/ui-plugin-manager/tests/components.client.spec.tsx index 35594c89e0..a98b0bc3d3 100644 --- a/packages/client/ui-plugin-manager/tests/components.client.spec.tsx +++ b/packages/client/ui-plugin-manager/tests/components.client.spec.tsx @@ -541,9 +541,9 @@ describe('PluginManagerPage', () => { describe('configuration pages', () => { const bodies: SlotBodies = { - 'plugins.item:bash': ({ view }) => view === 'summary' ? 'Limits every command.' :
, - 'plugins.bundle.config:dsh-better-sidebar': ({ view }) => view === 'page' ? : null, - 'plugins.row.config:dsh-better-sidebar#sidebar': ({ view }) => view === 'summary' ? 'The sidebar row.' : , + 'plugins.item:bash': view => view === 'summary' ? 'Limits every command.' : , + 'plugins.bundle.config:dsh-better-sidebar': view => view === 'page' ? : null, + 'plugins.row.config:dsh-better-sidebar#sidebar': view => view === 'summary' ? 'The sidebar row.' : , } it('lists an official plugin after the official bundles with its summary, and opens its page', () => { diff --git a/packages/client/ui-settings-agent-loop/tests/apply.client.spec.ts b/packages/client/ui-settings-agent-loop/tests/apply.client.spec.ts index b822607711..744d62f3d4 100644 --- a/packages/client/ui-settings-agent-loop/tests/apply.client.spec.ts +++ b/packages/client/ui-settings-agent-loop/tests/apply.client.spec.ts @@ -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)() expect(Object.keys(face.hooks)).toEqual(['agentLoopCard']) }) diff --git a/packages/client/ui-settings-agent-loop/tests/card.client.spec.tsx b/packages/client/ui-settings-agent-loop/tests/card.client.spec.tsx index be2fd9a09a..e3287413d1 100644 --- a/packages/client/ui-settings-agent-loop/tests/card.client.spec.tsx +++ b/packages/client/ui-settings-agent-loop/tests/card.client.spec.tsx @@ -23,7 +23,7 @@ function field(text: string, rest: Partial = {}): SettingsFi function renderCard(state: Partial = {}, view: 'summary' | 'page' = 'page') { const store = createSnapshotStore({ ...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() return actions } diff --git a/packages/client/ui-settings-plugins/tests/apply.client.spec.ts b/packages/client/ui-settings-plugins/tests/apply.client.spec.ts index 7581245ddb..63ba773884 100644 --- a/packages/client/ui-settings-plugins/tests/apply.client.spec.ts +++ b/packages/client/ui-settings-plugins/tests/apply.client.spec.ts @@ -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)() const initialTabs = sectionFace.hooks.tabs.getSnapshot() expect(initialTabs).toEqual([]) expect(sectionFace.hooks.tabs.getSnapshot()).toBe(initialTabs) diff --git a/packages/client/ui-settings-plugins/tests/section.client.spec.tsx b/packages/client/ui-settings-plugins/tests/section.client.spec.tsx index 0907213a17..7b4f0001ef 100644 --- a/packages/client/ui-settings-plugins/tests/section.client.spec.tsx +++ b/packages/client/ui-settings-plugins/tests/section.client.spec.tsx @@ -18,7 +18,7 @@ function renderSection(rows: readonly PluginsSettingsTabEntry[]) { renderSlot: (_name: string, _owner: unknown, options: { only?: string }) => ( {options.only} ), - } as unknown as PluginsSettingsSectionProps + } as PluginsSettingsSectionProps render() } diff --git a/packages/client/ui-settings-shell/tests/apply.client.spec.ts b/packages/client/ui-settings-shell/tests/apply.client.spec.ts index 3bc0b93161..935336964a 100644 --- a/packages/client/ui-settings-shell/tests/apply.client.spec.ts +++ b/packages/client/ui-settings-shell/tests/apply.client.spec.ts @@ -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)() expect(Object.keys(face.hooks)).toEqual(['shellCard']) expect(face.hooks.shellCard.getSnapshot()).toMatchObject({ available: false, dirty: false }) }) diff --git a/packages/client/ui-settings-shell/tests/card.client.spec.tsx b/packages/client/ui-settings-shell/tests/card.client.spec.tsx index d789c28165..0570e65e2b 100644 --- a/packages/client/ui-settings-shell/tests/card.client.spec.tsx +++ b/packages/client/ui-settings-shell/tests/card.client.spec.tsx @@ -25,7 +25,7 @@ function renderCard(state: Partial = {}, 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() return actions } diff --git a/packages/client/ui-settings-subagent/tests/apply.client.spec.ts b/packages/client/ui-settings-subagent/tests/apply.client.spec.ts index edfe36b27e..d4d5b836b5 100644 --- a/packages/client/ui-settings-subagent/tests/apply.client.spec.ts +++ b/packages/client/ui-settings-subagent/tests/apply.client.spec.ts @@ -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)() expect(Object.keys(face.hooks).sort()).toEqual(['subagentLimitsCard', 'subagentModelSelectionCard']) }) diff --git a/packages/client/ui-settings-subagent/tests/card.client.spec.tsx b/packages/client/ui-settings-subagent/tests/card.client.spec.tsx index d0efaf23f8..6804ea9e91 100644 --- a/packages/client/ui-settings-subagent/tests/card.client.spec.tsx +++ b/packages/client/ui-settings-subagent/tests/card.client.spec.tsx @@ -66,7 +66,7 @@ function renderSubagent( t, useSubagentLimitsCard: bindSnapshotSelector(limits), useSubagentModelSelectionCard: bindSnapshotSelector(models), - } as unknown as SubagentCardProps + } as SubagentCardProps render() return { actions, limits, models } } diff --git a/packages/client/ui-settings-web-search/tests/apply.client.spec.ts b/packages/client/ui-settings-web-search/tests/apply.client.spec.ts index bdff8383fe..169ba04dfd 100644 --- a/packages/client/ui-settings-web-search/tests/apply.client.spec.ts +++ b/packages/client/ui-settings-web-search/tests/apply.client.spec.ts @@ -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)() expect(Object.keys(face.hooks)).toEqual(['webSearchCard']) }) diff --git a/packages/client/ui-settings-web-search/tests/card.client.spec.tsx b/packages/client/ui-settings-web-search/tests/card.client.spec.tsx index 7f0c480cf6..a1b36c73a8 100644 --- a/packages/client/ui-settings-web-search/tests/card.client.spec.tsx +++ b/packages/client/ui-settings-web-search/tests/card.client.spec.tsx @@ -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() return actions } @@ -45,7 +45,7 @@ describe('WebSearchCard', () => { const store = createSnapshotStore({ ...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() expect(document.body.textContent).toBe(en.description) diff --git a/scripts/no-unknown-casts.baseline.json b/scripts/no-unknown-casts.baseline.json index b274bbe4fe..11163ebaab 100644 --- a/scripts/no-unknown-casts.baseline.json +++ b/scripts/no-unknown-casts.baseline.json @@ -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 },