Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pages/app/app-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
direction: "ltr" | "rtl";
motionDisabled: boolean;
i18n: boolean;
screenshotMode: boolean;
}

export interface AppContextType<T = unknown> {
Expand All @@ -29,6 +30,7 @@
direction: "ltr",
motionDisabled: false,
i18n: true,
screenshotMode: false,
},
setUrlParams: () => {},
};
Expand All @@ -38,7 +40,7 @@
export default AppContext;

function parseQuery(urlParams: URLSearchParams) {
const queryParams: Record<string, any> = { ...appContextDefaults.urlParams };

Check warning on line 43 in pages/app/app-context.tsx

View workflow job for this annotation

GitHub Actions / build / build

Unexpected any. Specify a different type

Check warning on line 43 in pages/app/app-context.tsx

View workflow job for this annotation

GitHub Actions / dry-run / Build chat components

Unexpected any. Specify a different type
urlParams.forEach((value, key) => (queryParams[key] = value));

return mapValues(queryParams, (value) => {
Expand Down
17 changes: 17 additions & 0 deletions pages/app/screenshot-area.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

/*
Spinner animations do not follow our general motion configuration, we need to disable them explicitly to get stable
screenshot testing results
*/
.no-animation {
*,
*:before,
*:after {
animation: none !important;
transition: none !important;
}
}
10 changes: 8 additions & 2 deletions pages/app/screenshot-area.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import { ReactNode } from "react";
import { ReactNode, useContext } from "react";
import clsx from "clsx";

import AppContext from "./app-context";

import styles from "./screenshot-area.module.css";

export function ScreenshotArea({ children }: { children: ReactNode }) {
return <div className="screenshot-area">{children}</div>;
const { urlParams } = useContext(AppContext);
return <div className={clsx("screenshot-area", urlParams.screenshotMode && styles["no-animation"])}>{children}</div>;
}
2 changes: 1 addition & 1 deletion test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function setupTest<P extends BasePageObject & { init?(): Promise<void> }>
test: (page: P) => Promise<void>,
) {
return useBrowser(windowSize, async (browser) => {
await browser.url(url);
await browser.url(`${url}?screenshotMode=true`);
const page = new PageClass(browser);
await page.waitForVisible("main");

Expand Down
Loading