Use total count in tabs and remove getByRole

This commit is contained in:
Rémi de Juvigny 2022-11-17 19:06:25 +01:00 committed by Fernando Chavez
parent dcd8318815
commit fdf3f6dcfb
7 changed files with 20 additions and 20 deletions

View File

@ -293,14 +293,14 @@ const MarketPlacePage = () => {
id: 'admin.pages.MarketPlacePage.plugins',
defaultMessage: 'Plugins',
})}{' '}
({pluginSearchResults.length})
({marketplacePluginsResponse.meta.pagination.total})
</Tab>
<Tab>
{formatMessage({
id: 'admin.pages.MarketPlacePage.providers',
defaultMessage: 'Providers',
})}{' '}
({providerSearchResults.length})
({marketplaceProvidersResponse.meta.pagination.total})
</Tab>
</Tabs>
</Box>

View File

@ -1111,7 +1111,7 @@ exports[`Marketplace page - layout renders the online layout 1`] = `
Plugins
(
5
96
)
</span>
</div>
@ -1134,7 +1134,7 @@ exports[`Marketplace page - layout renders the online layout 1`] = `
Providers
(
9
96
)
</span>
</div>

View File

@ -1111,7 +1111,7 @@ exports[`Marketplace page - plugins tab renders and matches the plugin tab snaps
Plugins
(
5
96
)
</span>
</div>
@ -1134,7 +1134,7 @@ exports[`Marketplace page - plugins tab renders and matches the plugin tab snaps
Providers
(
9
96
)
</span>
</div>

View File

@ -1163,7 +1163,7 @@ exports[`Marketplace page - providers tab renders and matches the providers tab
Plugins
(
5
96
)
</span>
</div>
@ -1187,7 +1187,7 @@ exports[`Marketplace page - providers tab renders and matches the providers tab
Providers
(
9
96
)
</span>
</div>

View File

@ -42,6 +42,8 @@ jest.mock('@strapi/helper-plugin', () => ({
})),
}));
const user = userEvent.setup();
const client = new QueryClient({
defaultOptions: {
queries: {
@ -133,7 +135,6 @@ describe('Marketplace page - layout', () => {
it('shows compatibility tooltip message when no version provided', async () => {
client.clear();
const user = userEvent.setup();
const { getByTestId } = render(App);
await waitForReload();
@ -186,7 +187,6 @@ describe('Marketplace page - layout', () => {
it('shows only downloads count and not github stars if there are no or 0 stars and no downloads available for any package', async () => {
client.clear();
const user = userEvent.setup();
render(App);
await waitForReload();

View File

@ -447,27 +447,27 @@ describe('Marketplace page - plugins tab', () => {
// Should have pagination section with 4 pages
const pagination = screen.getByLabelText(/pagination/i);
expect(pagination).toBeVisible();
const pageButtons = screen.getAllByRole('link', { name: /go to page \d+/i });
const pageButtons = screen.getAllByText(/go to page \d+/i).map((el) => el.closest('a'));
expect(pageButtons.length).toBe(4);
// Can't go to previous page since there isn't one
expect(screen.getByRole('link', { name: /go to previous page/i })).toHaveAttribute(
expect(screen.getByText(/go to previous page/i).closest('a')).toHaveAttribute(
'aria-disabled',
'true'
);
// Can go to next page
await user.click(screen.getByRole('link', { name: /go to next page/i }));
await user.click(screen.getByText(/go to next page/i).closest('a'));
await waitForReload();
expect(history.location.search).toBe('?page=2');
// Can go to previous page
await user.click(screen.getByRole('link', { name: /go to previous page/i }));
await user.click(screen.getByText(/go to previous page/i).closest('a'));
await waitForReload();
expect(history.location.search).toBe('?page=1');
// Can go to specific page
await user.click(screen.getByRole('link', { name: /go to page 3/i }));
await user.click(screen.getByText(/go to page 3/i).closest('a'));
await waitForReload();
expect(history.location.search).toBe('?page=3');
});

View File

@ -348,27 +348,27 @@ describe('Marketplace page - providers tab', () => {
// Should have pagination section with 4 pages
const pagination = screen.getByLabelText(/pagination/i);
expect(pagination).toBeVisible();
const pageButtons = screen.getAllByRole('link', { name: /go to page \d+/i });
const pageButtons = screen.getAllByText(/go to page \d+/i).map((el) => el.closest('a'));
expect(pageButtons.length).toBe(4);
// Can't go to previous page since there isn't one
expect(screen.getByRole('link', { name: /go to previous page/i })).toHaveAttribute(
expect(screen.getByText(/go to previous page/i).closest('a')).toHaveAttribute(
'aria-disabled',
'true'
);
// Can go to next page
await user.click(screen.getByRole('link', { name: /go to next page/i }));
await user.click(screen.getByText(/go to next page/i).closest('a'));
await waitForReload();
expect(history.location.search).toBe('?npmPackageType=provider&sort=name:asc&page=2');
// Can go to previous page
await user.click(screen.getByRole('link', { name: /go to previous page/i }));
await user.click(screen.getByText(/go to previous page/i).closest('a'));
await waitForReload();
expect(history.location.search).toBe('?npmPackageType=provider&sort=name:asc&page=1');
// Can go to specific page
await user.click(screen.getByRole('link', { name: /go to page 3/i }));
await user.click(screen.getByText(/go to page 3/i).closest('a'));
await waitForReload();
expect(history.location.search).toBe('?npmPackageType=provider&sort=name:asc&page=3');
});