| 1 | # @fixtures/astro-static |
| 2 | |
| 3 | E2e fixture for `@alchemy.run/frontend-frameworks/astro` exercising the **fully-static path**: |
| 4 | a real `astro.config.mjs` with `output: "static"`, several prerendered pages, |
| 5 | a sitemap-ish nav linking every page, a `getStaticPaths` dynamic route, a |
| 6 | custom `404.astro`, a client-side island (bundled `<script>` counter), and |
| 7 | `public/` assets. |
| 8 | |
| 9 | **THE POINT:** a pure static Astro build should deploy **ASSETS-ONLY** — no |
| 10 | worker at all. `BuildOutput.serverModules` must be `undefined`/empty and every |
| 11 | request (pages, client JS, public assets, the 404 page) must be answered by |
| 12 | the asset layer. |
| 13 | |
| 14 | ## Status: ENABLED |
| 15 | |
| 16 | The assets-only static-output wave landed: the suite runs ungated |
| 17 | (`bun run test` calls `playwright test` directly). |
| 18 | |
| 19 | ## The assets-only seam |
| 20 | |
| 21 | What "assets-only" requires of each layer (mirroring `packages/frontend-frameworks/fixtures/static-website`, |
| 22 | the Vite assets-only fixture): |
| 23 | |
| 24 | - **Build (`packages/astro`)**: the inline overlay no longer pins `output`, |
| 25 | so the config file's `output: "static"` (astro's own default) is honored. |
| 26 | The integration records the resolved `buildOutput` at `astro:config:done`; |
| 27 | when it is `"static"` the cloudflare target's `finish` pass drops the SSR |
| 28 | entry astro bundled for prerendering (`serverModules: undefined`) and the |
| 29 | `clientDirectory` carries every prerendered page, `404.html` included. |
| 30 | - **Preview (live mode)**: miniflare requires a script even for assets-only |
| 31 | workers, so the harness (`CloudflareTarget.serve`) detects the module-less |
| 32 | `BuildOutput`, synthesizes a stub that 500s (any request reaching it is a |
| 33 | routing bug), and forces `routerConfig.has_user_worker: false` itself — |
| 34 | the fixture hand-rolls nothing. `assetConfig.not_found_handling: |
| 35 | "404-page"` serves the built `404.html` with status 404. |
| 36 | - **Dev**: `astro dev` renders on demand by design (no prerendering in dev); |
| 37 | the suite only asserts request-visible behavior there (pages, nav, island, |
| 38 | 404, public assets), not build-frozen HTML. |
| 39 | |
| 40 | ## What the suite asserts |
| 41 | |
| 42 | - prerendered pages served in both `live` and `dev` modes |
| 43 | - full-site navigation through the shared nav |
| 44 | - `getStaticPaths`-enumerated `/blog/[slug]` routes |
| 45 | - the client island hydrates (`#hydrated` flips, counter increments) |
| 46 | - `public/robots.txt` and the custom 404 page (status 404 + content) |
| 47 | - **live only**: two fetches of `/` return byte-identical HTML (build-frozen) |
| 48 | - **live only, the enablement target**: `dist/build.json` has NO server |
| 49 | modules |
| 50 | |
| 51 | ## Commands |
| 52 | |
| 53 | ```sh |
| 54 | bun run dev # astro dev (port 3107) |
| 55 | bun run build # astro build -> dist/ + dist/build.json |
| 56 | bun run preview # miniflare over dist/build.json (assets-only + synthesized stub) |
| 57 | bun run test # playwright e2e over dev + live |
| 58 | ``` |