Files
hanzo.ai/e2e/gates/crash.spec.ts
zeekay 0ad0035eec Call useSearchParams before the signed-in early return, point IAM at api.hanzo.ai, and stop a publish that has not typechecked and linted
The app's root read the search params only once a session had settled, so the render
that found one more hook than the last threw React #310 and drew the crash page.
deploy.yml now typechecks and lints before it builds, and crash.spec.ts settles a
session late and fails on a hooks error.

Claude-Session: https://claude.ai/code/session_01HvACxex9ZZTzJCCHgirsGy
2026-10-06 18:29:08 -07:00

36 lines
1.3 KiB
TypeScript

import { expect, test } from '@playwright/test'
import { serveExport } from './export'
import { signIn } from '../session'
/**
* A MEMBER'S `/` NEVER DRAWS THE CRASH PAGE.
*
* The session settles after the page paints: first the SDK is loading, then it
* is signed in. A component that calls a hook only on the second render throws
* React #310 and the whole site reads "Something went wrong". So userinfo is
* answered late, and the page must reach the app with no page error.
*/
let base: string
let stop: () => Promise<void>
test.beforeAll(async () => {
const served = await serveExport()
base = served.url
stop = served.close
})
test.afterAll(async () => stop())
test('a session that settles late does not crash the site', async ({ page }) => {
const errors: string[] = []
page.on('pageerror', (e) => errors.push(e.message))
await signIn(page)
await page.route('**/v1/iam/oauth/userinfo', async (route) => {
await new Promise((r) => setTimeout(r, 800))
await route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ sub: 'gate', name: 'gate', email: '[email protected]' }) })
})
await page.goto(base + '/')
await page.waitForTimeout(2500)
await expect(page.getByText('Something went wrong')).toHaveCount(0)
expect(errors.filter((m) => /Minified React error|Rendered (more|fewer) hooks/.test(m))).toEqual([])
})