Skip to content
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

Turn on eslint playwright plugin and eslint react-query plugin #2401

Merged
merged 3 commits into from
Nov 15, 2024
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
7 changes: 2 additions & 5 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -230,16 +230,13 @@ export default tseslint.config(

{
plugins: { '@tanstack/query': reactQueryPlugin },
rules: {
'@tanstack/query/no-unstable-deps': 'off', // TODO @tom2drum turn on this rule
},
},

{
plugins: { playwright: playwrightPlugin },
...playwrightPlugin.configs['flat/recommended'],
files: [ '**/*.pw.tsx' ],
rules: {
'playwright/valid-title': 'warn', // TODO @tom2drum turn on this rule
...playwrightPlugin.configs['flat/recommended'].rules,
'playwright/no-standalone-expect': 'off', // this rules does not work correctly with extended test functions
},
},
Expand Down
2 changes: 1 addition & 1 deletion theme/components/Button/Button.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ test.use({ viewport: { width: 150, height: 350 } });
{ variant: 'radio_group', states: [ 'default', 'hovered', 'selected' ], withDarkMode: true },
].forEach(({ variant, colorScheme, withDarkMode, states }) => {
test.describe(`variant ${ variant }${ colorScheme ? ` with ${ colorScheme } color scheme` : '' }${ withDarkMode ? ' +@dark-mode' : '' }`, () => {
test('', async({ render }) => {
test('base view', async({ render }) => {
const component = await render(
<Flex p={ 2 } flexDir="column" rowGap={ 3 }>
{ states?.map((state) => {
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
4 changes: 2 additions & 2 deletions theme/components/Tooltip/Tooltip.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ test.fixme('with icon', async({ render, page }) => {
);

const tooltip = page.getByText(/tooltip content/i);
expect(await tooltip.isVisible()).toBe(false);
await expect(tooltip).toBeHidden();

await component.locator('svg[aria-label="Trigger"]').hover();
expect(await tooltip.isVisible()).toBe(true);
await expect(tooltip).toBeVisible();
});
12 changes: 8 additions & 4 deletions ui/address/AddressTokenTransfers.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ test.describe('socket', () => {

socketServer.sendMessage(socket, channel, 'token_transfer', { token_transfers: [ tokenTransferMock.erc1155B, tokenTransferMock.erc1155C ] });

await page.waitForSelector('tbody tr:nth-child(3)');
const thirdRow = page.locator('tbody tr:nth-child(3)');
await thirdRow.waitFor();

const itemsCountNew = await page.locator('tbody tr').count();
expect(itemsCountNew).toBe(4);
Expand Down Expand Up @@ -147,7 +148,8 @@ test.describe('socket', () => {

socketServer.sendMessage(socket, channel, 'token_transfer', { token_transfers: [ tokenTransferMock.erc1155B, tokenTransferMock.erc1155C ] });

await page.waitForSelector('tbody tr:nth-child(3)');
const thirdRow = page.locator('tbody tr:nth-child(3)');
await thirdRow.waitFor();

const itemsCountNew = await page.locator('tbody tr').count();
expect(itemsCountNew).toBe(3);
Expand Down Expand Up @@ -183,7 +185,8 @@ test.describe('socket', () => {

socketServer.sendMessage(socket, channel, 'token_transfer', { token_transfers: [ tokenTransferMock.erc1155B, tokenTransferMock.erc20 ] });

await page.waitForSelector('tbody tr:nth-child(3)');
const thirdRow = page.locator('tbody tr:nth-child(3)');
await thirdRow.waitFor();

const itemsCountNew = await page.locator('tbody tr').count();
expect(itemsCountNew).toBe(3);
Expand Down Expand Up @@ -221,7 +224,8 @@ test.describe('socket', () => {
{ token_transfers: [ tokenTransferMock.erc1155B, tokenTransferMock.erc20, tokenTransferMock.erc1155C, tokenTransferMock.erc721 ] },
);

await page.waitForSelector('tbody tr:nth-child(3)');
const thirdRow = page.locator('tbody tr:nth-child(3)');
await thirdRow.waitFor();

const itemsCountNew = await page.locator('tbody tr').count();
expect(itemsCountNew).toBe(3);
Expand Down
2 changes: 1 addition & 1 deletion ui/address/AddressTokens.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ test.describe('mobile', () => {
test.describe('update balances via socket', () => {
test.describe.configure({ mode: 'serial' });

test('', async({ render, page, createSocket, mockApiResponse }) => {
test('base flow', async({ render, page, createSocket, mockApiResponse }) => {
test.slow();

const hooksConfig = {
Expand Down
17 changes: 11 additions & 6 deletions ui/address/AddressTxs.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ test.describe('base view', () => {
test.describe('screen xl', () => {
test.use({ viewport: pwConfig.viewport.xl });

test('', async() => {
test('base view', async() => {
test.slow();
await expect(component).toHaveScreenshot();
});
Expand Down Expand Up @@ -83,7 +83,8 @@ test.describe('socket', () => {

socketServer.sendMessage(socket, channel, 'transaction', { transactions: [ txMock.base2, txMock.base4 ] });

await page.waitForSelector('tbody tr:nth-child(3)');
const thirdRow = page.locator('tbody tr:nth-child(3)');
await thirdRow.waitFor();

const itemsCountNew = await page.locator('tbody tr').count();
expect(itemsCountNew).toBe(4);
Expand Down Expand Up @@ -112,7 +113,8 @@ test.describe('socket', () => {

socketServer.sendMessage(socket, channel, 'transaction', { transactions: [ txMock.base, txMock.base2 ] });

await page.waitForSelector('tbody tr:nth-child(3)');
const thirdRow = page.locator('tbody tr:nth-child(3)');
await thirdRow.waitFor();

const itemsCountNew = await page.locator('tbody tr').count();
expect(itemsCountNew).toBe(3);
Expand Down Expand Up @@ -141,7 +143,8 @@ test.describe('socket', () => {

socketServer.sendMessage(socket, channel, 'transaction', { transactions: [ txMock.base2, txMock.base3, txMock.base4 ] });

await page.waitForSelector('tbody tr:nth-child(3)');
const thirdRow = page.locator('tbody tr:nth-child(3)');
await thirdRow.waitFor();

const itemsCountNew = await page.locator('tbody tr').count();
expect(itemsCountNew).toBe(3);
Expand Down Expand Up @@ -179,7 +182,8 @@ test.describe('socket', () => {

socketServer.sendMessage(socket, channel, 'transaction', { transactions: [ txMock.base2, txMock.base4 ] });

await page.waitForSelector('tbody tr:nth-child(3)');
const thirdRow = page.locator('tbody tr:nth-child(3)');
await thirdRow.waitFor();

const itemsCountNew = await page.locator('tbody tr').count();
expect(itemsCountNew).toBe(3);
Expand Down Expand Up @@ -214,7 +218,8 @@ test.describe('socket', () => {

socketServer.sendMessage(socket, channel, 'transaction', { transactions: [ txMock.base2, txMock.base3, txMock.base4 ] });

await page.waitForSelector('tbody tr:nth-child(3)');
const thirdRow = page.locator('tbody tr:nth-child(3)');
await thirdRow.waitFor();

const itemsCountNew = await page.locator('tbody tr').count();
expect(itemsCountNew).toBe(3);
Expand Down
8 changes: 4 additions & 4 deletions ui/apiKey/ApiKeyModal/ApiKeyForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const ApiKeyForm: React.FC<Props> = ({ data, onClose, setAlertVisible }) => {
});
};

const mutation = useMutation({
const { mutateAsync, isPending } = useMutation({
mutationFn: updateApiKey,
onSuccess: async(data) => {
const response = data as unknown as ApiKey;
Expand Down Expand Up @@ -89,8 +89,8 @@ const ApiKeyForm: React.FC<Props> = ({ data, onClose, setAlertVisible }) => {

const onSubmit: SubmitHandler<Inputs> = useCallback(async(data) => {
setAlertVisible(false);
await mutation.mutateAsync(data);
}, [ mutation, setAlertVisible ]);
await mutateAsync(data);
}, [ mutateAsync, setAlertVisible ]);

return (
<FormProvider { ...formApi }>
Expand Down Expand Up @@ -119,7 +119,7 @@ const ApiKeyForm: React.FC<Props> = ({ data, onClose, setAlertVisible }) => {
size="lg"
type="submit"
isDisabled={ !formApi.formState.isDirty }
isLoading={ mutation.isPending }
isLoading={ isPending }
>
{ data ? 'Save' : 'Generate API key' }
</Button>
Expand Down
14 changes: 6 additions & 8 deletions ui/block/useBlockTxsQuery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,12 @@ export default function useBlockTxsQuery({ heightOrHash, blockQuery, tab }: Para
((apiQuery.isError || apiQuery.isPlaceholderData) && apiQuery.errorUpdateCount > 0)
) && rpcQuery.data && publicClient);

const rpcQueryWithPages: QueryWithPagesResult<'block_txs'> = React.useMemo(() => {
return {
...rpcQuery as UseQueryResult<BlockTransactionsResponse, ResourceError>,
pagination: emptyPagination,
onFilterChange: () => {},
onSortingChange: () => {},
};
}, [ rpcQuery ]);
const rpcQueryWithPages: QueryWithPagesResult<'block_txs'> = {
...rpcQuery as UseQueryResult<BlockTransactionsResponse, ResourceError>,
pagination: emptyPagination,
onFilterChange: () => {},
onSortingChange: () => {},
};

const query = isRpcQuery ? rpcQueryWithPages : apiQuery;

Expand Down
14 changes: 6 additions & 8 deletions ui/block/useBlockWithdrawalsQuery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,12 @@ export default function useBlockWithdrawalsQuery({ heightOrHash, blockQuery, tab
((apiQuery.isError || apiQuery.isPlaceholderData) && apiQuery.errorUpdateCount > 0)
) && rpcQuery.data && publicClient);

const rpcQueryWithPages: QueryWithPagesResult<'block_withdrawals'> = React.useMemo(() => {
return {
...rpcQuery as UseQueryResult<BlockWithdrawalsResponse, ResourceError>,
pagination: emptyPagination,
onFilterChange: () => {},
onSortingChange: () => {},
};
}, [ rpcQuery ]);
const rpcQueryWithPages: QueryWithPagesResult<'block_withdrawals'> = {
...rpcQuery as UseQueryResult<BlockWithdrawalsResponse, ResourceError>,
pagination: emptyPagination,
onFilterChange: () => {},
onSortingChange: () => {},
};

const query = isRpcQuery ? rpcQueryWithPages : apiQuery;

Expand Down
8 changes: 4 additions & 4 deletions ui/customAbi/CustomAbiModal/CustomAbiForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const CustomAbiForm: React.FC<Props> = ({ data, onClose, onSuccess, setAlertVisi
});
};

const mutation = useMutation({
const { mutateAsync, isPending } = useMutation({
mutationFn: customAbiKey,
onSuccess: async(data) => {
const response = data as unknown as CustomAbi;
Expand Down Expand Up @@ -101,8 +101,8 @@ const CustomAbiForm: React.FC<Props> = ({ data, onClose, onSuccess, setAlertVisi
const onSubmit: SubmitHandler<Inputs> = useCallback(async(formData) => {
setAlertVisible(false);
const id = data && 'id' in data ? String(data.id) : undefined;
await mutation.mutateAsync({ ...formData, id });
}, [ mutation, data, setAlertVisible ]);
await mutateAsync({ ...formData, id });
}, [ mutateAsync, data, setAlertVisible ]);

return (
<FormProvider { ...formApi }>
Expand Down Expand Up @@ -140,7 +140,7 @@ const CustomAbiForm: React.FC<Props> = ({ data, onClose, onSuccess, setAlertVisi
size="lg"
type="submit"
isDisabled={ !formApi.formState.isDirty }
isLoading={ mutation.isPending }
isLoading={ isPending }
>
{ data && 'id' in data ? 'Save' : 'Create custom ABI' }
</Button>
Expand Down
2 changes: 1 addition & 1 deletion ui/pages/Home.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ test.describe('default view', () => {
test.describe('screen xl', () => {
test.use({ viewport: pwConfig.viewport.xl });

test('', async({ page }) => {
test('base view', async({ page }) => {
await expect(component).toHaveScreenshot({
mask: [ page.locator(pwConfig.adsBannerSelector) ],
maskColor: pwConfig.maskColor,
Expand Down
8 changes: 4 additions & 4 deletions ui/shared/DeleteModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const DeleteModal: React.FC<Props> = ({
onClose();
}, [ onClose, setAlertVisible ]);

const mutation = useMutation({
const { mutate, isPending } = useMutation({
mutationFn,
onSuccess: async() => {
onSuccess();
Expand All @@ -52,8 +52,8 @@ const DeleteModal: React.FC<Props> = ({

const onDeleteClick = useCallback(() => {
setAlertVisible(false);
mutation.mutate();
}, [ setAlertVisible, mutation ]);
mutate();
}, [ setAlertVisible, mutate ]);

const isMobile = useIsMobile();

Expand All @@ -71,7 +71,7 @@ const DeleteModal: React.FC<Props> = ({
<Button
size="lg"
onClick={ onDeleteClick }
isLoading={ mutation.isPending }
isLoading={ isPending }
// FIXME: chackra's button is disabled when isLoading
isDisabled={ false }
>
Expand Down
2 changes: 1 addition & 1 deletion ui/shared/entities/address/AddressEntity.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test.use({ viewport: { width: 180, height: 140 } });

test.describe('icon size', () => {
iconSizes.forEach((size) => {
test(size, async({ render }) => {
test(`${ size }`, async({ render }) => {
const component = await render(
<AddressEntity
address={ addressMock.withoutName }
Expand Down
2 changes: 1 addition & 1 deletion ui/shared/entities/block/BlockEntity.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ test.use({ viewport: { width: 180, height: 30 } });

test.describe('icon sizes', () => {
iconSizes.forEach((size) => {
test(size, async({ render }) => {
test(`${ size }`, async({ render }) => {
const component = await render(
<BlockEntity
number={ 17943507 }
Expand Down
5 changes: 3 additions & 2 deletions ui/shared/entities/ens/EnsEntity.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test.use({ viewport: { width: 180, height: 30 } });

test.describe('icon size', () => {
iconSizes.forEach((size) => {
test(size, async({ render }) => {
test(`${ size }`, async({ render }) => {
const component = await render(
<EnsEntity
domain={ name }
Expand Down Expand Up @@ -61,8 +61,9 @@ test('customization', async({ render }) => {
await expect(component).toHaveScreenshot();
});

test.describe('', () => {
test.describe('tooltip test', () => {
test.use({ viewport: { width: 300, height: 400 } });

test('with protocol info', async({ render, page, mockAssetResponse }) => {
await mockAssetResponse(domainMock.ensDomainA.protocol?.icon_url as string, './playwright/mocks/image_s.jpg');

Expand Down
Diff not rendered.
2 changes: 1 addition & 1 deletion ui/shared/entities/nft/NftEntity.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test.use({ viewport: { width: 180, height: 30 } });

test.describe('icon sizes', () => {
iconSizes.forEach((size) => {
test(size, async({ render }) => {
test(`${ size }`, async({ render }) => {
const component = await render(
<NftEntity
hash={ hash }
Expand Down
2 changes: 1 addition & 1 deletion ui/shared/entities/token/TokenEntity.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test.use({ viewport: { width: 300, height: 100 } });

test.describe('icon size', () => {
iconSizes.forEach((size) => {
test(size, async({ render }) => {
test(`${ size }`, async({ render }) => {
const component = await render(
<TokenEntity
token={ tokenMock.tokenInfo }
Expand Down
2 changes: 1 addition & 1 deletion ui/shared/entities/tx/TxEntity.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test.use({ viewport: { width: 180, height: 30 } });

test.describe('icon size', () => {
iconSizes.forEach((size) => {
test(size, async({ render }) => {
test(`${ size }`, async({ render }) => {
const component = await render(
<TxEntity
hash={ hash }
Expand Down
2 changes: 1 addition & 1 deletion ui/shared/entities/userOp/UserOpEntity.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test.use({ viewport: { width: 180, height: 30 } });

test.describe('icon size', () => {
iconSizes.forEach((size) => {
test(size, async({ render }) => {
test(`${ size }`, async({ render }) => {
const component = await render(
<UserOpEntity
hash={ hash }
Expand Down
2 changes: 1 addition & 1 deletion ui/snippets/footer/Footer.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ test.describe('with custom links, max cols', () => {
test.describe('screen xl', () => {
test.use({ viewport: pwConfig.viewport.xl });

test('', async({ page }) => {
test('base view', async({ page }) => {
await expect(page).toHaveScreenshot();
});
});
Expand Down
Diff not rendered.
6 changes: 3 additions & 3 deletions ui/snippets/navigation/vertical/NavigationDesktop.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ authTest.describe('auth', () => {
test.describe('with tooltips', () => {
test.use({ viewport: pwConfig.viewport.xl });

test('', async({ render, page }) => {
test('base view', async({ render, page }) => {
const component = await render(
<Flex w="100%" minH="100vh" alignItems="stretch">
<NavigationDesktop/>
Expand Down Expand Up @@ -120,14 +120,14 @@ test.describe('with submenu', () => {
await page.locator('div[aria-label="Blockchain link group"]').hover();
});

test('', async() => {
test('base view', async() => {
await expect(component).toHaveScreenshot();
});

test.describe('xl screen', () => {
test.use({ viewport: pwConfig.viewport.xl });

test('', async() => {
test('base view', async() => {
await expect(component).toHaveScreenshot();
});
});
Expand Down
Diff not rendered.
Diff not rendered.
Diff not rendered.
Loading
Loading