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 / BranchTable.stories.svelte
1.8 kB 53 lines
1<script module lang="ts"> 2 import { defineMeta, type StoryContext } from "@storybook/addon-svelte-csf"; 3 import { expect } from "storybook/test"; 4 import BranchTable from "./BranchTable.svelte"; 5 import type { BranchSummary } from "./types"; 6 7 const branches: BranchSummary[] = [ 8 { 9 name: "main", 10 hash: "0123456789abcdef0123456789abcdef01234567", 11 when: "2026-07-28T09:00:00Z", 12 isDefault: true, 13 message: "merge pull request #42\n\na longer body nobody reads" 14 }, 15 { 16 name: "feature/storybook", 17 hash: "abcdef0123456789abcdef0123456789abcdef01", 18 when: "2026-07-27T09:00:00Z", 19 isDefault: false, 20 message: "add stories for everything" 21 } 22 ]; 23 24 type PlayContext = Pick<StoryContext<Record<string, unknown>>, "canvas">; 25 26 const rowsLinkOut = async ({ canvas }: PlayContext) => { 27 const treeLinks = canvas.getAllByRole("link", { name: "main" }); 28 await expect(treeLinks[0]).toHaveAttribute("href", "/dawn/tangled/tree/main"); 29 const hashLinks = canvas.getAllByRole("link", { name: "01234567" }); 30 await expect(hashLinks[0]).toHaveAttribute("href", "/dawn/tangled/commits/main"); 31 await expect(canvas.getByText("merge pull request #42")).toBeInTheDocument(); 32 await expect(canvas.queryByText(/a longer body/)).toBeNull(); 33 await expect(canvas.getAllByText("Default")).toHaveLength(2); 34 }; 35 36 const empty = async ({ canvas }: PlayContext) => { 37 await expect(canvas.getByText("This repository has no branches.")).toBeVisible(); 38 }; 39 40 const { Story } = defineMeta({ 41 title: "Repo/BranchTable", 42 component: BranchTable, 43 tags: ["autodocs"], 44 args: { 45 ownerHandle: "dawn", 46 repoName: "tangled", 47 branches 48 } 49 }); 50</script> 51 52<Story name="Branches" play={rowsLinkOut} /> 53<Story name="Empty" args={{ branches: [] }} play={empty} />