chadtmiller.com/group-host
atmosphere group host
0
0
The e2e flows wait for a console page to hydrate before using it
docs/development.md+5−2
| @@ -79,8 +79,11 @@ as the console, as it does a deployment's group addresses; each front | ||
passes the name asked on as `X-Forwarded-Host`, which a site's OAuth | ||
client is named for (the PDS refuses a client under `.test`). Chromium | ||
comes with `cd harness && npx playwright install chromium`, and is told | ||
that every name under `group-host.internal` is this machine. A failed | ||
flow leaves its trace and a picture under `target/e2e/results`. | ||
that every name under `group-host.internal` is this machine. Each flow's | ||
page waits, after going to a console page, until it has hydrated (the | ||
root layout sets `data-hydrated` on `<html>`), as a field filled before | ||
then is put back as it does. A failed flow leaves its trace and a | ||
picture under `target/e2e/results`. | ||
| ||
## Looking at the console | ||
| ||
harness/e2e/flows.spec.mjs+3−0
| @@ -11,6 +11,7 @@ import { | ||
McpClient, | ||
approve, | ||
didKey, | ||
hydrating, | ||
joins, | ||
signIn, | ||
signInDialog, | ||
| @@ -30,6 +31,8 @@ let bob; | ||
test.beforeAll(async ({ browser }) => { | ||
page = await browser.newPage(); | ||
bob = await (await browser.newContext()).newPage(); | ||
hydrating(page); | ||
hydrating(bob); | ||
await suggests(page.context()); | ||
await suggests(bob.context()); | ||
}); | ||
harness/e2e/pages.mjs+13−0
| @@ -10,6 +10,19 @@ export const world = JSON.parse(process.env.E2E_WORLD); | ||
export const who = Object.fromEntries(world.accounts.map((a) => [a.handle.split('.')[0], a])); | ||
export const url = (path) => world.base + path; | ||
| ||
/// Has `page.goto` to a console page wait until the page answers in the | ||
/// browser (`data-hydrated`, which its root layout sets), so that what a | ||
/// flow types or picks then is not put back as the page hydrates. | ||
export const hydrating = (page) => { | ||
const go = page.goto.bind(page); | ||
page.goto = async (to, options) => { | ||
const res = await go(to, options); | ||
if (new URL(page.url()).origin === new URL(world.base).origin) | ||
await page.locator('html[data-hydrated]').waitFor({ state: 'attached' }); | ||
return res; | ||
}; | ||
}; | ||
| ||
/// Signs in as `name` on the PDS's own page `page` has come to, and | ||
/// approves what was asked. | ||
export const approve = async (page, name) => { | ||
web/src/routes/+layout.svelte+6−0
| @@ -4,7 +4,13 @@ | ||
import SiteFooter from '#lib/organisms/SiteFooter.svelte'; | ||
import LeaveGuard from '#lib/molecules/LeaveGuard.svelte'; | ||
import { page } from '$app/state'; | ||
import { onMount } from 'svelte'; | ||
let { data, children } = $props(); | ||
// The page answers in the browser from here: what is typed or picked | ||
// before then may be put back as it hydrates. The e2e flows wait for it. | ||
onMount(() => { | ||
document.documentElement.dataset.hydrated = ''; | ||
}); | ||
</script> | ||
| ||
<SiteHeader | ||