From 702ac12f18e6222cfdd194fdc1c05b8cb072db1d Mon Sep 17 00:00:00 2001 From: Suzumiya Date: Wed, 7 Oct 2026 13:43:12 +0800 Subject: [PATCH] =?UTF-8?q?test=EF=BC=9A=E6=94=B9=E5=90=8D=E6=96=AD?= =?UTF-8?q?=E8=A8=80=E7=B2=BE=E7=A1=AE=E5=88=B0=E6=8C=89=E9=92=AE/?= =?UTF-8?q?=E6=96=87=E6=A1=88=E8=8A=82=E7=82=B9=EF=BC=88=E5=8E=BB=E6=8E=89?= =?UTF-8?q?=E5=85=A8=E9=A1=B5=20not.toContain('Fork')=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GameDistributionPages.test.tsx | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/components/game-distribution/GameDistributionPages.test.tsx b/src/components/game-distribution/GameDistributionPages.test.tsx index d7e555eb3..484400289 100644 --- a/src/components/game-distribution/GameDistributionPages.test.tsx +++ b/src/components/game-distribution/GameDistributionPages.test.tsx @@ -3200,8 +3200,16 @@ describe('GameLineagePage 可视化与交互', () => { expect(outlineCss).toMatch( /\.lineage-outline__action--co-create \{[\s\S]{0,200}?--platform-button-primary-solid/u, ); - // 全树的 Fork 旧文案在两种形态里都已不存在(信息面板的「开始共创此版本」不在树节点上)。 - expect(outline.textContent).not.toContain('Fork'); + // 动作名用**精确**断言(不扫全页文本):大纲行里恰好这两个可见名,且行内没有任何以 Fork + // 命名的可交互元素。 + expect( + within(actions as HTMLElement) + .getAllByRole('button') + .map((button) => button.textContent), + ).toEqual(['打开作品', '开始共创']); + expect( + within(actions as HTMLElement).queryByRole('button', { name: /Fork/u }), + ).toBeNull(); }); it('节点是真实 DOM 卡片:主体点击=选中、标题/打开作品=进详情、当前作品有标记且父在上子在下', async () => { @@ -3740,8 +3748,9 @@ describe('GameLineagePage 筛选器 / 主干线 / 信息面板(文档对齐) expect( within(panel).getByRole('button', { name: '开始共创此版本' }), ).toBeTruthy(); - // 面板内不得再把该动作叫 Fork(与按钮可见名一致)。 - expect(panel.textContent).not.toContain('Fork'); + // 动作名精确到**按钮**(不扫全页文本):面板里没有任何以 Fork 命名的可交互元素, + // 可见名就是上面钉住的那一个。 + expect(within(panel).queryByRole('button', { name: /Fork/u })).toBeNull(); fireEvent.click( within(panel).getByRole('button', { name: '开始共创此版本' }), ); @@ -3857,8 +3866,8 @@ describe('GameLineagePage 筛选器 / 主干线 / 信息面板(文档对齐) expect( within(sheet).getByRole('button', { name: '开始共创此版本' }), ).toBeTruthy(); - // 窄屏 bottom sheet 与桌面浮层同一组件:同样不得再出现 Fork 动作名。 - expect(sheet.textContent).not.toContain('Fork'); + // 窄屏 bottom sheet 与桌面浮层同一组件:动作名同样精确到按钮(不扫全页文本)。 + expect(within(sheet).queryByRole('button', { name: /Fork/u })).toBeNull(); // 遮罩点击关闭。 fireEvent.click(screen.getByLabelText('关闭信息面板')); await waitFor(() =>