From d989c7b518ba83e2cf012e452c785438635fc0f4 Mon Sep 17 00:00:00 2001 From: wangtiance Date: Fri, 20 Nov 2026 10:06:13 +0800 Subject: [PATCH] [test] providers: stabilize capability discovery browser clock ## summary - Pause the browser clock with transport headroom and align its wall time with the HTTP fixture before requesting capability observations. - Freeze before the paused-service reply to preserve its expiry checks and bilingual presentations. - Record the nightly failure evidence and clock-control lesson. --- docs/development/lessons.md | 6 ++++++ tests/browser/capability_discovery.mjs | 12 ++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/docs/development/lessons.md b/docs/development/lessons.md index f4abe2049..173ff927a 100644 --- a/docs/development/lessons.md +++ b/docs/development/lessons.md @@ -48,6 +48,12 @@ When work exposes a consequential risk or a recurring problem, add a lesson or u - **Fixture-mode follow-up:** [PR #266 review](https://github.com/ThinkFlowLab/OpenDirector/pull/266#issuecomment-6906025718) found browser workflows passing with local HTTP-generation fixtures but failing before business assertions under nightly's generic provider. Declare the required fixture modes in the manifest and check the running API and web proxy before executing each fixture lane. Reproduce the workflow's service commands and script grouping; separately correct local startup commands do not validate CI wiring. - **Save-observation follow-up:** [Issue #300](https://github.com/ThinkFlowLab/OpenDirector/issues/300) reproduced a stale saved label satisfying a browser wait before the edited text binding was committed. `asset.writeText` had succeeded, but the `creation.batch` containing `canvas.materialize` was still in flight; its later applied receipt installed the binding and the content was `AB`. Wait for the specific persisted binding, settings or position before asserting a save, retain the content check, and bound and release test gates even on failure. A visible saved label alone does not identify which edit was acknowledged. +## Browser clock pauses must precede short-lived observations + +- **Trigger:** Freezing browser time to inspect a short-lived response in both languages. +- **Evidence:** [Nightly run 44645615189](https://github.com/ThinkFlowLab/OpenDirector/actions/runs/44645615189/job/135987292433) failed at `capability_discovery.mjs:517`: `pauseAt(new Date())` targeted a time already behind the running browser clock. +- **Check:** Pause at a future time with command-transport headroom, realign the paused wall clock with the HTTP fixture, and only then request the observation. Advancing to the pause target after receiving it can expire it. Keep explicit expiry assertions and exercise the production preview; a passing rerun alone does not explain the original failure. + ## Native permission plans are not committed permissions - **Trigger:** Retrying an ACL read/modify/write or rolling back failed initialization. diff --git a/tests/browser/capability_discovery.mjs b/tests/browser/capability_discovery.mjs index 554f6f057..6db4d8f52 100644 --- a/tests/browser/capability_discovery.mjs +++ b/tests/browser/capability_discovery.mjs @@ -514,7 +514,13 @@ try { // Error observations last two seconds. Hold browser time so both screenshots // inspect the same response, without issuing another check on a locale change. await page.clock.install(); - await page.clock.pauseAt(new Date()); + async function pauseCapabilityClock() { + // pauseAt advances a running clock. Leave room for command transport, then + // align the paused wall clock with the HTTP fixture before its next reply. + await page.clock.pauseAt(new Date(Date.now() + 60_000)); + await page.clock.setSystemTime(new Date()); + } + await pauseCapabilityClock(); for (const [state, expected] of [ [ "stale", @@ -593,6 +599,9 @@ try { await page.clock.setSystemTime(new Date()); delay = 400; mode = "paused"; + // Freeze before the response: advancing to pauseAt after receiving it would + // expire the very observation whose two language presentations we inspect. + await pauseCapabilityClock(); await draft.getByRole("button", { name: "Retry", exact: true }).click(); assert.equal( await draft.getByText("Checking…", { exact: true }).count(), @@ -607,7 +616,6 @@ try { 1, ); // Clock control lets each language capture the same unexpired observation. - await page.clock.pauseAt(new Date()); await presentInBothLanguages("paused", { "en-US": "Service paused", "zh-CN": "服务已暂停",