-
Notifications
You must be signed in to change notification settings - Fork 21
[BOOKINGSG-9114][RYN] migrate error-display component #1100
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
6b5fc91
[BOOKINGSG-9114][RYN] rename file extension
9a9beba
[BOOKINGSG-9114][RYN] migrate to V4 tokens
0859f76
[BOOKINGSG-9114][RYN] migrate illustrationScheme prop
81e4033
[BOOKINGSG-9114][RYN] add e2e specs and screenshots
b6c6ed9
[BOOKINGSG-9114][RYN] convert styled component Styled tags to Linaria…
5556c59
[BOOKINGSG-9114][RYN] update props table
70a65f5
[BOOKINGSG-9114][RYN] update e2e tests
dfd2d97
[BOOKINGSG-9114][RYN] refactor illustrationScheme field in props table
2f1f35b
[BOOKINGSG-9114][RYN] fix breakpoints resolution with useDesignToken …
af290b0
[BOOKINGSG-9114][RYN] update e2e specs to align with convention
c1054c0
[BOOKINGSG-9114][RL] Remove unused screenshots
2c19821
[MISC][RL] Remove unnecessary prefix for variable
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
16 changes: 16 additions & 0 deletions
16
e2e/nextjs-app/src/app/components/error-display/custom-error.e2e.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,16 @@ | ||
| "use client"; | ||
| import { ErrorDisplay } from "@lifesg/react-design-system/error-display"; | ||
|
|
||
| export default function Story() { | ||
| return ( | ||
| <ErrorDisplay | ||
| type="404" | ||
| title="My Custom 404" | ||
| description={ | ||
| <> | ||
| You can pass a <strong>JSX component</strong> here as well | ||
| </> | ||
| } | ||
| /> | ||
| ); | ||
| } |
10 changes: 10 additions & 0 deletions
10
e2e/nextjs-app/src/app/components/error-display/default.e2e.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,10 @@ | ||
| "use client"; | ||
| import { ErrorDisplay } from "@lifesg/react-design-system/error-display"; | ||
|
|
||
| export default function Story() { | ||
| return ( | ||
| <div className="story-background"> | ||
| <ErrorDisplay type="404" /> | ||
| </div> | ||
| ); | ||
| } |
6 changes: 6 additions & 0 deletions
6
e2e/nextjs-app/src/app/components/error-display/image-only.e2e.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,6 @@ | ||
| "use client"; | ||
| import { ErrorDisplay } from "@lifesg/react-design-system/error-display"; | ||
|
|
||
| export default function Story() { | ||
| return <ErrorDisplay type="500" imageOnly />; | ||
| } |
11 changes: 11 additions & 0 deletions
11
e2e/nextjs-app/src/app/components/error-display/maintenance.e2e.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,11 @@ | ||
| "use client"; | ||
| import { ErrorDisplay } from "@lifesg/react-design-system/error-display"; | ||
|
|
||
| export default function Story() { | ||
| return ( | ||
| <ErrorDisplay | ||
| type="maintenance" | ||
| additionalProps={{ dateString: "1 January 2023, 8:00am" }} | ||
| /> | ||
| ); | ||
| } |
22 changes: 22 additions & 0 deletions
22
e2e/nextjs-app/src/app/components/error-display/with-action-button.e2e.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,22 @@ | ||
| "use client"; | ||
| import { ErrorDisplay } from "@lifesg/react-design-system/error-display"; | ||
| import { useState } from "react"; | ||
|
|
||
| export default function Story() { | ||
| const [clicked, setClicked] = useState(false); | ||
|
|
||
| return ( | ||
| <> | ||
| <ErrorDisplay | ||
| type="unsupported-browser" | ||
| actionButton={{ | ||
| children: "Continue anyway", | ||
| onClick: () => setClicked(true), | ||
| }} | ||
| /> | ||
| {clicked && ( | ||
| <div data-testid="continue-button-click-result">clicked</div> | ||
| )} | ||
| </> | ||
| ); | ||
| } |
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
Binary file added
BIN
+27.7 KB
...splay-Custom-error-renders-custom-title-and-description--custom-error-mount.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
+33.5 KB
.../error-display/__screenshots__/chromium/ErrorDisplay-Default--default-mount.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
+35.9 KB
...play/__screenshots__/chromium/ErrorDisplay-Default-dark-mode---default-dark.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
+26.3 KB
...creenshots__/chromium/ErrorDisplay-Default-mobile-viewport---default-mobile.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.6 KB
...rDisplay-Image-only-renders-without-title-and-description--image-only-mount.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
+38.7 KB
...rorDisplay-Maintenance-renders-dateString-in-description--maintenance-mount.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
+53.2 KB
...play-With-action-button-renders-and-fires-onClick--with-action-button-mount.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
130 changes: 130 additions & 0 deletions
130
e2e/tests/components/error-display/error-display.e2e.spec.ts
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,130 @@ | ||
| import { expect, test as base, Page } from "@playwright/test"; | ||
| import { AbstractStoryPage, compareScreenshot } from "../../utils"; | ||
|
|
||
| class StoryPage extends AbstractStoryPage { | ||
| protected readonly component = "error-display"; | ||
| constructor(page: Page) { | ||
| super(page); | ||
| } | ||
| } | ||
|
|
||
| const test = base.extend<{ story: StoryPage }>({ | ||
| story: async ({ page }, use) => { | ||
| const story = new StoryPage(page); | ||
| await use(story); | ||
| }, | ||
| }); | ||
|
|
||
| test.describe("ErrorDisplay", () => { | ||
| test.describe(() => { | ||
| test.beforeEach(async ({ story }) => { | ||
| await story.init("default"); | ||
| }); | ||
|
|
||
| test("Default", async ({ story }) => { | ||
| await compareScreenshot(story, "default-mount"); | ||
| }); | ||
| }); | ||
|
|
||
| test.describe(() => { | ||
| test.beforeEach(async ({ story }) => { | ||
| await story.init("default", { mode: "dark" }); | ||
| }); | ||
|
|
||
| test("Default (dark mode)", async ({ story }) => { | ||
| await compareScreenshot(story, "default-dark"); | ||
| }); | ||
| }); | ||
|
|
||
| test.describe(() => { | ||
| test.beforeEach(async ({ story }) => { | ||
| await story.init("default", { size: "mobile" }); | ||
| }); | ||
|
|
||
| test("Default (mobile viewport)", async ({ story }) => { | ||
| await compareScreenshot(story, "default-mobile"); | ||
| }); | ||
| }); | ||
|
|
||
| test.describe(() => { | ||
| test.beforeEach(async ({ story }) => { | ||
| await story.init("with-action-button"); | ||
| }); | ||
|
|
||
| test("With action button renders and fires onClick", async ({ | ||
| story, | ||
| }) => { | ||
| const button = story.page.getByRole("button", { | ||
| name: "Continue anyway", | ||
| }); | ||
|
|
||
| await test.step("Screenshot matches on mount", async () => { | ||
| await compareScreenshot(story, "with-action-button-mount"); | ||
| }); | ||
|
|
||
| await test.step("Clicking the button fires the handler", async () => { | ||
| await button.click(); | ||
| await expect( | ||
| story.page.getByTestId("continue-button-click-result") | ||
| ).toBeVisible(); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| test.describe(() => { | ||
| test.beforeEach(async ({ story }) => { | ||
| await story.init("image-only"); | ||
| }); | ||
|
|
||
| test("Image only renders without title and description", async ({ | ||
| story, | ||
| }) => { | ||
| await expect( | ||
| story.page.getByTestId("error-display--title") | ||
| ).not.toBeVisible(); | ||
| await expect( | ||
| story.page.getByTestId("error-display--description") | ||
| ).not.toBeVisible(); | ||
| await compareScreenshot(story, "image-only-mount"); | ||
| }); | ||
| }); | ||
|
|
||
| test.describe(() => { | ||
| test.beforeEach(async ({ story }) => { | ||
| await story.init("custom-error"); | ||
| }); | ||
|
|
||
| test("Custom error renders custom title and description", async ({ | ||
| story, | ||
| }) => { | ||
| await test.step("Custom title is rendered", async () => { | ||
| await expect( | ||
| story.page.getByRole("heading", { | ||
| level: 2, | ||
| name: "My Custom 404", | ||
| }) | ||
| ).toBeVisible(); | ||
| }); | ||
|
|
||
| await test.step("Custom description with JSX is rendered", async () => { | ||
| await expect( | ||
| story.page.getByTestId("error-display--description") | ||
| ).toContainText("JSX component"); | ||
| }); | ||
|
|
||
| await compareScreenshot(story, "custom-error-mount"); | ||
| }); | ||
| }); | ||
|
|
||
| test.describe(() => { | ||
| test.beforeEach(async ({ story }) => { | ||
| await story.init("maintenance"); | ||
| }); | ||
|
|
||
| test("Maintenance renders dateString in description", async ({ | ||
| story, | ||
| }) => { | ||
| await compareScreenshot(story, "maintenance-mount"); | ||
| }); | ||
| }); | ||
| }); |
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.
Uh oh!
There was an error while loading. Please reload this page.