窗口期渲染用例先等 invoke 发出,别让断言在命令未发出时就过
- chat-composer 的 does not report a finished turn 用例捕获 invoke 并先等它被调用,再断言窗口期不出现终态文案 - 写权限门是异步的:不等待时断言会在 invoke 之前通过、收尾的 pending[0]?.resolve 变成空操作,用例盖不住它声称覆盖的窗口
This commit is contained in:
@@ -471,7 +471,7 @@ export function registerChatComposerControlTests() {
|
||||
|
||||
it('does not report a finished turn while the host has not acknowledged the send yet', async () => {
|
||||
const pending: Array<{ resolve: (value: string) => void }> = [];
|
||||
const { surface } = await openDirectCodexSurface({
|
||||
const { invoke, surface } = await openDirectCodexSurface({
|
||||
chat_with_game_creator_direct_codex: () =>
|
||||
new Promise<string>((resolve) => {
|
||||
pending.push({ resolve });
|
||||
@@ -480,6 +480,15 @@ export function registerChatComposerControlTests() {
|
||||
const composer = within(surface).getByLabelText('陶泥儿对话内容');
|
||||
await submitDirectTurn(surface, composer, '窗口期的消息');
|
||||
|
||||
// 写权限门是异步的,先等命令真的发出去,否则下面的窗口期断言会在 invoke 还没发生时就
|
||||
// 通过、收尾的 `pending[0]?.resolve` 也变成空操作,用例根本没盖住它要盖的窗口。
|
||||
await waitFor(() => {
|
||||
expect(invoke).toHaveBeenCalledWith(
|
||||
'chat_with_game_creator_direct_codex',
|
||||
expectDirectTurnWithText('窗口期的消息'),
|
||||
);
|
||||
});
|
||||
|
||||
// 本地乐观气泡立刻可见;此刻原生既没回 turn.started,也没回显用户条目,
|
||||
// 这一轮属于「本地已发出、宿主未确认」,不得渲染成已结束。
|
||||
await waitFor(() => {
|
||||
|
||||
Reference in New Issue
Block a user