Something went wrong. Try again.
Monorepo for Tangled
Something went wrong. Try again.
Svelte
12345678910111213141516171819202122232425262728293031323334353637383940<script module lang="ts"> import { defineMeta } from "@storybook/addon-svelte-csf"; import { expect, fn, userEvent, waitFor, within } from "storybook/test"; import type { Did } from "@atcute/lexicons/syntax"; import type { AuthAccount } from "$lib/auth.svelte"; import Topbar from "$lib/components/shell/Topbar.svelte";
const user = { did: "did:plc:alice" as Did, handle: "alice.tangled.sh" }; const accounts: AuthAccount[] = [ { did: user.did, handle: user.handle, addedAt: 1 }, { did: "did:plc:bob" as Did, handle: "bob.tangled.sh", addedAt: 2 } ];
const { Story } = defineMeta({ title: "Shell/Topbar", component: Topbar, tags: ["autodocs"], args: { variant: "app", user } });</script>
<Story name="One account" args={{ accounts: [accounts[0]] }} />
<Story name="Signed out" args={{ variant: "marketing", user: null }} />
<Story name="Signed out app" args={{ user: null }} />
<Story name="Resolving session" args={{ user: null, loading: true }} />
<Story name="Switching account" args={{ accounts, onSwitchAccount: fn() }} play={async ({ canvasElement, args }) => { const canvas = within(canvasElement); await userEvent.click(canvas.getByRole("button", { name: /alice/i })); await userEvent.click(await canvas.findByRole("menuitem", { name: /bob/i })); await waitFor(() => expect(args.onSwitchAccount).toHaveBeenCalledWith("did:plc:bob")); }}/>