Add whatwg-fetch and fixes to Playlist tests that break when polyfill is added

pull/85578/head
Tom Ratcliffe 1 year ago committed by Tom Ratcliffe
parent 2ab13071fb
commit 6557f5a00e
  1. 3
      public/app/features/playlist/PlaylistEditPage.test.tsx
  2. 4
      public/app/features/playlist/PlaylistNewPage.test.tsx

@ -1,3 +1,4 @@
import 'whatwg-fetch';
import { fireEvent, render, screen, waitFor } from '@testing-library/react'; import { fireEvent, render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event'; import userEvent from '@testing-library/user-event';
import { History, Location } from 'history'; import { History, Location } from 'history';
@ -32,7 +33,7 @@ async function getTestContext({ name, interval, items, uid }: Partial<Playlist>
const location = {} as Location; const location = {} as Location;
const history = {} as History; const history = {} as History;
const getMock = jest.spyOn(backendSrv, 'get'); const getMock = jest.spyOn(backendSrv, 'get');
const putMock = jest.spyOn(backendSrv, 'put'); const putMock = jest.spyOn(backendSrv, 'put').mockImplementation(() => Promise.resolve());
getMock.mockResolvedValue({ getMock.mockResolvedValue({
name: 'Test Playlist', name: 'Test Playlist',

@ -1,3 +1,4 @@
import 'whatwg-fetch';
import { fireEvent, render, screen, waitFor } from '@testing-library/react'; import { fireEvent, render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event'; import userEvent from '@testing-library/user-event';
import React from 'react'; import React from 'react';
@ -25,7 +26,8 @@ jest.mock('app/core/components/TagFilter/TagFilter', () => ({
function getTestContext({ name, interval, items }: Partial<Playlist> = {}) { function getTestContext({ name, interval, items }: Partial<Playlist> = {}) {
jest.clearAllMocks(); jest.clearAllMocks();
const playlist = { name, items, interval } as unknown as Playlist; const playlist = { name, items, interval } as unknown as Playlist;
const backendSrvMock = jest.spyOn(backendSrv, 'post'); const backendSrvMock = jest.spyOn(backendSrv, 'post').mockImplementation(() => Promise.resolve());
jest.spyOn(backendSrv, 'search').mockResolvedValue([]);
const { rerender } = render( const { rerender } = render(
<TestProvider> <TestProvider>

Loading…
Cancel
Save