Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
uiii committed Dec 6, 2023
1 parent 7968837 commit 9d70f38
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/SearchInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ function SearchInput(props: SearchInputProps) {
}, [persist]);

return (
<form {...restProps} onSubmit={handleSubmit}>
<form {...restProps} onSubmit={handleSubmit} data-test="search-input">
<FormGroup row css={formGroupStyle}>
<NetworkSelect
css={networkSelectStyle}
Expand Down
4 changes: 4 additions & 0 deletions src/hooks/usePreloadRuntimeMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ export function usePreloadRuntimeMetadata() {
const [progress, setProgress] = useState<number>(localStorage.getItem("runtime-metadata-preloaded") ? 100 : 0);

useEffect(() => {
if (localStorage.getItem("skip-runtime-metadata-preload")) {
return;
}

Promise.allSettled(getNetworks().map(async (it) => {
try {
const specVersion = await getLatestRuntimeSpecVersion(it.name);
Expand Down
2 changes: 1 addition & 1 deletion src/screens/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export const HomePage = () => {
persist
/>
</div>
<div css={networksStyle}>
<div css={networksStyle} data-test="networks">
{networkGroups.map((group) =>
<Card css={networksGroupStyle} key={group.relayChainNetwork?.name || "other"}>
<div css={newtorkGroupTitleStyle}>
Expand Down
6 changes: 6 additions & 0 deletions test/e2e/home.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ test.describe("home page", () => {
test("shows home page", async ({ page, takeScreenshot }) => {
await navigate(page, "/", {waitUntil: "load"});

const $searchInput = page.getByTestId("search-input");
const $networks = page.getByTestId("networks");

await expect($searchInput).toBeVisible();
await expect($networks).toBeVisible();

await takeScreenshot("home");
});
});
4 changes: 4 additions & 0 deletions test/utils/navigate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ const customEvents = ["data-loaded", "chart-finished"];
export async function navigate(page: Page, url: string, options: GotoOptions = {}) {
let customEvent: string|undefined = undefined;

await page.goto(url, {waitUntil: "commit"});
await page.evaluate(() => localStorage.setItem("skip-runtime-metadata-preload", "true"));
await page.evaluate(() => localStorage.setItem("runtime-metadata-preloaded", "true"));

if (options.waitUntil && customEvents.includes(options.waitUntil)) {
customEvent = options.waitUntil;
options.waitUntil = "domcontentloaded";
Expand Down

0 comments on commit 9d70f38

Please sign in to comment.