1import { Text } from "@alchemy.run/cloudflare-runtime/core/bindings";
2import * as Options from "@alchemy.run/cloudflare-test-tools/e2e/Options";
3import * as SvelteKit from "@alchemy.run/frontend-frameworks/sveltekit";
4
5// Read by the /api/widgets endpoint via `platform.env` — the point of this
6// fixture: even with `ssr = false` (pure SPA), +server.ts endpoints still run
7// server-side in the worker, with real bindings.
8export const FIXTURE_MESSAGE = "hello-from-sveltekit-spa-binding";
9
10export default Options.make({
11 // Typed factory form: map harness options onto SvelteKit options, then pin
12 // the dev port so parallel fixture runs don't collide.
13 framework: (options) => {
14 const base = SvelteKit.fromHarnessOptions(
15 options as SvelteKit.HarnessOptions,
16 );
17 return SvelteKit.layer({
18 ...base,
19 dev: { ...base.dev, port: 3108 },
20 });
21 },
22 target: {
23 cloudflare: {
24 worker: {
25 compatibilityDate: "2026-03-10",
26 compatibilityFlags: ["nodejs_compat"],
27 worker: {
28 name: "fixtures-sveltekit-spa",
29 bindings: [Text.local("FIXTURE_MESSAGE", FIXTURE_MESSAGE)],
30 assets: {
31 htmlHandling: "auto-trailing-slash",
32 // The SPA mode under test: drives the adapter's fallback-page
33 // generation (`builder.generateFallback` -> index.html) and must
34 // flow through to the deployed assets' not_found_handling.
35 notFoundHandling: "single-page-application",
36 runWorkerFirst: false,
37 },
38 },
39 },
40 preview: {
41 compatibilityDate: "2026-03-10",
42 compatibilityFlags: ["nodejs_compat"],
43 bindings: { FIXTURE_MESSAGE },
44 assets: {
45 binding: "ASSETS",
46 routerConfig: {
47 has_user_worker: true,
48 invoke_user_worker_ahead_of_assets: false,
49 },
50 assetConfig: {
51 html_handling: "auto-trailing-slash",
52 // The preview must honor the SPA fallback the adapter emitted:
53 // unmatched paths serve the generated index.html app shell.
54 not_found_handling: "single-page-application",
55 },
56 },
57 },
58 },
59 },
60});