test(stalker): await the first authenticated content request

The re-auth test kept failing on CI (3/3 attempts) with an undefined
token while passing locally. My earlier diagnosis — a sibling spec's
global /reset — was wrong: the failure survived the scoped-reset fix.

Real cause is a race in the test itself. `addFullStalkerPortal` only
awaits the route change, so on a slower runner the first authenticated
content request has not been recorded yet when the token is read; the
sibling test that passes happens to await `.category-item` first. Poll
for a content request carrying a token before capturing it.

The scoped-reset work stands on its own merits (cross-file resets were
a real hazard), it just was not what broke this test.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
4grayandClaude Fable 5 committed 2026-08-01 20:17:58 +02:00
1 parent 41cd41590a
commit a44f8135fa
1 file changed
+15
+15
View File
@@ -962,6 +962,21 @@ test.describe('@stalker full portal authentication', () => {
await addFullStalkerPortal(page, { mac: AUTH_REAUTH_MAC }); await addFullStalkerPortal(page, { mac: AUTH_REAUTH_MAC });
// `addFullStalkerPortal` only awaits the route change, and on a slow
// runner the first authenticated content request has not necessarily
// gone out by then — poll for it instead of reading the log once.
await expect
.poll(
() =>
requests.some(
(entry) =>
CONTENT_ACTIONS.includes(entry.action) &&
entry.token
),
{ timeout: 30_000 }
)
.toBe(true);
// The token the initial import authenticated with — recovery must end // The token the initial import authenticated with — recovery must end
// up on a DIFFERENT one, or nothing was actually re-negotiated. // up on a DIFFERENT one, or nothing was actually re-negotiated.
const tokenBeforeInvalidation = requests.find( const tokenBeforeInvalidation = requests.find(