From 9d41f9226e3d979ef62e7f5f4a60cda3fa61a8b1 Mon Sep 17 00:00:00 2001 From: divya jindel Date: Thu, 7 May 2026 14:57:58 +0100 Subject: [PATCH] test(step-flow): refine testing suite --- .../step-flow/step-flow-test.stories.tsx | 222 +++++++++++- src/components/step-flow/step-flow.pw.tsx | 326 +----------------- .../step-flow/step-flow.stories.tsx | 5 +- 3 files changed, 228 insertions(+), 325 deletions(-) diff --git a/src/components/step-flow/step-flow-test.stories.tsx b/src/components/step-flow/step-flow-test.stories.tsx index fd63ec16ab..6914a8db19 100644 --- a/src/components/step-flow/step-flow-test.stories.tsx +++ b/src/components/step-flow/step-flow-test.stories.tsx @@ -1,11 +1,27 @@ -import React from "react"; +import React, { useState, useRef } from "react"; +import Button from "../button"; +import Form from "../form"; +import Dialog from "../dialog"; import Typography from "../typography"; -import { StepFlow, StepFlowProps } from "."; +import Textarea from "../textarea"; +import Box from "../box"; +import Icon from "../icon"; +import Image from "../image"; +import pointSvg from "../../../.assets/point.svg"; +import { + StepFlow, + StepFlowTitle, + StepFlowHandle, + Steps, + StepFlowProps, +} from "."; +import { StoryFn } from "@storybook/react"; export default { title: "Step Flow/Test", parameters: { info: { disable: true }, + themeProvider: { chromatic: { theme: "sage" } }, chromatic: { disableSnapshot: true, }, @@ -115,3 +131,205 @@ export const DefaultWithAriaDescribedBy = () => ( ); DefaultWithAriaDescribedBy.storyName = "Default with aria-describedby"; + +export const AllChromaticScenarios = () => { + const titleNodeWithIcon = ( + + + + + ); + + const titleNodeWithSROnlyTitle = ( + + + + + ); + + return ( + + + + Default + + + + + + + Title Node + + + + + + + Title Node – Screen Reader Only Title + + + + + + + Category + + + + + + + Show Progress Indicator + + + + + + + Show Total Steps + + + + + + + Show Close Icon + + undefined} + titleVariant="h2" + /> + + + ); +}; + +AllChromaticScenarios.storyName = "All Chromatic Scenarios"; +AllChromaticScenarios.parameters = { + chromatic: { disableSnapshot: false }, +}; + +export const ExampleImplementationWithTitleNode: StoryFn = () => { + const lowestStep = 1; + const highestStep = 3; + + const [isOpen, setIsOpen] = useState(true); + const [step, setStep] = useState(lowestStep); + const stepFlowHandle = useRef(null); + + const stepTitles = ["Step title 1", "Step title 2", "Step title 3"]; + + function handleClick(clickType: string) { + stepFlowHandle.current?.focus(); + + if (clickType === "Back") { + setStep(step > lowestStep ? step - 1 : step); + } else { + setStep(step < highestStep ? step + 1 : step); + } + } + + const titleNode = ( + + + + + ); + return ( + <> + + setIsOpen(false)} + mb="20px" + titleVariant="h2" + /> + } + > +
handleClick("Back")}> + Back + + } + rightSideButtons={ + + } + > + + This is an example of a Dialog with a Form as content, with a Step + Flow to help users complete tasks in a specific order. + +