Files
explore/ui/shared/AppError/AppError.pw.tsx
T
tom goriunovandGitHub 05945f6cf7 refactor page layout components (#1087)
* update csv export text

* fix pw tests

* base layout and customization for home page and search results page

* refactor rest of the pages

* refactor AppError

* move header padding to layout

* move nextjs utils to separate folder

* combine PageServer and Page

* make useQueryClientConfig hook

* add tests

* remove unused var

* fix envs for pw

* fix pw tests
2023-08-15 19:28:00 -04:00

80 lines
2.1 KiB
TypeScript

import { test, expect } from '@playwright/experimental-ct-react';
import React from 'react';
import TestApp from 'playwright/TestApp';
import * as configs from 'playwright/utils/configs';
import AppError from './AppError';
test('status code 404', async({ mount }) => {
const error = { message: 'Not found', cause: { status: 404 } } as Error;
const component = await mount(
<TestApp>
<AppError error={ error }/>
</TestApp>,
);
await expect(component).toHaveScreenshot();
});
test('status code 422', async({ mount }) => {
const error = { message: 'Unprocessable entry', cause: { status: 422 } } as Error;
const component = await mount(
<TestApp>
<AppError error={ error }/>
</TestApp>,
);
await expect(component).toHaveScreenshot();
});
test('status code 500', async({ mount }) => {
const error = { message: 'Unknown error', cause: { status: 500 } } as Error;
const component = await mount(
<TestApp>
<AppError error={ error }/>
</TestApp>,
);
await expect(component).toHaveScreenshot();
});
test('invalid tx hash', async({ mount }) => {
const error = { message: 'Invalid tx hash', cause: { status: 404 } } as Error;
const component = await mount(
<TestApp>
<AppError error={ error }/>
</TestApp>,
);
await expect(component).toHaveScreenshot();
});
test('block lost consensus', async({ mount }) => {
const error = {
message: 'Not found',
cause: { payload: { message: 'Block lost consensus', hash: 'hash' } },
} as Error;
const component = await mount(
<TestApp>
<AppError error={ error }/>
</TestApp>,
);
await expect(component).toHaveScreenshot();
});
test('too many requests +@mobile', async({ mount, page }) => {
const error = {
message: 'Too many requests',
cause: { status: 429 },
} as Error;
const component = await mount(
<TestApp>
<AppError error={ error }/>
</TestApp>,
);
await page.waitForResponse('https://www.google.com/recaptcha/api2/**');
await expect(component).toHaveScreenshot({
mask: [ page.locator('.recaptcha') ],
maskColor: configs.maskColor,
});
});