This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

core / web / src / lib / components / repo / RepoCrumbs.stories.svelte
1.9 kB 59 lines
1<script module lang="ts"> 2 import { defineMeta, type StoryContext } from "@storybook/addon-svelte-csf"; 3 import { expect } from "storybook/test"; 4 import RepoCrumbs from "./RepoCrumbs.svelte"; 5 6 type PlayContext = Pick<StoryContext<Record<string, unknown>>, "canvas">; 7 8 const nestedPath = async ({ canvas }: PlayContext) => { 9 await expect(canvas.getByRole("link", { name: "tangled" })).toHaveAttribute( 10 "href", 11 "/dawn/tangled/tree/main" 12 ); 13 await expect(canvas.getByRole("link", { name: "web" })).toHaveAttribute( 14 "href", 15 "/dawn/tangled/tree/main/web" 16 ); 17 await expect(canvas.getByRole("link", { name: "src" })).toHaveAttribute( 18 "href", 19 "/dawn/tangled/tree/main/web/src" 20 ); 21 const current = canvas.getByText("lib"); 22 await expect(current).toHaveAttribute("aria-current", "page"); 23 await expect(canvas.queryByRole("link", { name: "lib" })).toBeNull(); 24 }; 25 26 const rootIsCurrent = async ({ canvas }: PlayContext) => { 27 const current = canvas.getByText("tangled"); 28 await expect(current).toHaveAttribute("aria-current", "page"); 29 await expect(canvas.queryByRole("link")).toBeNull(); 30 }; 31 32 const encodesSegments = async ({ canvas }: PlayContext) => { 33 await expect(canvas.getByRole("link", { name: "what#next?" })).toHaveAttribute( 34 "href", 35 "/dawn/tangled/tree/main/what%23next%3F" 36 ); 37 await expect(canvas.getByText("100%.md")).toHaveAttribute("aria-current", "page"); 38 }; 39 40 const { Story } = defineMeta({ 41 title: "Repo/RepoCrumbs", 42 component: RepoCrumbs, 43 tags: ["autodocs"], 44 args: { 45 ownerHandle: "dawn", 46 repoName: "tangled", 47 ref: "main", 48 path: "web/src/lib" 49 } 50 }); 51</script> 52 53<Story name="Nested path" play={nestedPath} /> 54<Story name="Repository root" args={{ path: "" }} play={rootIsCurrent} /> 55<Story 56 name="Segments needing encoding" 57 args={{ path: "what#next?/100%.md" }} 58 play={encodesSegments} 59/>