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 (
+ <>
+
+
+ >
+ );
+};
+ExampleImplementationWithTitleNode.storyName =
+ "Example Implementation with title node";
diff --git a/src/components/step-flow/step-flow.pw.tsx b/src/components/step-flow/step-flow.pw.tsx
index 8ba96fa2ef..77a5c7a2b0 100644
--- a/src/components/step-flow/step-flow.pw.tsx
+++ b/src/components/step-flow/step-flow.pw.tsx
@@ -1,301 +1,10 @@
import React from "react";
-import { test, expect } from "../../../playwright/helpers/base-test";
-import {
- checkAccessibility,
- getDesignTokensByCssProperty,
-} from "../../../playwright/support/helper";
-import {
- StepFlowComponent,
- StepFlowComponentWithStepFlowTitleNode,
- StepFlowComponentWithRefAndButtons,
- StepFlowComponentWithRefAndButtonsAndStepFlowTitleNode,
-} from "./components.test-pw";
-
-import { StepFlowTitle, Steps } from ".";
-
-import {
- stepFlowProgressIndicator,
- stepFlowCategoryText,
- stepFlowTitleTextWrapper,
- stepFlowTitleText,
- stepFlowVisuallyHiddenTitleText,
- stepFlowProgressIndicatorBar,
- stepFlowLabel,
- stepFlowDismissIcon,
-} from "../../../playwright/components/step-flow";
-
-import { button } from "../../../playwright/components";
-
-import { CHARACTERS } from "../../../playwright/support/constants";
-
-const testData = [CHARACTERS.DIACRITICS, CHARACTERS.SPECIALCHARACTERS];
-
-test.describe("Prop checks for StepFlow component", () => {
- testData.forEach((stringVals) => {
- test(`should render with the category prop, when the prop's value is ${stringVals}`, async ({
- mount,
- page,
- }) => {
- await mount();
-
- await expect(stepFlowCategoryText(page)).toHaveText(stringVals);
- });
- });
-
- testData.forEach((stringVals) => {
- test(`should render with the title prop, when the prop's value is ${stringVals}`, async ({
- mount,
- page,
- }) => {
- await mount();
-
- await expect(stepFlowTitleText(page)).toHaveText(stringVals);
- });
- });
-
- (["h1", "h2"] as const).forEach((titleVariants) => {
- test(`should render with the titleVariant prop, when the prop's value is ${titleVariants}`, async ({
- mount,
- page,
- }) => {
- await mount(
- ,
- );
-
- await expect(page.locator(titleVariants)).toContainText("foo");
- });
- });
-
- (["h1", "h2"] as const).forEach((titleVariants) => {
- test(`should render with the titleVariant prop passed to the 'StepFlowTitle' sub component, when the prop's value is ${titleVariants}`, async ({
- mount,
- page,
- }) => {
- await mount(
-
- }
- />,
- );
-
- await expect(page.locator(titleVariants)).toContainText("foo");
- });
- });
-
- test("should render the correct element when 'showProgressIndicator' is true", async ({
- mount,
- page,
- }) => {
- await mount();
-
- await expect(stepFlowProgressIndicatorBar(page)).toBeVisible();
- });
-
- (
- [
- [1, 1],
- [2, 1],
- [2, 3],
- ] as [Steps, Steps][]
- ).forEach(([totalSteps, currentStep]) => {
- test(`should render the correct label when the 'totalSteps' prop is passed as ${totalSteps} and 'currentStep' is ${currentStep}`, async ({
- mount,
- page,
- }) => {
- await mount(
- ,
- );
-
- if (totalSteps >= currentStep) {
- await expect(stepFlowLabel(page)).toHaveText(
- `Step ${currentStep} of ${totalSteps}`,
- );
- } else {
- await expect(stepFlowLabel(page)).toHaveText(
- `Step ${totalSteps} of ${totalSteps}`,
- );
- }
- });
- });
-
- (
- [
- [1, 1],
- [2, 1],
- [2, 3],
- ] as [Steps, Steps][]
- ).forEach(([totalSteps, currentStep]) => {
- test(`should render the correct visually hidden title when the 'totalSteps' prop is passed as ${totalSteps} and 'currentStep' is ${currentStep}, and the category and title props are also passed`, async ({
- mount,
- page,
- }) => {
- const category = "foo";
- const title = "bar";
-
- await mount(
- ,
- );
-
- if (totalSteps >= currentStep) {
- await expect(stepFlowVisuallyHiddenTitleText(page)).toHaveText(
- `${category}. ${title}. Step ${currentStep} of ${totalSteps}.`,
- );
- } else {
- await expect(stepFlowVisuallyHiddenTitleText(page)).toHaveText(
- `${category}. ${title}. Step ${totalSteps} of ${totalSteps}.`,
- );
- }
- });
- });
-
- ([1, 2, 3, 4, 5, 6, 7, 8] as Steps[]).forEach((totalSteps) => {
- test(`should render the correct amount of progress indicators when the 'totalSteps' prop is passed as ${totalSteps}`, async ({
- mount,
- page,
- }) => {
- await mount(
- ,
- );
-
- expect(await stepFlowProgressIndicator(page).count()).toEqual(totalSteps);
- });
- });
-
- test("should render the correct element when 'showCloseIcon' is true", async ({
- mount,
- page,
- }) => {
- await mount();
-
- await expect(stepFlowDismissIcon(page)).toBeVisible();
- });
-
- test("background colour token should be correct when 'showCloseIcon' is true and the indicator is in progress", async ({
- mount,
- page,
- }) => {
- await mount(
- ,
- );
-
- const backgroundColorToken = await getDesignTokensByCssProperty(
- page,
- stepFlowProgressIndicator(page),
- "background-color",
- );
-
- expect(backgroundColorToken[0]).toBe("--colorsUtilityYin090");
- });
-
- test("background colour token should be correct when 'showCloseIcon' is true and the indicator is completed", async ({
- mount,
- page,
- }) => {
- await mount(
- ,
- );
-
- const backgroundColorToken = await getDesignTokensByCssProperty(
- page,
- stepFlowProgressIndicator(page).nth(0),
- "background-color",
- );
-
- expect(backgroundColorToken[0]).toBe("--colorsSemanticPositive500");
- });
-
- test("background colour should be correct when 'showCloseIcon' is true and the indicator is not completed", async ({
- mount,
- page,
- }) => {
- await mount(
- ,
- );
-
- const backgroundColorToken = await getDesignTokensByCssProperty(
- page,
- stepFlowProgressIndicator(page).nth(2),
- "background-color",
- );
-
- expect(backgroundColorToken[0]).toBe("--colorsActionDisabled600");
- });
-});
-
-test.describe("Event checks for StepFlow component", () => {
- test("should call onDismiss callback when a click event is triggered", async ({
- mount,
- page,
- }) => {
- let callbackCount = 0;
- await mount(
- {
- callbackCount += 1;
- }}
- />,
- );
- await stepFlowDismissIcon(page).click();
-
- expect(callbackCount).toBe(1);
- });
-});
-
-test.describe("Ref checks for StepFlow component", () => {
- test("should focus on title DOM element when a focus ref is passed", async ({
- mount,
- page,
- }) => {
- await mount();
-
- await expect(stepFlowTitleTextWrapper(page)).not.toBeFocused();
- await button(page).nth(1).click();
-
- await expect(stepFlowTitleTextWrapper(page)).toBeFocused();
- });
-
- test("should focus on title DOM element when a focus ref is passed, and a node is passed to `title` with the `StepFlowTitle` as a descendant", async ({
- mount,
- page,
- }) => {
- await mount();
-
- await expect(stepFlowTitleTextWrapper(page)).not.toBeFocused();
- await button(page).nth(1).click();
-
- await expect(stepFlowTitleTextWrapper(page)).toBeFocused();
- });
-});
+import { test } from "../../../playwright/helpers/base-test";
+import { checkAccessibility } from "../../../playwright/support/helper";
+import { stepFlowDismissIcon } from "../../../playwright/components/step-flow";
+import { StepFlowComponent } from "./components.test-pw";
test.describe("Accessibility tests for StepFlow component", () => {
- test("should pass accessibility checks when a node is passed to`title` with the `StepFlowTile` as a descendant", async ({
- mount,
- page,
- }) => {
- await mount();
-
- await checkAccessibility(page);
- });
-
test("should pass accessibility checks when component is rendered with required props", async ({
mount,
page,
@@ -305,33 +14,6 @@ test.describe("Accessibility tests for StepFlow component", () => {
await checkAccessibility(page);
});
- test("should pass accessibility checks when component is rendered with a ref and buttons", async ({
- mount,
- page,
- }) => {
- await mount();
-
- await checkAccessibility(page);
- });
-
- test("should pass accessibility checks when component is rendered with a ref and buttons and a node is passed to `title` with the `StepFlowTile` as a descendant", async ({
- mount,
- page,
- }) => {
- await mount();
-
- await checkAccessibility(page);
- });
-
- test("should pass accessibility checks when 'showProgressIndicator' is true", async ({
- mount,
- page,
- }) => {
- await mount();
-
- await checkAccessibility(page);
- });
-
test("should pass accessibility checks when 'showProgressIndicator' is true and there are completed, not completed and in-progress indicator steps", async ({
mount,
page,
diff --git a/src/components/step-flow/step-flow.stories.tsx b/src/components/step-flow/step-flow.stories.tsx
index ea1002be4a..26424ef440 100644
--- a/src/components/step-flow/step-flow.stories.tsx
+++ b/src/components/step-flow/step-flow.stories.tsx
@@ -28,7 +28,10 @@ const meta: Meta = {
argTypes: {
...styledSystemProps,
},
- parameters: { controls: { disabled: true } },
+ parameters: {
+ controls: { disabled: true },
+ chromatic: { disableSnapshot: true },
+ },
decorators: [
(Story, context) => {
const isExampleImplementation = context.name?.includes("Example");