-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(SegmentedSwitch): add visual tests
- Loading branch information
1 parent
812ddaf
commit 753de42
Showing
14 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
packages/orbit-components/src/SegmentedSwitch/SegmentedSwitch.ct-story.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
} |
23 changes: 23 additions & 0 deletions
23
packages/orbit-components/src/SegmentedSwitch/SegmentedSwitch.ct.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |
Binary file added
BIN
+37.1 KB
...ntedSwitch.ct.tsx-snapshots/visual-SegmentedSwitch-default-1-Desktop-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+37.7 KB
...itch.ct.tsx-snapshots/visual-SegmentedSwitch-default-1-Large-Desktop-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+45.8 KB
...witch.ct.tsx-snapshots/visual-SegmentedSwitch-default-1-Large-Mobile-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+42.8 KB
...itch.ct.tsx-snapshots/visual-SegmentedSwitch-default-1-Medium-Mobile-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+40.8 KB
...witch.ct.tsx-snapshots/visual-SegmentedSwitch-default-1-Small-Mobile-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+48.8 KB
...entedSwitch.ct.tsx-snapshots/visual-SegmentedSwitch-default-1-Tablet-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+36.7 KB
...egmentedSwitch.ct.tsx-snapshots/visual-SegmentedSwitch-rtl-1-Desktop-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+37.3 KB
...edSwitch.ct.tsx-snapshots/visual-SegmentedSwitch-rtl-1-Large-Desktop-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+46.1 KB
...tedSwitch.ct.tsx-snapshots/visual-SegmentedSwitch-rtl-1-Large-Mobile-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+43.1 KB
...edSwitch.ct.tsx-snapshots/visual-SegmentedSwitch-rtl-1-Medium-Mobile-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+41.1 KB
...tedSwitch.ct.tsx-snapshots/visual-SegmentedSwitch-rtl-1-Small-Mobile-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+49 KB
...SegmentedSwitch.ct.tsx-snapshots/visual-SegmentedSwitch-rtl-1-Tablet-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.