Skip to content

Commit

Permalink
test(SegmentedSwitch): add visual tests
Browse files Browse the repository at this point in the history
  • Loading branch information
domihustinova committed Jul 26, 2024
1 parent 812ddaf commit 753de42
Show file tree
Hide file tree
Showing 14 changed files with 83 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import * as React from "react";

import type { Option } from "./types";

import SegmentedSwitch from ".";

const options: Option[] = [
{ label: "Male", value: "Male" },
{ label: "Female", value: "Female" },
];

const optionsWithDefaultChecked: Option[] = [
{ label: "Male", value: "Male" },
{ label: "Female", value: "Female", defaultChecked: true },
];

export function SegmentedSwitchStory() {
return (
<div className="gap-md p-md flex flex-col">
<SegmentedSwitch options={options} onChange={() => {}} />
<SegmentedSwitch options={options} label="Custom label" onChange={() => {}} />
<SegmentedSwitch
options={optionsWithDefaultChecked}
label="Custom label"
onChange={() => {}}
/>
<SegmentedSwitch
options={options}
label="Custom label"
help="Do or do not. There is no try."
onChange={() => {}}
/>
<SegmentedSwitch
options={options}
label="Custom label"
error="You shall not pass!"
onChange={() => {}}
/>
<div className="mt-xl">
<SegmentedSwitch
options={options}
label="Custom label"
help="Do or do not. There is no try."
showTooltip
onChange={() => {}}
/>
</div>
<div className="mt-xl">
<SegmentedSwitch
options={options}
label="Custom label"
error="You shall not pass!"
onChange={() => {}}
showTooltip
/>
</div>
<SegmentedSwitch options={options} maxWidth="300px" onChange={() => {}} />
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as React from "react";
import { test, expect } from "@playwright/experimental-ct-react";

import { SegmentedSwitchStory } from "./SegmentedSwitch.ct-story";
import RenderInRtl from "../utils/rtl/RenderInRtl";

test.describe("visual SegmentedSwitch", () => {
test("default", async ({ mount }) => {
const component = await mount(<SegmentedSwitchStory />);

await expect(component).toHaveScreenshot();
});

test("rtl", async ({ mount }) => {
const component = await mount(
<RenderInRtl>
<SegmentedSwitchStory />
</RenderInRtl>,
);

await expect(component).toHaveScreenshot();
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 753de42

Please sign in to comment.