fix(e2e): tolerate trailing slash in SERVER_ROOT_PATH login redirect (#29369)

The Next.js admin UI is exported with trailingSlash: true, so the proxy
serves /ui/login at /ui/login/index.html and 308s /ui/login → /ui/login/.
The waitForURL predicate used endsWith("/ui/login"), which never matched
the canonicalized URL and timed out after 15s.

This was masked until the build artifacts were regenerated against the
AuthContext fix: the prior bundles still hit the racy redirect path that
fired before proxyBaseUrl was populated, producing /ui/login (no prefix,
no proxy round-trip, no trailing slash) which fortuitously satisfied the
predicate. The first PR to ship the corrected bundle exposed the
assertion bug.

Switch the predicate to includes("/ui/login"); the prefix assertion below
still validates the SERVER_ROOT_PATH preservation that is the actual
contract under test.
This commit is contained in:
yuneng-jiang 2026-05-30 20:00:33 -07:00 committed by GitHub
parent 80cf50dedb
commit 54ed5a4eb5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -26,7 +26,7 @@ test("unauth redirect preserves SERVER_ROOT_PATH prefix", async ({ page }) => {
await page.goto(`http://localhost:4000${ROOT_PATH}/ui/?page=virtual-keys`);
await page.waitForURL((url) => url.pathname.endsWith("/ui/login"), { timeout: 15_000 });
await page.waitForURL((url) => url.pathname.includes("/ui/login"), { timeout: 15_000 });
expect(page.url()).toContain(`${ROOT_PATH}/ui/login`);
});