From 5dc1009c8dfb2e926c4f532f3a92508f12fdb359 Mon Sep 17 00:00:00 2001 From: yudshj Date: Thu, 19 Nov 2026 12:43:54 +0800 Subject: [PATCH] Synchronize history paging and Node cancellation tests --- apps/web/tests/stats-paged-history.e2e.ts | 4 ++-- .../ptc-runtime/ptc-runtime-node/tests/runtime.spec.ts | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/apps/web/tests/stats-paged-history.e2e.ts b/apps/web/tests/stats-paged-history.e2e.ts index 27c494e4aa..f522de88bf 100644 --- a/apps/web/tests/stats-paged-history.e2e.ts +++ b/apps/web/tests/stats-paged-history.e2e.ts @@ -16,7 +16,7 @@ import { assertFixtureInventory, captureStableAria, compareOrRefreshGolden, launchWebScaffold, seedSession, watchConsole, webSnapshotMode, type WebScaffold, } from './scaffold.ts' -import { newEnglishPage, saveFailureShot } from './support.ts' +import { loadEarlierChatPage, newEnglishPage, saveFailureShot } from './support.ts' const SNAPSHOT_DIR = fileURLToPath(new URL('./expected/stats-paged-history', import.meta.url)) const UI_EXPECTED = fileURLToPath(new URL('./expected/stats-paged-history/ui.expected.md', import.meta.url)) @@ -127,7 +127,7 @@ describe('web e2e: whole-session stats survive history paging', () => { // 加载更早: prepending the older page must not move ANY strip figure — // counts, wall times, or token groups. - await page.getByRole('button', { name: 'Load earlier' }).click() + await loadEarlierChatPage(page) await expect.poll(() => page.getByText('m1', { exact: true }).count(), { timeout: 10_000 }).toBe(1) const history = page.locator('[data-chat-history]') await expect.poll(() => history.getAttribute('data-chat-history'), { timeout: 10_000 }).toBe('idle') diff --git a/packages/ptc-runtime/ptc-runtime-node/tests/runtime.spec.ts b/packages/ptc-runtime/ptc-runtime-node/tests/runtime.spec.ts index 778a70045f..9c9a061901 100644 --- a/packages/ptc-runtime/ptc-runtime-node/tests/runtime.spec.ts +++ b/packages/ptc-runtime/ptc-runtime-node/tests/runtime.spec.ts @@ -210,8 +210,14 @@ describe('Node program process', () => { const { run } = await setup() const entered = Promise.withResolvers() const controller = new AbortController() - const active = run({ ...timing, program: 'void tools.enter({}); for (;;) {}', signal: controller.signal, bindings: bindings({ enter: async () => { entered.resolve(undefined); return null } }) }) - await entered.promise + const active = run({ + ...timing, + program: 'await tools.enter({}); for (;;) {}', + signal: controller.signal, + bindings: bindings({ enter: async () => { entered.resolve(undefined); return null } }), + }) + const earlyResult = await Promise.race([entered.promise, active]) + expect(earlyResult).toBeUndefined() controller.abort('stop') expect((await active).error).toEqual({ kind: 'abort', message: 'stop' }) })