Use testid more in markatplace tests

This commit is contained in:
Rémi de Juvigny 2022-11-25 16:33:05 +01:00 committed by Fernando Chavez
parent 2221d7e93f
commit 4d7bb545bb
2 changed files with 20 additions and 21 deletions

View File

@ -191,7 +191,7 @@ describe('Marketplace page - plugins tab', () => {
const collectionsButton = screen.getByTestId('Collections-button');
await user.click(collectionsButton);
const option = screen.getByRole('option', { name: 'Made by Strapi (13)' });
const option = screen.getByTestId('Made by Strapi-13');
await user.click(option);
await waitForReload();
@ -214,7 +214,7 @@ describe('Marketplace page - plugins tab', () => {
const categoriesButton = screen.getByTestId('Categories-button');
await user.click(categoriesButton);
const option = screen.getByRole('option', { name: `Custom fields (4)` });
const option = screen.getByTestId('Custom fields-4');
await user.click(option);
await waitForReload();
@ -238,7 +238,7 @@ describe('Marketplace page - plugins tab', () => {
// When they click the select button
await user.click(collectionsButton);
// They should see a Made by Strapi option
const collectionOption = screen.getByRole('option', { name: `Made by Strapi (13)` });
const collectionOption = screen.getByTestId('Made by Strapi-13');
// When they click the option
await user.click(collectionOption);
// When they click the filters button again
@ -250,7 +250,7 @@ describe('Marketplace page - plugins tab', () => {
// They should the categories button with no options selected
const categoriesButton = screen.getByTestId('Categories-button');
await user.click(categoriesButton);
const categoryOption = screen.getByRole('option', { name: `Custom fields (4)` });
const categoryOption = screen.getByTestId('Custom fields-4');
await user.click(categoryOption);
// When the page reloads they should see a tag for the selected option
await waitForReload();
@ -276,7 +276,7 @@ describe('Marketplace page - plugins tab', () => {
it('filters multiple collection options', async () => {
await user.click(screen.getByTestId('filters-button'));
await user.click(screen.getByTestId('Collections-button'));
await user.click(screen.getByRole('option', { name: `Made by Strapi (13)` }));
await user.click(screen.getByTestId('Made by Strapi-13'));
await waitForReload();
@ -300,7 +300,7 @@ describe('Marketplace page - plugins tab', () => {
it('filters multiple category options', async () => {
await user.click(screen.getByTestId('filters-button'));
await user.click(screen.getByTestId('Categories-button'));
await user.click(screen.getByRole('option', { name: `Custom fields (4)` }));
await user.click(screen.getByTestId('Custom fields-4'));
await waitForReload();
@ -328,7 +328,7 @@ describe('Marketplace page - plugins tab', () => {
const collectionsButton = screen.getByTestId('Collections-button');
await user.click(collectionsButton);
const option = screen.getByRole('option', { name: 'Made by Strapi (13)' });
const option = screen.getByTestId('Made by Strapi-13');
await user.click(option);
await waitForReload();
@ -343,13 +343,12 @@ describe('Marketplace page - plugins tab', () => {
it('only filters in the plugins tab', async () => {
const filtersButton = screen.getByTestId('filters-button');
await user.click(filtersButton);
const collectionsButton = screen.getByTestId('Collections-button');
await user.click(collectionsButton);
const option = screen.getByRole('option', { name: `Made by Strapi (13)` });
const option = screen.getByTestId('Made by Strapi-13');
await user.click(option);
const collectionCards = await screen.findAllByTestId('npm-package-card');
@ -369,8 +368,8 @@ describe('Marketplace page - plugins tab', () => {
await user.click(sortButton);
const alphabeticalOption = screen.getByRole('option', { name: 'Alphabetical order' });
const newestOption = screen.getByRole('option', { name: 'Newest' });
const alphabeticalOption = screen.getByText('Alphabetical order').closest('li');
const newestOption = screen.getByText('Newest').closest('li');
expect(alphabeticalOption).toBeVisible();
expect(newestOption).toBeVisible();
@ -380,7 +379,7 @@ describe('Marketplace page - plugins tab', () => {
const sortButton = screen.getByRole('combobox', { name: /Sort by/i });
await user.click(sortButton);
const newestOption = screen.getByRole('option', { name: 'Newest' });
const newestOption = screen.getByText('Newest').closest('li');
await user.click(newestOption);
expect(history.location.search).toEqual('?sort=submissionDate:desc&page=1');
});

View File

@ -178,7 +178,7 @@ describe('Marketplace page - providers tab', () => {
const collectionsButton = screen.getByTestId('Collections-button');
await user.click(collectionsButton);
const option = screen.getByRole('option', { name: `Made by Strapi (6)` });
const option = screen.getByTestId('Made by Strapi-6');
await user.click(option);
await waitForReload();
@ -197,7 +197,7 @@ describe('Marketplace page - providers tab', () => {
it('filters multiple collection options', async () => {
await user.click(screen.getByTestId('filters-button'));
await user.click(screen.getByTestId('Collections-button'));
await user.click(screen.getByRole('option', { name: `Made by Strapi (6)` }));
await user.click(screen.getByTestId('Made by Strapi-6'));
await waitForReload();
@ -225,7 +225,7 @@ describe('Marketplace page - providers tab', () => {
const collectionsButton = screen.getByTestId('Collections-button');
await user.click(collectionsButton);
const option = screen.getByRole('option', { name: `Made by Strapi (6)` });
const option = screen.getByTestId('Made by Strapi-6');
await user.click(option);
await waitForReload();
@ -245,18 +245,18 @@ describe('Marketplace page - providers tab', () => {
const collectionsButton = screen.getByTestId('Collections-button');
await user.click(collectionsButton);
const option = screen.getByRole('option', { name: `Made by Strapi (6)` });
const option = screen.getByTestId('Made by Strapi-6');
await user.click(option);
const collectionCards = await screen.findAllByTestId('npm-package-card');
expect(collectionCards.length).toBe(2);
await user.click(screen.getByRole('tab', { name: /plugins/i }));
await user.click((await screen.findByText(/plugins/i)).closest('button'));
const pluginCards = screen.getAllByTestId('npm-package-card');
expect(pluginCards.length).toBe(5);
await user.click(screen.getByRole('tab', { name: /providers/i }));
await user.click((await screen.findByText(/providers/i)).closest('button'));
expect(collectionCards.length).toBe(2);
});
@ -265,8 +265,8 @@ describe('Marketplace page - providers tab', () => {
const sortButton = screen.getByRole('combobox', { name: /Sort by/i });
await user.click(sortButton);
const alphabeticalOption = screen.getByRole('option', { name: 'Alphabetical order' });
const newestOption = screen.getByRole('option', { name: 'Newest' });
const alphabeticalOption = screen.getByText('Alphabetical order').closest('li');
const newestOption = screen.getByText('Newest').closest('li');
expect(alphabeticalOption).toBeVisible();
expect(newestOption).toBeVisible();
@ -277,7 +277,7 @@ describe('Marketplace page - providers tab', () => {
const sortButton = screen.getByRole('combobox', { name: /Sort by/i });
await user.click(sortButton);
const newestOption = screen.getByRole('option', { name: 'Newest' });
const newestOption = screen.getByText('Newest').closest('li');
await user.click(newestOption);
expect(history.location.search).toEqual(