This repository has no description
1<script lang="ts">
2 // story-only helper: injects a fake auth context so form stories can exercise
3 // a real (failing) submission without a live session. the fake agent's fetch
4 // handler always rejects, so putIssue/putComment land in the form's catch block.
5 import { setContext, type Snippet } from "svelte";
6 import { AUTH_KEY, type Auth } from "$lib/auth.svelte";
7
8 interface Props {
9 // message the fake agent rejects submissions with
10 failWith?: string;
11 children: Snippet;
12 }
13
14 let { failWith = "MockAuthProvider: network request failed, this error is intentional.", children }: Props = $props();
15
16 const agent = {
17 sub: "did:plc:alice",
18 handle: () => Promise.reject(new Error(failWith))
19 };
20
21 const auth = {
22 agent,
23 currentDid: "did:plc:alice",
24 currentUser: { did: "did:plc:alice", handle: "alice.pds.tngl.boltless.dev" }
25 } as unknown as Auth;
26
27 setContext(AUTH_KEY, auth);
28</script>
29
30{@render children()}