修复 CreatorPages 回关用例在并发负载下点击被吞导致的偶发失败
Project CI / AI game creator shell Rust crates (pull_request) Successful in 5m1s
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Successful in 6m48s
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Successful in 6m8s
Project CI / Frontend tests (pull_request) Successful in 2m39s
Project CI / Backend tests (pull_request) Successful in 7m54s
Project CI / AI game creator shell web tests (pull_request) Successful in 3m27s
Project CI / Repository checks (pull_request) Successful in 7m10s
Project CI / Native shell tests (pull_request) Successful in 9m41s

- 在「自己的粉丝支持回关和取消回关,移除须确认且只移除该行」用例中,先取到「回关」按钮并保留引用,不再取到后立即同步点击
- 新增等待该按钮 disabled 变为 false 再 fireEvent.click,避免关系 store 尚未 seed、按钮仍是 disabled 时 React 不派发 onClick 而把这次点击吞掉
- 补充简短中文注释,说明行首帧早于关系 store seed、必须等按钮可用再点
This commit is contained in:
2026-10-06 15:03:25 +08:00
parent 52c83cc2a1
commit 3b99da832f
+7 -2
View File
@@ -138,10 +138,15 @@ it('自己的粉丝支持回关和取消回关,移除须确认且只移除该
total: 1,
});
render(<CreatorConnectionsPage id="a" tab="followers" {...callbacks} />);
await screen.findByRole('button', { name: '回关' });
// 关系 store 的 seed 晚于行首帧,此时按钮仍是 disabled;React 不会对 disabled
// 元素派发 onClick,必须先等到按钮可用再点,否则这次点击会被直接吞掉。
const back = (await screen.findByRole('button', {
name: '回关',
})) as HTMLButtonElement;
await waitFor(() => expect(back.disabled).toBe(false));
api.write.mockResolvedValue({ relationship: following });
api.list.mockResolvedValue({ items: [row()], nextCursor: null, total: 1 });
fireEvent.click(screen.getByRole('button', { name: '回关' }));
fireEvent.click(back);
await screen.findByRole('button', { name: '取消关注' });
expect(api.write).toHaveBeenLastCalledWith('b', 'follow');
fireEvent.click(screen.getByRole('button', { name: '移除粉丝' }));