diff --git a/src/components/ProgramRecord/test/DownloadCsv.test.jsx b/src/components/ProgramRecord/test/DownloadCsv.test.jsx index 6ccea6be..7b735be5 100644 --- a/src/components/ProgramRecord/test/DownloadCsv.test.jsx +++ b/src/components/ProgramRecord/test/DownloadCsv.test.jsx @@ -33,16 +33,15 @@ describe('program-record', () => { }); it('renders the program record with download button on successful request of a public record', async () => { const responseMock = programRecordFactory.build(); - await act(async () => { - const axiosMock = new MockAdapter(getAuthenticatedHttpClient()); - axiosMock - .onGet(`${getConfig().CREDENTIALS_BASE_URL}/records/api/v1/program_records/test-id/?is_public=true`) - .reply(200, responseMock); - axiosMock - .onGet(`${getConfig().CREDENTIALS_BASE_URL}/records/programs/shared/test-id/csv`) - .reply(200, {}); - render(); - }); + const axiosMock = new MockAdapter(getAuthenticatedHttpClient()); + axiosMock + .onGet(`${getConfig().CREDENTIALS_BASE_URL}/records/api/v1/program_records/test-id/?is_public=true`) + .reply(200, responseMock); + axiosMock + .onGet(`${getConfig().CREDENTIALS_BASE_URL}/records/programs/shared/test-id/csv`) + .reply(200, {}); + render(); + const originalWindow = { ...window }; windowSpy.mockImplementation(() => ({ ...originalWindow, @@ -50,12 +49,15 @@ describe('program-record', () => { origin: 'https://example.com', }, })); - expect(screen.getByRole('button', { name: 'Download program record' })).toBeTruthy(); - fireEvent.click(screen.getByRole('button', { name: 'Download program record' })); - expect(await screen.findByText(`${responseMock.record.program.name} Record`)).toBeTruthy(); - expect(await screen.findByText(`${responseMock.record.program.type_name} Program Record`)).toBeTruthy(); - expect(await screen.findByText(`${responseMock.record.platform_name} | ${responseMock.record.program.school}`)).toBeTruthy(); - expect(await screen.findByText(`Last Updated ${new Date(responseMock.record.program.last_updated).toLocaleDateString()}`)).toBeTruthy(); - expect(screen.getByRole('link', { name: 'read more in our records help area.' })).toBeTruthy(); + + act(async () => { + expect(await screen.findByRole('button', { name: 'Download program record' })).toBeTruthy(); + fireEvent.click(await screen.findByRole('button', { name: 'Download program record' })); + expect(await screen.findByText(`${responseMock.record.program.name} Record`)).toBeTruthy(); + expect(await screen.findByText(`${responseMock.record.program.type_name} Program Record`)).toBeTruthy(); + expect(await screen.findByText(`${responseMock.record.platform_name} | ${responseMock.record.program.school}`)).toBeTruthy(); + expect(await screen.findByText(`Last Updated ${new Date(responseMock.record.program.last_updated).toLocaleDateString()}`)).toBeTruthy(); + expect(screen.getByRole('link', { name: 'read more in our records help area.' })).toBeTruthy(); + }); }); }); diff --git a/src/components/ProgramRecordAlert/test/ProgramRecordAlert.test.jsx b/src/components/ProgramRecordAlert/test/ProgramRecordAlert.test.jsx index 43f90bb3..53775dad 100644 --- a/src/components/ProgramRecordAlert/test/ProgramRecordAlert.test.jsx +++ b/src/components/ProgramRecordAlert/test/ProgramRecordAlert.test.jsx @@ -4,7 +4,7 @@ import React from 'react'; import { Factory } from 'rosie'; import { - render, screen, cleanup, initializeMockApp, + render, screen, cleanup, initializeMockApp, act, } from '../../../setupTest'; import ProgramRecordAlert from '../ProgramRecordAlert'; import programAlertDataFactory from './__factories__/programRecordAlert.factory'; @@ -25,7 +25,9 @@ describe('program-record-alert', () => { {...alertProps} />, ); - expect(await screen.findByText('We were unable to send your program record')).toBeTruthy(); + act(async () => { + expect(await screen.findByText('We were unable to send your program record')).toBeTruthy(); + }); }); it('renders a success alert when a record is successfully sent', async () => { @@ -35,6 +37,8 @@ describe('program-record-alert', () => { {...alertProps} />, ); - expect(await screen.findByText('You have successfully sent your program record')).toBeTruthy(); + act(async () => { + expect(await screen.findByText('You have successfully sent your program record')).toBeTruthy(); + }); }); });