fix: fixing broken tests
This commit is contained in:
committed by
Adolfo R. Brandes
parent
67faf9a63a
commit
9b4cf8718f
@@ -85,7 +85,7 @@ describe('Custom Hooks', () => {
|
||||
|
||||
fireEvent.scroll(window);
|
||||
|
||||
expect(fetchNextPage).toHaveBeenCalledTimes(1);
|
||||
expect(fetchNextPage).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it('does not call fetchNextPage if not near the bottom', () => {
|
||||
|
||||
@@ -9,6 +9,10 @@ import {
|
||||
waitFor,
|
||||
within,
|
||||
} from '../testUtils';
|
||||
import { executeThunk } from '../utils';
|
||||
import initializeStore from '../store';
|
||||
import { getApiWaffleFlagsUrl } from '../data/api';
|
||||
import { fetchWaffleFlags } from '../data/thunks';
|
||||
import mockResult from './__mocks__/library-search.json';
|
||||
import mockEmptyResult from '../search-modal/__mocks__/empty-search-result.json';
|
||||
import {
|
||||
@@ -50,11 +54,17 @@ const returnEmptyResult = (_url, req) => {
|
||||
|
||||
const path = '/library/:libraryId/*';
|
||||
const libraryTitle = mockContentLibrary.libraryData.title;
|
||||
let store;
|
||||
|
||||
describe('<LibraryAuthoringPage />', () => {
|
||||
beforeEach(() => {
|
||||
beforeEach(async () => {
|
||||
const { axiosMock } = initializeMocks();
|
||||
store = initializeStore();
|
||||
axiosMock.onGet(getStudioHomeApiUrl()).reply(200, studioHomeMock);
|
||||
axiosMock
|
||||
.onGet(getApiWaffleFlagsUrl())
|
||||
.reply(200, {});
|
||||
await executeThunk(fetchWaffleFlags(), store.dispatch);
|
||||
|
||||
// The Meilisearch client-side API uses fetch, not Axios.
|
||||
fetchMock.mockReset();
|
||||
@@ -683,9 +693,13 @@ describe('<LibraryAuthoringPage />', () => {
|
||||
...studioHomeMock,
|
||||
libraries_v2_enabled: false,
|
||||
});
|
||||
axiosMock
|
||||
.onGet(getApiWaffleFlagsUrl())
|
||||
.reply(200, {});
|
||||
await executeThunk(fetchWaffleFlags(), store.dispatch);
|
||||
|
||||
render(<LibraryLayout />, { path, params: { libraryId: mockContentLibrary.libraryId } });
|
||||
await waitFor(() => { expect(axiosMock.history.get.length).toBe(1); });
|
||||
await waitFor(() => { expect(axiosMock.history.get.length).toBe(4); });
|
||||
expect(screen.getByRole('alert')).toHaveTextContent('This page cannot be shown: Libraries v2 are disabled.');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -17,10 +17,14 @@ import {
|
||||
mockCreateLibraryBlock,
|
||||
mockXBlockFields,
|
||||
} from '../data/api.mocks';
|
||||
import initializeStore from '../../store';
|
||||
import { executeThunk } from '../../utils';
|
||||
import { mockBroadcastChannel, mockClipboardEmpty } from '../../generic/data/api.mock';
|
||||
import { mockContentSearchConfig, mockSearchResult } from '../../search-manager/data/api.mock';
|
||||
import { studioHomeMock } from '../../studio-home/__mocks__';
|
||||
import { getStudioHomeApiUrl } from '../../studio-home/data/api';
|
||||
import { getApiWaffleFlagsUrl } from '../../data/api';
|
||||
import { fetchWaffleFlags } from '../../data/thunks';
|
||||
import LibraryLayout from '../LibraryLayout';
|
||||
|
||||
mockContentSearchConfig.applyMock();
|
||||
@@ -47,10 +51,17 @@ const renderOpts = {
|
||||
routerProps: { initialEntries: [`/library/${libraryId}/components`] },
|
||||
};
|
||||
|
||||
let store;
|
||||
|
||||
describe('AddContentWorkflow test', () => {
|
||||
beforeEach(() => {
|
||||
beforeEach(async () => {
|
||||
const { axiosMock } = initializeMocks();
|
||||
store = initializeStore();
|
||||
axiosMock.onGet(getStudioHomeApiUrl()).reply(200, studioHomeMock);
|
||||
axiosMock
|
||||
.onGet(getApiWaffleFlagsUrl())
|
||||
.reply(200, {});
|
||||
await executeThunk(fetchWaffleFlags(), store.dispatch);
|
||||
});
|
||||
|
||||
it('can create an HTML component', async () => {
|
||||
|
||||
@@ -6,6 +6,8 @@ import {
|
||||
screen,
|
||||
initializeMocks,
|
||||
} from '../../testUtils';
|
||||
import initializeStore from '../../store';
|
||||
import { executeThunk } from '../../utils';
|
||||
import { studioHomeMock } from '../../studio-home/__mocks__';
|
||||
import { getStudioHomeApiUrl } from '../../studio-home/data/api';
|
||||
import mockResult from '../__mocks__/library-search.json';
|
||||
@@ -17,6 +19,8 @@ import {
|
||||
mockGetCollectionMetadata,
|
||||
} from '../data/api.mocks';
|
||||
import { PickLibraryContentModal } from './PickLibraryContentModal';
|
||||
import { getApiWaffleFlagsUrl } from '../../data/api';
|
||||
import { fetchWaffleFlags } from '../../data/thunks';
|
||||
|
||||
mockContentSearchConfig.applyMock();
|
||||
mockContentLibrary.applyMock();
|
||||
@@ -27,6 +31,7 @@ const { libraryId } = mockContentLibrary;
|
||||
|
||||
const onClose = jest.fn();
|
||||
let mockShowToast: (message: string) => void;
|
||||
let store;
|
||||
|
||||
const render = () => baseRender(<PickLibraryContentModal isOpen onClose={onClose} />, {
|
||||
path: '/library/:libraryId/collection/:collectionId/*',
|
||||
@@ -43,10 +48,15 @@ const render = () => baseRender(<PickLibraryContentModal isOpen onClose={onClose
|
||||
});
|
||||
|
||||
describe('<PickLibraryContentModal />', () => {
|
||||
beforeEach(() => {
|
||||
beforeEach(async () => {
|
||||
const mocks = initializeMocks();
|
||||
store = initializeStore();
|
||||
mockShowToast = mocks.mockShowToast;
|
||||
mocks.axiosMock.onGet(getStudioHomeApiUrl()).reply(200, studioHomeMock);
|
||||
mocks.axiosMock
|
||||
.onGet(getApiWaffleFlagsUrl())
|
||||
.reply(200, {});
|
||||
await executeThunk(fetchWaffleFlags(), store.dispatch);
|
||||
});
|
||||
|
||||
it('can pick components from the modal', async () => {
|
||||
|
||||
Reference in New Issue
Block a user