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(() =>