Skip to content

Commit

Permalink
feat(sitepage): add stories for the different menu actions
Browse files Browse the repository at this point in the history
  • Loading branch information
karrui committed Jul 16, 2024
1 parent 17bbe66 commit 9d9ddee
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const columns = [
header: () => <TableHeader>Actions</TableHeader>,
cell: ({ row }) => (
<ResourceTableMenu
title={row.original.name}
resourceId={row.original.id}
type={row.original.type}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ import type { ResourceTableData } from "./types"
import { MenuItem } from "~/components/Menu"

interface ResourceTableMenuProps {
title: ResourceTableData["name"]
resourceId: ResourceTableData["id"]
type: ResourceTableData["type"]
}

export const ResourceTableMenu = ({ type }: ResourceTableMenuProps) => {
export const ResourceTableMenu = ({ title, type }: ResourceTableMenuProps) => {
return (
<Menu isLazy size="sm">
<MenuButton
aria-label="Options"
aria-label={`Options for ${title}`}
as={IconButton}
colorScheme="neutral"
icon={<BiDotsHorizontalRounded />}
Expand Down
25 changes: 25 additions & 0 deletions apps/studio/src/stories/Page/SitePage.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Meta, StoryObj } from "@storybook/react"
import { userEvent, waitFor, within } from "@storybook/test"
import { meHandlers } from "tests/msw/handlers/me"
import { pageHandlers } from "tests/msw/handlers/page"

Expand All @@ -22,3 +23,27 @@ type Story = StoryObj<typeof meta>
export const Default: Story = {
args: {},
}

export const PageResourceMenu: Story = {
play: async ({ canvasElement }) => {
await waitFor(async () => {
const screen = within(canvasElement)
const pageMenuButton = screen.getByRole("button", {
name: "Options for Test Page 1",
})
await userEvent.click(pageMenuButton)
})
},
}

export const FolderResourceMenu: Story = {
play: async ({ canvasElement }) => {
await waitFor(async () => {
const screen = within(canvasElement)
const folderMenuButton = screen.getByRole("button", {
name: "Options for Test Folder 1",
})
await userEvent.click(folderMenuButton)
})
},
}

0 comments on commit 9d9ddee

Please sign in to comment.