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