Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/sparkly-buckets-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

Maintanance: Added stories for Assign attribute value modals and configuration for mocking GraphQL responses in Storybook.
1 change: 1 addition & 0 deletions .storybook/vite.storybook.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default defineConfig({
"@dashboard": path.resolve(__dirname, "..", "./src"),
src: path.resolve(__dirname, "..", "./src"),
moment: path.resolve(__dirname, "..", "./node_modules/moment/min/moment-with-locales.js"),
"@storybookUtils": path.resolve(__dirname, "..", "./storybookUtils"),
},
},

Expand Down
22 changes: 22 additions & 0 deletions codegen-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,28 @@ const config: CodegenConfig = {
typesPath: "./types.generated",
},
},
"./src/graphql/fabbricaTypes.generated.ts": {
plugins: ["typescript"],
config: {
enumsAsTypes: true,
avoidOptionals: true,
nonOptionalTypename: true,
scalars: {
Day: "number",
Hour: "number",
Date: "string",
},
namingConvention: {
enumValues: "change-case-all#upperCase",
},
},
},
"./src/graphql/fabbrica.generated.ts": {
plugins: ["@mizdra/graphql-codegen-typescript-fabbrica"],
config: {
typesFile: "./fabbricaTypes.generated",
},
},
},
};

Expand Down
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export default tseslint.config(
},
}, // Disable rules for specific files
{
files: ["vite.config.js"],
files: ["vite.config.js", ".storybook/vite.storybook.config.js"],
languageOptions: {
globals: {
...globals.node,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
"@graphql-codegen/typescript-operations": "^2.5.13",
"@graphql-codegen/typescript-react-apollo": "^3.3.7",
"@graphql-eslint/eslint-plugin": "^4.4.0",
"@mizdra/graphql-codegen-typescript-fabbrica": "^0.6.1",
"@playwright/test": "1.56.1",
"@saleor/app-sdk": "1.7.0",
"@sentry/cli": "^2.58.2",
Expand Down
142 changes: 142 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import type { Meta, StoryObj } from "@storybook/react-vite";
import { CategoryFactory } from "@storybookUtils/AssignDialogShared/factories";
import { ComponentProps } from "react";
import { fn } from "storybook/test";

import AssignCategoryDialog from "./AssignCategoryDialog";

type Props = ComponentProps<typeof AssignCategoryDialog>;

const meta: Meta<typeof AssignCategoryDialog> = {
title: "Components/Dialogs/AssignCategoryDialog",
component: AssignCategoryDialog,
loaders: [async () => ({ categories: await CategoryFactory.buildList(8) })],
render: (args: Props, { loaded }: { loaded: { categories: Props["categories"] } }) => (
<AssignCategoryDialog {...args} categories={args.categories ?? loaded.categories} />
),
argTypes: {
confirmButtonState: {
control: "inline-radio",
options: ["default", "loading", "success", "error"],
},
onClose: { table: { disable: true } },
onFetch: { table: { disable: true } },
onFetchMore: { table: { disable: true } },
onSubmit: { table: { disable: true } },
categories: { table: { disable: true } },
labels: { table: { disable: true } },
},
args: {
open: true,
loading: false,
hasMore: false,
confirmButtonState: "default",
onClose: fn(),
onFetch: fn(),
onFetchMore: fn(),
onSubmit: fn(),
},
};

export default meta;
type Story = StoryObj<typeof AssignCategoryDialog>;

export const Default: Story = {};

export const SingleSelection: Story = {
args: { selectionMode: "single" },
};

export const Loading: Story = {
args: { loading: true, categories: [] },
};

export const Empty: Story = {
args: { categories: [] },
};

export const HasMore: Story = {
args: { hasMore: true },
};
Loading
Loading