-
Notifications
You must be signed in to change notification settings - Fork 30
chore: Add InputTime v2 Visual regression tests #3063
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
MichaelParadis
wants to merge
3
commits into
master
Choose a base branch
from
CLEANUP/add-inputtime-v2-vrt
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
240 changes: 240 additions & 0 deletions
240
packages/site/src/pages/visualTests/VisualTestInputTimeV2Page.tsx
This file contains hidden or 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,240 @@ | ||
| import { Box, Grid, Heading, InputTime, Stack, Text } from "@jobber/components"; | ||
| import { useState } from "react"; | ||
|
|
||
| const REFERENCE_TIME = new Date(2024, 0, 1, 14, 30, 0); | ||
|
|
||
| export const VisualTestInputTimeV2Page = () => { | ||
| const [value, setValue] = useState<Date | undefined>(undefined); | ||
|
|
||
| return ( | ||
| <Box padding="large"> | ||
| <Stack gap="extravagant"> | ||
| <Heading level={3}>InputTime v2 Examples</Heading> | ||
|
|
||
| <Stack gap="large"> | ||
| <section data-testid="basic-empty"> | ||
| <Text size="large">Basic (empty)</Text> | ||
| <Grid> | ||
| <Grid.Cell size={{ xs: 12, md: 6 }}> | ||
| <InputTime | ||
| version={2} | ||
| value={value} | ||
| onChange={newValue => setValue(newValue)} | ||
| placeholder="Select time" | ||
| /> | ||
| </Grid.Cell> | ||
| </Grid> | ||
| </section> | ||
|
|
||
| <section data-testid="with-value"> | ||
| <Text size="large">With value</Text> | ||
| <Grid> | ||
| <Grid.Cell size={{ xs: 12, md: 6 }}> | ||
| <InputTime | ||
| version={2} | ||
| value={REFERENCE_TIME} | ||
| onChange={newValue => setValue(newValue)} | ||
| placeholder="Select time" | ||
| /> | ||
| </Grid.Cell> | ||
| </Grid> | ||
| </section> | ||
|
|
||
| <section data-testid="with-description"> | ||
| <Text size="large">With description</Text> | ||
| <Grid> | ||
| <Grid.Cell size={{ xs: 12, md: 6 }}> | ||
| <InputTime | ||
| version={2} | ||
| value={value} | ||
| onChange={newValue => setValue(newValue)} | ||
| placeholder="Select time" | ||
| description="Please select a start time" | ||
| /> | ||
| </Grid.Cell> | ||
| </Grid> | ||
| </section> | ||
|
|
||
| <section data-testid="with-error"> | ||
| <Text size="large">With error</Text> | ||
| <Grid> | ||
| <Grid.Cell size={{ xs: 12, md: 6 }}> | ||
| <InputTime | ||
| version={2} | ||
| value={value} | ||
| onChange={newValue => setValue(newValue)} | ||
| placeholder="Select time" | ||
| error="Please enter a valid time" | ||
| /> | ||
| </Grid.Cell> | ||
| </Grid> | ||
| </section> | ||
|
|
||
| <section data-testid="invalid"> | ||
| <Text size="large">Invalid (no message)</Text> | ||
| <Grid> | ||
| <Grid.Cell size={{ xs: 12, md: 6 }}> | ||
| <InputTime | ||
| version={2} | ||
| value={value} | ||
| onChange={newValue => setValue(newValue)} | ||
| placeholder="Select time" | ||
| invalid={true} | ||
| /> | ||
| </Grid.Cell> | ||
| </Grid> | ||
| </section> | ||
|
|
||
| <section data-testid="disabled"> | ||
| <Text size="large">Disabled (with value)</Text> | ||
| <Grid> | ||
| <Grid.Cell size={{ xs: 12, md: 6 }}> | ||
| <InputTime | ||
| version={2} | ||
| value={REFERENCE_TIME} | ||
| onChange={newValue => setValue(newValue)} | ||
| placeholder="Select time" | ||
| disabled={true} | ||
| /> | ||
| </Grid.Cell> | ||
| </Grid> | ||
| </section> | ||
|
|
||
| <section data-testid="disabled-empty"> | ||
| <Text size="large">Disabled (empty)</Text> | ||
| <Grid> | ||
| <Grid.Cell size={{ xs: 12, md: 6 }}> | ||
| <InputTime | ||
| version={2} | ||
| value={undefined} | ||
| onChange={newValue => setValue(newValue)} | ||
| placeholder="Select time" | ||
| disabled={true} | ||
| /> | ||
| </Grid.Cell> | ||
| </Grid> | ||
| </section> | ||
|
|
||
| <section data-testid="readonly"> | ||
| <Text size="large">ReadOnly (with value)</Text> | ||
| <Grid> | ||
| <Grid.Cell size={{ xs: 12, md: 6 }}> | ||
| <InputTime | ||
| version={2} | ||
| value={REFERENCE_TIME} | ||
| onChange={newValue => setValue(newValue)} | ||
| placeholder="Select time" | ||
| readOnly={true} | ||
| /> | ||
| </Grid.Cell> | ||
| </Grid> | ||
| </section> | ||
|
|
||
| <section data-testid="size-small"> | ||
| <Text size="large">Small size</Text> | ||
| <Grid> | ||
| <Grid.Cell size={{ xs: 12, md: 6 }}> | ||
| <InputTime | ||
| version={2} | ||
| value={REFERENCE_TIME} | ||
| onChange={newValue => setValue(newValue)} | ||
| placeholder="Select time" | ||
| size="small" | ||
| /> | ||
| </Grid.Cell> | ||
| </Grid> | ||
| </section> | ||
|
|
||
| <section data-testid="size-large"> | ||
| <Text size="large">Large size</Text> | ||
| <Grid> | ||
| <Grid.Cell size={{ xs: 12, md: 6 }}> | ||
| <InputTime | ||
| version={2} | ||
| value={REFERENCE_TIME} | ||
| onChange={newValue => setValue(newValue)} | ||
| placeholder="Select time" | ||
| size="large" | ||
| /> | ||
| </Grid.Cell> | ||
| </Grid> | ||
| </section> | ||
|
|
||
| <section data-testid="align-center"> | ||
| <Text size="large">Center aligned</Text> | ||
| <Grid> | ||
| <Grid.Cell size={{ xs: 12, md: 6 }}> | ||
| <InputTime | ||
| version={2} | ||
| value={REFERENCE_TIME} | ||
| onChange={newValue => setValue(newValue)} | ||
| placeholder="Select time" | ||
| align="center" | ||
| /> | ||
| </Grid.Cell> | ||
| </Grid> | ||
| </section> | ||
|
|
||
| <section data-testid="align-right"> | ||
| <Text size="large">Right aligned</Text> | ||
| <Grid> | ||
| <Grid.Cell size={{ xs: 12, md: 6 }}> | ||
| <InputTime | ||
| version={2} | ||
| value={REFERENCE_TIME} | ||
| onChange={newValue => setValue(newValue)} | ||
| placeholder="Select time" | ||
| align="right" | ||
| /> | ||
| </Grid.Cell> | ||
| </Grid> | ||
| </section> | ||
|
|
||
| <section data-testid="inline"> | ||
| <Text size="large">Inline</Text> | ||
| <div style={{ display: "flex", alignItems: "center", gap: "8px" }}> | ||
| <Text>Start:</Text> | ||
| <InputTime | ||
| version={2} | ||
| value={REFERENCE_TIME} | ||
| onChange={newValue => setValue(newValue)} | ||
| placeholder="Time" | ||
| inline={true} | ||
| /> | ||
| </div> | ||
| </section> | ||
|
|
||
| <section data-testid="clearable-always"> | ||
| <Text size="large">Clearable always (with value)</Text> | ||
| <Grid> | ||
| <Grid.Cell size={{ xs: 12, md: 6 }}> | ||
| <InputTime | ||
| version={2} | ||
| value={REFERENCE_TIME} | ||
| onChange={newValue => setValue(newValue)} | ||
| placeholder="Select time" | ||
| clearable="always" | ||
| /> | ||
| </Grid.Cell> | ||
| </Grid> | ||
| </section> | ||
|
|
||
| <section data-testid="clearable-focus"> | ||
| <Text size="large">Clearable on focus (with value)</Text> | ||
| <Grid> | ||
| <Grid.Cell size={{ xs: 12, md: 6 }}> | ||
| <InputTime | ||
| version={2} | ||
| value={REFERENCE_TIME} | ||
| onChange={newValue => setValue(newValue)} | ||
| placeholder="Select time" | ||
| clearable="while-editing" | ||
| /> | ||
| </Grid.Cell> | ||
| </Grid> | ||
| </section> | ||
| </Stack> | ||
| </Stack> | ||
| </Box> | ||
| ); | ||
| }; |
This file contains hidden or 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
This file contains hidden or 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,88 @@ | ||
| import { expect, test } from "@playwright/test"; | ||
|
|
||
| const screenshotOptions = { | ||
| animations: "disabled" as const, | ||
| caret: "hide" as const, | ||
| fullPage: true, | ||
| }; | ||
|
|
||
| test.describe("InputTime v2 Visual Tests", () => { | ||
| test.beforeEach(async ({ page }) => { | ||
| await page.goto("/visual-tests/input-time-v2"); | ||
| await page.waitForLoadState("networkidle"); | ||
| await page.waitForTimeout(500); | ||
| }); | ||
|
|
||
| test("1 - initial page state", async ({ page }) => { | ||
| await expect(page).toHaveScreenshot("1-initial.png", screenshotOptions); | ||
| }); | ||
|
|
||
| test.describe("interactions", () => { | ||
| test("2 - focus state (empty)", async ({ page }) => { | ||
| const input = page | ||
| .getByTestId("basic-empty") | ||
| .getByTestId("ATL-InputTime-input"); | ||
| await input.scrollIntoViewIfNeeded(); | ||
| await input.focus(); | ||
| await page.waitForTimeout(200); | ||
| await expect(page).toHaveScreenshot( | ||
| "2-focus-empty.png", | ||
| screenshotOptions, | ||
| ); | ||
| }); | ||
|
|
||
| test("3 - focus state (with value)", async ({ page }) => { | ||
| const input = page | ||
| .getByTestId("with-value") | ||
| .getByTestId("ATL-InputTime-input"); | ||
| await input.scrollIntoViewIfNeeded(); | ||
| await input.focus(); | ||
| await page.waitForTimeout(200); | ||
| await expect(page).toHaveScreenshot( | ||
| "3-focus-with-value.png", | ||
| screenshotOptions, | ||
| ); | ||
| }); | ||
|
|
||
| test("4 - focus state (error)", async ({ page }) => { | ||
| const input = page | ||
| .getByTestId("with-error") | ||
| .getByTestId("ATL-InputTime-input"); | ||
| await input.scrollIntoViewIfNeeded(); | ||
| await input.focus(); | ||
| await page.waitForTimeout(200); | ||
| await expect(page).toHaveScreenshot( | ||
| "4-focus-error.png", | ||
| screenshotOptions, | ||
| ); | ||
| }); | ||
|
|
||
| test("5 - clearable focus: clear button visible on focus", async ({ | ||
| page, | ||
| }) => { | ||
| const input = page | ||
| .getByTestId("clearable-focus") | ||
| .getByTestId("ATL-InputTime-input"); | ||
| await input.scrollIntoViewIfNeeded(); | ||
| await input.focus(); | ||
| await page.waitForTimeout(200); | ||
| await expect(page).toHaveScreenshot( | ||
| "5-clearable-focus-focused.png", | ||
| screenshotOptions, | ||
| ); | ||
| }); | ||
|
|
||
| test("6 - clearable always: clear button hover", async ({ page }) => { | ||
| const clearButton = page | ||
| .getByTestId("clearable-always") | ||
| .getByRole("button", { name: /clear/i }); | ||
| await clearButton.scrollIntoViewIfNeeded(); | ||
| await clearButton.hover(); | ||
| await page.waitForTimeout(200); | ||
| await expect(page).toHaveScreenshot( | ||
| "6-clearable-always-clear-hover.png", | ||
| screenshotOptions, | ||
| ); | ||
| }); | ||
| }); | ||
| }); |
Binary file added
BIN
+86.5 KB
packages/site/tests/visual/inputtime-v2.visual.ts-snapshots/1-initial-chromium.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
+131 KB
packages/site/tests/visual/inputtime-v2.visual.ts-snapshots/1-initial-firefox.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
+108 KB
packages/site/tests/visual/inputtime-v2.visual.ts-snapshots/1-initial-webkit.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
+87.1 KB
...s/site/tests/visual/inputtime-v2.visual.ts-snapshots/2-focus-empty-chromium.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
+132 KB
...es/site/tests/visual/inputtime-v2.visual.ts-snapshots/2-focus-empty-firefox.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
+108 KB
...ges/site/tests/visual/inputtime-v2.visual.ts-snapshots/2-focus-empty-webkit.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
+87.5 KB
...e/tests/visual/inputtime-v2.visual.ts-snapshots/3-focus-with-value-chromium.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
+132 KB
...te/tests/visual/inputtime-v2.visual.ts-snapshots/3-focus-with-value-firefox.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
+109 KB
...ite/tests/visual/inputtime-v2.visual.ts-snapshots/3-focus-with-value-webkit.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
+87.3 KB
...s/site/tests/visual/inputtime-v2.visual.ts-snapshots/4-focus-error-chromium.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
+132 KB
...es/site/tests/visual/inputtime-v2.visual.ts-snapshots/4-focus-error-firefox.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
+109 KB
...ges/site/tests/visual/inputtime-v2.visual.ts-snapshots/4-focus-error-webkit.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
+87.5 KB
.../visual/inputtime-v2.visual.ts-snapshots/5-clearable-focus-focused-chromium.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
+132 KB
...s/visual/inputtime-v2.visual.ts-snapshots/5-clearable-focus-focused-firefox.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
+109 KB
...ts/visual/inputtime-v2.visual.ts-snapshots/5-clearable-focus-focused-webkit.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
+86.5 KB
...al/inputtime-v2.visual.ts-snapshots/6-clearable-always-clear-hover-chromium.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
+131 KB
...ual/inputtime-v2.visual.ts-snapshots/6-clearable-always-clear-hover-firefox.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
+108 KB
...sual/inputtime-v2.visual.ts-snapshots/6-clearable-always-clear-hover-webkit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right Align and Center align has existing issue in Safari on both our V1 and V2 versions of InputTime. We likely didn't know about it
https://atlantis.getjobber.com/storybook/web/?path=/story/components-forms-and-inputs-inputtime--controlled&args=align:right