gui tests: title-bar-tools red on origin/main 2042123f4: the reload cuts off sideGwRead's /api/providers, counted as a page error
internal/gui/tests/title-bar-tools.test.cjs (added in 17557132c, #2625) is red on origin/main 2042123f4, run alone, in both engines.
- WebKit only (
BROWSER=webkit), two runs: 3 pass / 2 fail, then 0 pass / 3 fail before it was stopped. - At ee288bc65, both engines: 4 pass / 6 fail. Load average was about 300 during these runs.
Every failure is the test's errors list (line 148) holding the side gateway read that the page's reload cut off:
+ '900px library hooks: Fetch API cannot load http://magpie.test/api/providers due to access control checks.\n' +
+ ' at api (http://magpie.test/app.js:111:26)\n' +
+ ' at sideGwRead (http://magpie.test/app.js:23221:52)\n' +
+ ' at unknown (http://magpie.test/app.js:23324:55)'
+ ]
- []
sideGwRead runs 1.5s after start (app.js:23324), and its rejection is already ignored (() => {}). The test reloads the page after setting a localStorage key (line 107), and the reload cancels that read when it is still in flight. On a fast machine the read finishes before the reload. Under load it doesn't.
The test already means to skip this. Its pageerror handler (line 97) returns early for WebKit when e.message matches /^Fetch API cannot load .* due to access control checks/. These errors still reach the list, and e.stack begins with that exact text. So in these runs either e.message didn't match the pattern, or the failing runs were Chromium, which the handler doesn't skip (the run at ee288bc65 failed chromium en too). That still needs checking.
Possible fixes, either one: test the pattern against e.stack || e.message and skip it in both engines, or have the faked /api/providers answer before the reload.
Taking this, after the P5/P6 release now in CI. settings-proxy-auth.test.cjs:54 fails the same way on origin/main 5380114da (/magpie.test/api/providers due to access control checks, WebKit), so I'll cover both files.
Not reproduced yet. On origin/main 5380114da, load ~300: title-bar-tools with a pageerror logger before the WebKit filter, plus settings-proxy-auth, both engines at concurrency 2: no pageerror at all in 4 WebKit title-bar-tools languages and 5 WebKit settings-proxy-auth languages (all ok); the one red was chromium zh, a 5s page.goto of ?view=plugins. A standalone WebKit probe (a fetch cut off by reload) gives no pageerror when the rejection is handled, and Unhandled Promise Rejection: TypeError: Load failed when it isn't, so the "access control checks" form needs something more (Playwright's route fulfilling after the reload is the next thing to try). Still mine.
Still red on origin/main b69f8e96, with the file run alone (BROWSER=chromium and BROWSER=webkit, each node --test --test-concurrency=1 internal/gui/tests/title-bar-tools.test.cjs), Linux (Ubuntu 22.04, x86_64), Node 22.22.1, Playwright 1.62.1, outside graftcp, DISPLAY unset. One run per engine there and 3 per engine at ff6fdffd, red in every run. Two failures.
This issue's check (line 148), in WebKit only: zh, ja and en failed it in all 4 runs, zh-TW in 2. Each list comes from one width and page, a Plugins page in 13 of the 14. It holds /api/agents/cli, /api/plugins/agents, /api/agents/install, /api/update and /api/whatsnew each time. Once it also held /api/plugin-panels, /api/plugin-pages and /api/plugins/updates, and once, at 760px library rtk, /api/library/rtk, /api/library and this issue's /api/providers.
On the open question above: these were WebKit runs, so it is e.message that line 98's pattern misses. Playwright's WebKit page reports a console message of level error from JavaScript as a page error, and splits its text at the first colon: the error's name gets the text before it, e.message the text after it (playwright-core's _onConsoleMessage for WebKit pages and its splitErrorMessage: lib/server/webkit/wkPage.js and lib/utils/isomorphic/stackTrace.js in 1.58.2, both in lib/coreBundle.js in 1.62.1). Here the first colon is the one in http:, so e.message is /magpie.test/api/agents/cli due to access control checks., the form settings-proxy-auth printed above, and ^Fetch API cannot load can't match it. e.stack keeps the whole text. The pattern matches the start of all 76 entries in these lists, and none of them once split that way. One list, cut after its first entry:
not ok 1 - webkit zh: the title bar's tools never lie over where the reader is
location: 'internal/gui/tests/title-bar-tools.test.cjs:85:5'
error: |-
Expected values to be strictly deep-equal:
+ actual - expected
+ [
+ '760px plugins discover: Fetch API cannot load http://magpie.test/api/agents/cli due to access control checks.\n' +
+ ' at api (http://magpie.test/app.js:123:26)\n' +
+ ' at unknown (http://magpie.test/app.js:2400:24)\n' +
+ ' at loadCLIs (http://magpie.test/app.js:2410:5)\n' +
+ ' at load (http://magpie.test/app.js:4203:13)',
[...]
+ ]
- []
stack: |-
TestContext.<anonymous> (internal/gui/tests/title-bar-tools.test.cjs:148:16)
The second failure is at another assertion: de, in both engines and in every run. The wait for the Plugins head at line 108 runs out, and the head is found hidden each time. The error doesn't say at which width or Plugins tab. In Chromium de ends after about 13s, where the other four languages pass in 62 to 65s.
not ok 4 - chromium de: the title bar's tools never lie over where the reader is
location: 'internal/gui/tests/title-bar-tools.test.cjs:85:5'
error: |-
locator.waitFor: Timeout 5000ms exceeded.
Call log:
- waiting for locator('#view-plugins .pm-head') to be visible
14 × locator resolved to hidden <div class="lib-head pm-head">…</div>
stack: |-
TestContext.<anonymous> (internal/gui/tests/title-bar-tools.test.cjs:108:38)