diff --git a/furniture-3d-system/src/app/intake/IntakeClient.test.tsx b/furniture-3d-system/src/app/intake/IntakeClient.test.tsx index 20a1b0b8..80986792 100644 --- a/furniture-3d-system/src/app/intake/IntakeClient.test.tsx +++ b/furniture-3d-system/src/app/intake/IntakeClient.test.tsx @@ -3284,7 +3284,7 @@ describe('IntakeClient', () => { expect(screen.queryByTestId('embedded-non-integrated-detail')).not.toBeInTheDocument() }) - it('opens a separate workspace tab each time product edit is clicked', async () => { + it('reuses the existing workspace tab when product edit is clicked again', async () => { const actor = userEvent.setup() replaceNonIntegratedProducts([createNonIntegratedProduct()]) @@ -3296,11 +3296,11 @@ describe('IntakeClient', () => { await actor.click(screen.getByRole('button', { name: '修改' })) expect(screen.getAllByRole('tab', { name: 'DNZ0001产品开发明细' })).toHaveLength( - 2, + 1, ) }) - it('opens a copied product tab even when the source product already has the max tabs', async () => { + it('opens a copied product tab when the source product page is already open', async () => { const actor = userEvent.setup() const [sourceBrand, targetBrand] = Object.keys(NON_INTEGRATED_BRAND_PREFIX_MAP) const expectedSpu = `${NON_INTEGRATED_BRAND_PREFIX_MAP[targetBrand]}SZ0230` @@ -3332,7 +3332,7 @@ describe('IntakeClient', () => { const beforeCopyTabs = screen.getAllByRole('tab') expect( beforeCopyTabs.filter((tab) => tab.textContent?.startsWith('SZ0230')), - ).toHaveLength(2) + ).toHaveLength(1) const listRow = screen.getByText('SZ0230').closest('tr') expect(listRow).not.toBeNull() @@ -3349,8 +3349,8 @@ describe('IntakeClient', () => { }) const tabs = screen.getAllByRole('tab') - expect(tabs).toHaveLength(4) - expect(tabs.filter((tab) => tab.textContent?.startsWith('SZ0230'))).toHaveLength(2) + expect(tabs).toHaveLength(3) + expect(tabs.filter((tab) => tab.textContent?.startsWith('SZ0230'))).toHaveLength(1) expect(tabs.some((tab) => tab.textContent?.includes(expectedSpu))).toBe(true) expect(push).not.toHaveBeenCalled() }) diff --git a/furniture-3d-system/src/app/intake/intakeWorkspaceTabUtils.test.ts b/furniture-3d-system/src/app/intake/intakeWorkspaceTabUtils.test.ts index b8986246..bd24d200 100644 --- a/furniture-3d-system/src/app/intake/intakeWorkspaceTabUtils.test.ts +++ b/furniture-3d-system/src/app/intake/intakeWorkspaceTabUtils.test.ts @@ -28,3 +28,23 @@ describe("work-record workspace tabs", () => { expect(result.activeTab).toEqual(existing); }); }); + +describe("single-page workspace tabs", () => { + it("activates the existing tab instead of opening the same page twice", () => { + const existing: IntakeWorkspaceTab = { + kind: "pendingEntry", + id: "pending-entry:nonIntegrated:1", + label: "产品开发明细", + entryTab: "nonIntegrated", + }; + const incoming: IntakeWorkspaceTab = { + ...existing, + id: "pending-entry:nonIntegrated:2", + }; + + const result = resolveWorkspaceTabsForOpen([existing], incoming); + + expect(result.tabs).toEqual([existing]); + expect(result.activeTab).toEqual(existing); + }); +}); diff --git a/furniture-3d-system/src/app/intake/intakeWorkspaceTabUtils.ts b/furniture-3d-system/src/app/intake/intakeWorkspaceTabUtils.ts index d8b7de0a..463af698 100644 --- a/furniture-3d-system/src/app/intake/intakeWorkspaceTabUtils.ts +++ b/furniture-3d-system/src/app/intake/intakeWorkspaceTabUtils.ts @@ -1,6 +1,6 @@ import type { IntakeWorkspaceTab } from "@/app/intake/intakeWorkspaceTypes"; -const MAX_WORKSPACE_TABS_PER_PAGE = 2; +const MAX_WORKSPACE_TABS_PER_PAGE = 1; function readWorkspaceTabSequence(tabId: string) { const maybeSequence = Number(tabId.split(":").at(-1));