Reset cache for all tests and remove describe

This commit is contained in:
Mark Kaylor 2022-10-28 11:49:23 +02:00
parent 54ad17928e
commit 78b86c96c8

View File

@ -19,9 +19,10 @@ import { createMemoryHistory } from 'history';
import MarketPlacePage from '../index';
import server from './server';
// Increase the jest timeout to accommodate long running tests
jest.setTimeout(30000);
const toggleNotification = jest.fn();
jest.mock('../../../hooks/useNavigatorOnLine', () => jest.fn(() => true));
jest.setTimeout(30000);
jest.mock('@strapi/helper-plugin', () => ({
...jest.requireActual('@strapi/helper-plugin'),
useNotification: jest.fn(() => {
@ -63,6 +64,8 @@ describe('Plugins tab', () => {
afterEach(() => {
server.resetHandlers();
// Clear the cache to isolate each test
client.clear();
});
afterAll(() => server.close());
@ -82,11 +85,12 @@ describe('Plugins tab', () => {
</QueryClientProvider>
);
await waitForReload();
renderedContainer = container;
});
it('renders and matches the plugin tab snapshot', async () => {
await waitForReload();
// Check snapshot
expect(renderedContainer.firstChild).toMatchSnapshot();
@ -127,9 +131,6 @@ describe('Plugins tab', () => {
});
it('shows the installed text for installed plugins', () => {
const pluginsTab = screen.getByRole('tab', { name: /plugins/i });
userEvent.click(pluginsTab);
// Plugin that's already installed
const alreadyInstalledCard = screen
.getAllByTestId('npm-package-card')
@ -197,21 +198,6 @@ describe('Plugins tab', () => {
});
});
describe('filter requests', () => {
beforeAll(() => {
// Clear cache before all the tests run
client.clear();
});
beforeEach(async () => {
await waitForReload();
});
afterEach(() => {
// Clear the cache again after each test
client.clear();
});
it('filters a collection option', async () => {
const filtersButton = screen.getByRole('button', { name: /filters/i });
userEvent.click(filtersButton);
@ -395,5 +381,4 @@ describe('Plugins tab', () => {
userEvent.click(screen.getByRole('tab', { name: /plugins/i }));
expect(collectionCards.length).toBe(2);
});
});
});