Skip to content

Commit

Permalink
fix(storybook): Tidy up redundant unlabelled stories
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Apr 2, 2024
1 parent f995c01 commit bfe9634
Showing 1 changed file with 6 additions and 44 deletions.
50 changes: 6 additions & 44 deletions editor.planx.uk/src/components/Feedback/FeedbackForm.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type Story = StoryObj<typeof meta>;

export default meta;

export const EmptyLabelledForm: Story = {
export const EmptyForm: Story = {
args: {
inputs: [
{ id: "userContext", name: "userContext", label: "What were you doing?" },
Expand All @@ -24,19 +24,8 @@ export const EmptyLabelledForm: Story = {
},
};

export const EmptyUnlabelledForm: Story = {
args: {
inputs: [
{ id: "userComment", name: "userComment", label: "What's your comment?" },
],
handleSubmit: async (values) => {
console.log(values);
},
},
};

export const SuccessfulLabelledFormSubmit: Story = {
...EmptyLabelledForm,
export const SuccessfulFormSubmit: Story = {
...EmptyForm,
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);

Expand All @@ -57,8 +46,8 @@ export const SuccessfulLabelledFormSubmit: Story = {
},
};

export const MissingInputLabelledForm: Story = {
...EmptyLabelledForm,
export const MissingInputForm: Story = {
...EmptyForm,
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);

Expand All @@ -70,31 +59,4 @@ export const MissingInputLabelledForm: Story = {
const submitButton = canvas.getByRole("button", { name: "Send feedback" });
await userEvent.click(submitButton);
},
};

export const SuccessfulUnlabelledFormSubmit: Story = {
...EmptyUnlabelledForm,
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);

const commentInput = canvas.getByLabelText("Leave your feedback");
await userEvent.type(
commentInput,
"It said I own a house but it's actually a flat.",
{ delay: 100 },
);

const submitButton = canvas.getByRole("button", { name: "Send feedback" });
await userEvent.click(submitButton);
},
};

export const MissingInputUnlabelledFormSubmit: Story = {
...EmptyUnlabelledForm,
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);

const submitButton = canvas.getByRole("button", { name: "Send feedback" });
await userEvent.click(submitButton);
},
};
};

0 comments on commit bfe9634

Please sign in to comment.