ReviewOS

also looking at this

stacks/bench-review

Close unauthenticated /api/requests CRUD, and make the session cookie HttpOnly

#77
Merged glennmichael123 wants to merge fix/request-autocrud-and-httponly into main
11 files +552 -57
tests/feature/ui.test.tsmodified+26-1
Changes to tests/feature/ui.test.ts
@@ -1,4 +1,29 @@
1import { expect, test } from 'bun:test'
1import { afterAll, beforeAll, expect, test } from 'bun:test'
2import { GlobalRegistrator } from '@happy-dom/global-registrator'
3
4/**
5 * DOM-dependent tests.
6 *
7 * The DOM is registered HERE rather than in `tests/setup.ts`, because
8 * `GlobalRegistrator.register()` swaps `Request`/`Response`/`Headers` for
9 * happy-dom's browser implementations, and a browser `Headers` silently drops
10 * `Set-Cookie` and `Cookie` (the Fetch spec calls them forbidden header names).
11 * Registering it globally therefore made `tests/unit/session-cookie.test.ts`
12 * unable to see the `HttpOnly` session cookie it exists to assert. See
13 * `tests/setup.ts` for the measurement.
14 *
15 * Bun runs test files in one process, so the registration is bracketed: any
16 * file that needs a DOM takes it for its own duration and hands the native
17 * globals back afterwards, instead of mutating the whole run.
18 */
19
20beforeAll(() => {
21 GlobalRegistrator.register()
22})
23
24afterAll(async () => {
25 await GlobalRegistrator.unregister()
26})
227
328test('dom test', () => {
429 document.body.innerHTML = `<button>My button</button>`