From 2f9684765f44fdaecfa067963fa95ecc874ff0f9 Mon Sep 17 00:00:00 2001 From: Turtle Date: Fri, 20 Nov 2026 04:56:38 +0800 Subject: [PATCH] test(web): satisfy type-aware lint in drag specs Co-authored-by: liukx0205 <69756503+liukx0205@users.noreply.github.com> Co-authored-by: Yifffan <133629972+Yifffan@users.noreply.github.com> --- .../client/ui-subagent/tests/sidebar-chat.client.spec.tsx | 4 ++-- .../ui-workspace/tests/workspace-browser.client.spec.tsx | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/client/ui-subagent/tests/sidebar-chat.client.spec.tsx b/packages/client/ui-subagent/tests/sidebar-chat.client.spec.tsx index aadaf1e43c..8b49ecfb21 100644 --- a/packages/client/ui-subagent/tests/sidebar-chat.client.spec.tsx +++ b/packages/client/ui-subagent/tests/sidebar-chat.client.spec.tsx @@ -119,9 +119,9 @@ describe('Sidebar chat registration', () => { Object.assign(ctx, { uiWorkspace: { openWorkspace }, sidebarRight: { openResource, mounted: { getSnapshot: () => onScreen } }, - effect: (install: () => unknown) => { + effect: (install: () => (() => void) | undefined) => { const dispose = install() - if (typeof dispose === 'function') disposers.push(() => { dispose() }) + if (dispose !== undefined) disposers.push(dispose) return () => {} }, }), diff --git a/packages/client/ui-workspace/tests/workspace-browser.client.spec.tsx b/packages/client/ui-workspace/tests/workspace-browser.client.spec.tsx index a66555575d..499c48fc38 100644 --- a/packages/client/ui-workspace/tests/workspace-browser.client.spec.tsx +++ b/packages/client/ui-workspace/tests/workspace-browser.client.spec.tsx @@ -2469,9 +2469,10 @@ describe('WorkspaceBrowser', () => { }) fireEvent.click(screen.getByText('alpha')) const [one, two] = screen.getAllByRole('treeitem').slice(1) as [HTMLElement, HTMLElement] - two.getBoundingClientRect = () => ({ + const rect = () => ({ top: 150, bottom: 184, left: 0, right: 200, width: 200, height: 34, x: 0, y: 150, toJSON: () => ({}), }) + two.getBoundingClientRect = rect fireEvent.dragStart(one, { dataTransfer: dragData() }) fireDrag(two, 'dragOver', 180) dragEnd(one, 'copy') @@ -2481,7 +2482,7 @@ describe('WorkspaceBrowser', () => { fireEvent.click(screen.getByRole('menuitem', { name: '单列表' })) const flatOne = screen.getByText('one').closest('[role="treeitem"]') as HTMLElement const flatTwo = screen.getByText('two').closest('[role="treeitem"]') as HTMLElement - flatTwo.getBoundingClientRect = two.getBoundingClientRect + flatTwo.getBoundingClientRect = rect fireEvent.dragStart(flatOne, { dataTransfer: dragData() }) fireDrag(flatTwo, 'dragOver', 180) dragEnd(flatOne, 'copy')