|
| 1 | +import { action } from "@storybook/addon-actions"; |
| 2 | +import type { Meta, StoryObj } from "@storybook/react"; |
| 3 | +import { userEvent, within } from "@storybook/test"; |
| 4 | +import { |
| 5 | + MockOrganization, |
| 6 | + MockOrganization2, |
| 7 | + MockUser, |
| 8 | +} from "testHelpers/entities"; |
| 9 | +import { OrganizationAutocomplete } from "./OrganizationAutocomplete"; |
| 10 | + |
| 11 | +const meta: Meta<typeof OrganizationAutocomplete> = { |
| 12 | + title: "components/OrganizationAutocomplete", |
| 13 | + component: OrganizationAutocomplete, |
| 14 | + args: { |
| 15 | + value: null, |
| 16 | + onChange: action("Selected organization"), |
| 17 | + }, |
| 18 | +}; |
| 19 | + |
| 20 | +export default meta; |
| 21 | +type Story = StoryObj<typeof OrganizationAutocomplete>; |
| 22 | + |
| 23 | +export const ManyOrgs: Story = { |
| 24 | + parameters: { |
| 25 | + showOrganizations: true, |
| 26 | + user: MockUser, |
| 27 | + features: ["multiple_organizations"], |
| 28 | + permissions: { viewDeploymentValues: true }, |
| 29 | + queries: [ |
| 30 | + { |
| 31 | + key: ["organizations"], |
| 32 | + data: [MockOrganization, MockOrganization2], |
| 33 | + }, |
| 34 | + ], |
| 35 | + }, |
| 36 | + play: async ({ canvasElement }) => { |
| 37 | + const canvas = within(canvasElement); |
| 38 | + const button = canvas.getByRole("button"); |
| 39 | + await userEvent.click(button); |
| 40 | + }, |
| 41 | +}; |
| 42 | + |
| 43 | +export const OneOrg: Story = { |
| 44 | + parameters: { |
| 45 | + showOrganizations: true, |
| 46 | + user: MockUser, |
| 47 | + features: ["multiple_organizations"], |
| 48 | + permissions: { viewDeploymentValues: true }, |
| 49 | + queries: [ |
| 50 | + { |
| 51 | + key: ["organizations"], |
| 52 | + data: [MockOrganization], |
| 53 | + }, |
| 54 | + ], |
| 55 | + }, |
| 56 | + play: async ({ canvasElement }) => { |
| 57 | + const canvas = within(canvasElement); |
| 58 | + const button = canvas.getByRole("button"); |
| 59 | + await userEvent.click(button); |
| 60 | + }, |
| 61 | +}; |
0 commit comments