diff --git a/awx/ui_next/src/App.test.jsx b/awx/ui_next/src/App.test.jsx index 805cbdc639..a76d9634b5 100644 --- a/awx/ui_next/src/App.test.jsx +++ b/awx/ui_next/src/App.test.jsx @@ -31,6 +31,5 @@ describe('', () => { }); expect(wrapper.length).toBe(1); jest.clearAllMocks(); - wrapper.unmount(); }); }); diff --git a/awx/ui_next/src/components/AdHocCommands/AdHocCommands.test.jsx b/awx/ui_next/src/components/AdHocCommands/AdHocCommands.test.jsx index 417e2a08d7..e9879a84fa 100644 --- a/awx/ui_next/src/components/AdHocCommands/AdHocCommands.test.jsx +++ b/awx/ui_next/src/components/AdHocCommands/AdHocCommands.test.jsx @@ -76,8 +76,8 @@ describe('', () => { }); }); let wrapper; + afterEach(() => { - wrapper.unmount(); jest.clearAllMocks(); }); diff --git a/awx/ui_next/src/components/AdHocCommands/AdHocCommandsWizard.test.jsx b/awx/ui_next/src/components/AdHocCommands/AdHocCommandsWizard.test.jsx index 1393a94ebf..d2866e7965 100644 --- a/awx/ui_next/src/components/AdHocCommands/AdHocCommandsWizard.test.jsx +++ b/awx/ui_next/src/components/AdHocCommands/AdHocCommandsWizard.test.jsx @@ -54,7 +54,6 @@ describe('', () => { }); afterEach(() => { jest.clearAllMocks(); - wrapper.unmount(); }); test('should mount properly', async () => { diff --git a/awx/ui_next/src/components/AdHocCommands/AdHocCredentialStep.test.jsx b/awx/ui_next/src/components/AdHocCommands/AdHocCredentialStep.test.jsx index 873b792278..f0cc546241 100644 --- a/awx/ui_next/src/components/AdHocCommands/AdHocCredentialStep.test.jsx +++ b/awx/ui_next/src/components/AdHocCommands/AdHocCredentialStep.test.jsx @@ -36,7 +36,6 @@ describe('', () => { }); afterEach(() => { jest.clearAllMocks(); - wrapper.unmount(); }); test('should mount properly', async () => { diff --git a/awx/ui_next/src/components/AdHocCommands/AdHocExecutionEnironmentStep.test.jsx b/awx/ui_next/src/components/AdHocCommands/AdHocExecutionEnironmentStep.test.jsx index 539ec5874e..a78a0a673c 100644 --- a/awx/ui_next/src/components/AdHocCommands/AdHocExecutionEnironmentStep.test.jsx +++ b/awx/ui_next/src/components/AdHocCommands/AdHocExecutionEnironmentStep.test.jsx @@ -33,9 +33,9 @@ describe('', () => { ); }); }); + afterEach(() => { jest.clearAllMocks(); - wrapper.unmount(); }); test('should mount properly', async () => { diff --git a/awx/ui_next/src/components/AddRole/SelectRoleStep.test.jsx b/awx/ui_next/src/components/AddRole/SelectRoleStep.test.jsx index 159ab0b3a1..c871db337e 100644 --- a/awx/ui_next/src/components/AddRole/SelectRoleStep.test.jsx +++ b/awx/ui_next/src/components/AddRole/SelectRoleStep.test.jsx @@ -34,6 +34,7 @@ describe('', () => { name: 'foo', }, ]; + test('initially renders without crashing', () => { wrapper = shallowWithContexts( ', () => { /> ); expect(wrapper.length).toBe(1); - wrapper.unmount(); }); + test('clicking role fires onRolesClick callback', () => { const onRolesClick = jest.fn(); wrapper = mountWithContexts( @@ -63,6 +64,5 @@ describe('', () => { name: 'Project Admin', description: 'Can manage all projects of the organization', }); - wrapper.unmount(); }); }); diff --git a/awx/ui_next/src/components/AppContainer/PageHeaderToolbar.test.jsx b/awx/ui_next/src/components/AppContainer/PageHeaderToolbar.test.jsx index 22b319289e..0966c8bc4e 100644 --- a/awx/ui_next/src/components/AppContainer/PageHeaderToolbar.test.jsx +++ b/awx/ui_next/src/components/AppContainer/PageHeaderToolbar.test.jsx @@ -14,10 +14,6 @@ describe('PageHeaderToolbar', () => { const onAboutClick = jest.fn(); const onLogoutClick = jest.fn(); - afterEach(() => { - wrapper.unmount(); - }); - test('expected content is rendered on initialization', async () => { await act(async () => { wrapper = mountWithContexts( diff --git a/awx/ui_next/src/components/CopyButton/CopyButton.test.jsx b/awx/ui_next/src/components/CopyButton/CopyButton.test.jsx index 894431bc2d..d1926945c4 100644 --- a/awx/ui_next/src/components/CopyButton/CopyButton.test.jsx +++ b/awx/ui_next/src/components/CopyButton/CopyButton.test.jsx @@ -8,9 +8,6 @@ jest.mock('../../api'); let wrapper; describe('', () => { - afterEach(() => { - wrapper.unmount(); - }); test('should mount properly', async () => { await act(async () => { wrapper = mountWithContexts( @@ -24,6 +21,7 @@ describe('', () => { }); expect(wrapper.find('CopyButton').length).toBe(1); }); + test('should call the correct function on button click', async () => { const copyItem = jest.fn(); await act(async () => { diff --git a/awx/ui_next/src/components/DataListToolbar/DataListToolbar.test.jsx b/awx/ui_next/src/components/DataListToolbar/DataListToolbar.test.jsx index 640cd0eec9..42d76280fb 100644 --- a/awx/ui_next/src/components/DataListToolbar/DataListToolbar.test.jsx +++ b/awx/ui_next/src/components/DataListToolbar/DataListToolbar.test.jsx @@ -15,13 +15,6 @@ describe('', () => { integerFields: ['page', 'page_size'], }; - afterEach(() => { - if (toolbar) { - toolbar.unmount(); - toolbar = null; - } - }); - const onSearch = jest.fn(); const onReplaceSearch = jest.fn(); const onSort = jest.fn(); diff --git a/awx/ui_next/src/components/DisassociateButton/DisassociateButton.test.jsx b/awx/ui_next/src/components/DisassociateButton/DisassociateButton.test.jsx index 5f0b76d330..6bed1acf6a 100644 --- a/awx/ui_next/src/components/DisassociateButton/DisassociateButton.test.jsx +++ b/awx/ui_next/src/components/DisassociateButton/DisassociateButton.test.jsx @@ -40,7 +40,6 @@ describe('', () => { afterAll(() => { jest.clearAllMocks(); - wrapper.unmount(); }); test('should render button', () => { diff --git a/awx/ui_next/src/components/ExpandCollapse/ExpandCollapse.test.jsx b/awx/ui_next/src/components/ExpandCollapse/ExpandCollapse.test.jsx index 74b37d6235..eb06b49c51 100644 --- a/awx/ui_next/src/components/ExpandCollapse/ExpandCollapse.test.jsx +++ b/awx/ui_next/src/components/ExpandCollapse/ExpandCollapse.test.jsx @@ -15,6 +15,5 @@ describe('', () => { /> ); expect(wrapper.length).toBe(1); - wrapper.unmount(); }); }); diff --git a/awx/ui_next/src/components/FieldWithPrompt/FieldWithPrompt.test.jsx b/awx/ui_next/src/components/FieldWithPrompt/FieldWithPrompt.test.jsx index 21d24444b1..e3361a9576 100644 --- a/awx/ui_next/src/components/FieldWithPrompt/FieldWithPrompt.test.jsx +++ b/awx/ui_next/src/components/FieldWithPrompt/FieldWithPrompt.test.jsx @@ -6,10 +6,6 @@ import FieldWithPrompt from './FieldWithPrompt'; describe('FieldWithPrompt', () => { let wrapper; - afterEach(() => { - wrapper.unmount(); - }); - test('Required asterisk and Popover hidden when not required and tooltip not provided', () => { wrapper = mountWithContexts( ', () => { let wrapper; - afterEach(() => { - wrapper.unmount(); - }); test('should be disabled when no rows are selected', () => { wrapper = mountWithContexts(); expect(wrapper.find('JobListCancelButton button').props().disabled).toBe( diff --git a/awx/ui_next/src/components/JobList/JobListItem.test.jsx b/awx/ui_next/src/components/JobList/JobListItem.test.jsx index 2e35f181a0..70f89fdb63 100644 --- a/awx/ui_next/src/components/JobList/JobListItem.test.jsx +++ b/awx/ui_next/src/components/JobList/JobListItem.test.jsx @@ -41,10 +41,6 @@ describe('', () => { ); }); - afterEach(() => { - wrapper.unmount(); - }); - test('initially renders successfully', () => { expect(wrapper.find('JobListItem').length).toBe(1); }); @@ -118,10 +114,6 @@ describe('', () => { ); }); - afterEach(() => { - wrapper.unmount(); - }); - test('launch button shown to users with launch capabilities', () => { expect(wrapper.find('LaunchButton').length).toBe(1); }); diff --git a/awx/ui_next/src/components/ListHeader/ListHeader.test.jsx b/awx/ui_next/src/components/ListHeader/ListHeader.test.jsx index f7199fe4d4..6cca8a7969 100644 --- a/awx/ui_next/src/components/ListHeader/ListHeader.test.jsx +++ b/awx/ui_next/src/components/ListHeader/ListHeader.test.jsx @@ -24,7 +24,6 @@ describe('ListHeader', () => { /> ); expect(wrapper.length).toBe(1); - wrapper.unmount(); }); test('should navigate when DataListToolbar calls onSort prop', async () => { diff --git a/awx/ui_next/src/components/Lookup/ApplicationLookup.test.jsx b/awx/ui_next/src/components/Lookup/ApplicationLookup.test.jsx index 45986151f4..10eac993bb 100644 --- a/awx/ui_next/src/components/Lookup/ApplicationLookup.test.jsx +++ b/awx/ui_next/src/components/Lookup/ApplicationLookup.test.jsx @@ -36,7 +36,6 @@ describe('ApplicationLookup', () => { afterEach(() => { jest.clearAllMocks(); - wrapper.unmount(); }); test('should render successfully', async () => { diff --git a/awx/ui_next/src/components/Lookup/ExecutionEnvironmentLookup.test.jsx b/awx/ui_next/src/components/Lookup/ExecutionEnvironmentLookup.test.jsx index a8a33d12a8..339f8235f7 100644 --- a/awx/ui_next/src/components/Lookup/ExecutionEnvironmentLookup.test.jsx +++ b/awx/ui_next/src/components/Lookup/ExecutionEnvironmentLookup.test.jsx @@ -38,7 +38,6 @@ describe('ExecutionEnvironmentLookup', () => { afterEach(() => { jest.clearAllMocks(); - wrapper.unmount(); }); test('should render successfully', async () => { diff --git a/awx/ui_next/src/components/Lookup/InventoryLookup.test.jsx b/awx/ui_next/src/components/Lookup/InventoryLookup.test.jsx index ac0662ad30..765ad87bf7 100644 --- a/awx/ui_next/src/components/Lookup/InventoryLookup.test.jsx +++ b/awx/ui_next/src/components/Lookup/InventoryLookup.test.jsx @@ -26,7 +26,6 @@ describe('InventoryLookup', () => { afterEach(() => { jest.clearAllMocks(); - wrapper.unmount(); }); test('should render successfully and fetch data', async () => { diff --git a/awx/ui_next/src/components/Lookup/MultiCredentialsLookup.test.jsx b/awx/ui_next/src/components/Lookup/MultiCredentialsLookup.test.jsx index 994a81b0b3..0cfb3a66b5 100644 --- a/awx/ui_next/src/components/Lookup/MultiCredentialsLookup.test.jsx +++ b/awx/ui_next/src/components/Lookup/MultiCredentialsLookup.test.jsx @@ -122,7 +122,6 @@ describe('', () => { afterEach(() => { jest.clearAllMocks(); - wrapper.unmount(); }); test('should load credential types', async () => { diff --git a/awx/ui_next/src/components/Lookup/OrganizationLookup.test.jsx b/awx/ui_next/src/components/Lookup/OrganizationLookup.test.jsx index e6941e71c8..873310120e 100644 --- a/awx/ui_next/src/components/Lookup/OrganizationLookup.test.jsx +++ b/awx/ui_next/src/components/Lookup/OrganizationLookup.test.jsx @@ -12,7 +12,6 @@ describe('OrganizationLookup', () => { afterEach(() => { jest.clearAllMocks(); - wrapper.unmount(); }); test('should render successfully', async () => { diff --git a/awx/ui_next/src/components/NotificationList/NotificationListItem.test.jsx b/awx/ui_next/src/components/NotificationList/NotificationListItem.test.jsx index 2cf6556334..7e8e384055 100644 --- a/awx/ui_next/src/components/NotificationList/NotificationListItem.test.jsx +++ b/awx/ui_next/src/components/NotificationList/NotificationListItem.test.jsx @@ -21,10 +21,6 @@ describe('', () => { }); afterEach(() => { - if (wrapper) { - wrapper.unmount(); - wrapper = null; - } jest.clearAllMocks(); }); diff --git a/awx/ui_next/src/components/PaginatedTable/ToolbarDeleteButton.test.jsx b/awx/ui_next/src/components/PaginatedTable/ToolbarDeleteButton.test.jsx index ef06a98e46..6acc5062e9 100644 --- a/awx/ui_next/src/components/PaginatedTable/ToolbarDeleteButton.test.jsx +++ b/awx/ui_next/src/components/PaginatedTable/ToolbarDeleteButton.test.jsx @@ -40,8 +40,8 @@ describe('', () => { afterEach(() => { jest.clearAllMocks(); - wrapper.unmount(); }); + test('should render button', () => { wrapper = mountWithContexts( {}} itemsToDelete={[]} /> diff --git a/awx/ui_next/src/components/PromptDetail/PromptProjectDetail.test.jsx b/awx/ui_next/src/components/PromptDetail/PromptProjectDetail.test.jsx index 34a7249f66..239b4cdac4 100644 --- a/awx/ui_next/src/components/PromptDetail/PromptProjectDetail.test.jsx +++ b/awx/ui_next/src/components/PromptDetail/PromptProjectDetail.test.jsx @@ -25,10 +25,6 @@ describe('PromptProjectDetail', () => { ); }); - afterAll(() => { - wrapper.unmount(); - }); - test('should render successfully', () => { expect(wrapper.find('PromptProjectDetail')).toHaveLength(1); }); diff --git a/awx/ui_next/src/components/ResourceAccessList/ResourceAccessList.test.jsx b/awx/ui_next/src/components/ResourceAccessList/ResourceAccessList.test.jsx index 6bcbc2b391..f4db363906 100644 --- a/awx/ui_next/src/components/ResourceAccessList/ResourceAccessList.test.jsx +++ b/awx/ui_next/src/components/ResourceAccessList/ResourceAccessList.test.jsx @@ -133,7 +133,6 @@ describe('', () => { }); afterEach(() => { - wrapper.unmount(); jest.clearAllMocks(); }); diff --git a/awx/ui_next/src/components/Schedule/Schedule.test.jsx b/awx/ui_next/src/components/Schedule/Schedule.test.jsx index 280c6af6bb..4390ed5f44 100644 --- a/awx/ui_next/src/components/Schedule/Schedule.test.jsx +++ b/awx/ui_next/src/components/Schedule/Schedule.test.jsx @@ -113,12 +113,11 @@ describe('', () => { }); await waitForElement(wrapper, 'ContentLoading', el => el.length === 0); }); - afterAll(() => { - wrapper.unmount(); - }); + test('renders successfully', async () => { expect(wrapper.length).toBe(1); }); + test('expect all tabs to exist, including Back to Schedules', async () => { expect( wrapper.find('button[link="/templates/job_template/1/schedules"]').length diff --git a/awx/ui_next/src/components/Schedule/ScheduleList/ScheduleList.test.jsx b/awx/ui_next/src/components/Schedule/ScheduleList/ScheduleList.test.jsx index 0981eac2bf..a7c5b876ec 100644 --- a/awx/ui_next/src/components/Schedule/ScheduleList/ScheduleList.test.jsx +++ b/awx/ui_next/src/components/Schedule/ScheduleList/ScheduleList.test.jsx @@ -52,10 +52,6 @@ describe('ScheduleList', () => { wrapper.update(); }); - afterEach(() => { - wrapper.unmount(); - }); - test('should fetch schedules from api and render the list', () => { expect(loadSchedules).toHaveBeenCalled(); expect(wrapper.find('ScheduleListItem').length).toBe(5); diff --git a/awx/ui_next/src/components/Schedule/ScheduleList/ScheduleListItem.test.jsx b/awx/ui_next/src/components/Schedule/ScheduleList/ScheduleListItem.test.jsx index 394128a095..94a48d9695 100644 --- a/awx/ui_next/src/components/Schedule/ScheduleList/ScheduleListItem.test.jsx +++ b/awx/ui_next/src/components/Schedule/ScheduleList/ScheduleListItem.test.jsx @@ -64,10 +64,6 @@ describe('ScheduleListItem', () => { ); }); - afterAll(() => { - wrapper.unmount(); - }); - test('Name correctly shown with correct link', () => { expect( wrapper @@ -149,10 +145,6 @@ describe('ScheduleListItem', () => { ); }); - afterAll(() => { - wrapper.unmount(); - }); - test('Name correctly shown with correct link', () => { expect( wrapper @@ -217,10 +209,6 @@ describe('ScheduleListItem', () => { ); }); - afterAll(() => { - wrapper.unmount(); - }); - test('should show missing resource icon', () => { expect(wrapper.find('ExclamationTriangleIcon').length).toBe(1); expect(wrapper.find('ScheduleToggle').prop('isDisabled')).toBe(true); diff --git a/awx/ui_next/src/components/Schedule/ScheduleOccurrences/ScheduleOccurrences.test.jsx b/awx/ui_next/src/components/Schedule/ScheduleOccurrences/ScheduleOccurrences.test.jsx index 199cb3d1b0..e507a32420 100644 --- a/awx/ui_next/src/components/Schedule/ScheduleOccurrences/ScheduleOccurrences.test.jsx +++ b/awx/ui_next/src/components/Schedule/ScheduleOccurrences/ScheduleOccurrences.test.jsx @@ -15,15 +15,15 @@ describe('', () => { /> ); }); - afterAll(() => { - wrapper.unmount(); - }); + test('Local option initially set', async () => { expect(wrapper.find('MultiButtonToggle').props().value).toBe('local'); }); + test('It renders the correct number of dates', async () => { expect(wrapper.find('dd').children().length).toBe(2); }); + test('Clicking UTC button toggles the dates to utc', async () => { wrapper.find('button[aria-label="UTC"]').simulate('click'); expect(wrapper.find('MultiButtonToggle').props().value).toBe('utc'); @@ -44,6 +44,7 @@ describe('', () => { ).toBe('3/30/2020, 4:00:00 AM'); }); }); + describe('Only one date passed in', () => { test('Component should not render chldren', async () => { wrapper = mountWithContexts( @@ -55,7 +56,6 @@ describe('', () => { /> ); expect(wrapper.find('ScheduleOccurrences').children().length).toBe(0); - wrapper.unmount(); }); }); }); diff --git a/awx/ui_next/src/components/ScreenHeader/ScreenHeader.test.jsx b/awx/ui_next/src/components/ScreenHeader/ScreenHeader.test.jsx index 99cee2f5d1..f16fd774e1 100644 --- a/awx/ui_next/src/components/ScreenHeader/ScreenHeader.test.jsx +++ b/awx/ui_next/src/components/ScreenHeader/ScreenHeader.test.jsx @@ -43,7 +43,6 @@ describe('', () => { expect(breadcrumbItem.first().text()).toBe('Foo'); expect(breadcrumbItem.last().text()).toBe('One'); expect(breadcrumbHeading.text()).toBe('Bar'); - breadcrumbWrapper.unmount(); }); test('renders breadcrumb items defined in breadcrumbConfig', () => { @@ -66,7 +65,6 @@ describe('', () => { expect(breadcrumbWrapper.find('BreadcrumbItem')).toHaveLength( crumbLength ); - breadcrumbWrapper.unmount(); }); }); }); diff --git a/awx/ui_next/src/components/Search/AdvancedSearch.test.jsx b/awx/ui_next/src/components/Search/AdvancedSearch.test.jsx index ef5a81c10a..79b63fe462 100644 --- a/awx/ui_next/src/components/Search/AdvancedSearch.test.jsx +++ b/awx/ui_next/src/components/Search/AdvancedSearch.test.jsx @@ -7,7 +7,6 @@ describe('', () => { let wrapper; afterEach(() => { - wrapper.unmount(); jest.clearAllMocks(); }); diff --git a/awx/ui_next/src/components/SelectableCard/SelectableCard.test.jsx b/awx/ui_next/src/components/SelectableCard/SelectableCard.test.jsx index a273161f55..75cab3dee6 100644 --- a/awx/ui_next/src/components/SelectableCard/SelectableCard.test.jsx +++ b/awx/ui_next/src/components/SelectableCard/SelectableCard.test.jsx @@ -8,11 +8,10 @@ describe('', () => { test('initially renders without crashing when not selected', () => { wrapper = shallow(); expect(wrapper.length).toBe(1); - wrapper.unmount(); }); + test('initially renders without crashing when selected', () => { wrapper = shallow(); expect(wrapper.length).toBe(1); - wrapper.unmount(); }); }); diff --git a/awx/ui_next/src/components/SelectedList/DraggableSelectedList.test.jsx b/awx/ui_next/src/components/SelectedList/DraggableSelectedList.test.jsx index c0318069c7..32fcadfc90 100644 --- a/awx/ui_next/src/components/SelectedList/DraggableSelectedList.test.jsx +++ b/awx/ui_next/src/components/SelectedList/DraggableSelectedList.test.jsx @@ -6,8 +6,8 @@ describe('', () => { let wrapper; afterEach(() => { jest.clearAllMocks(); - wrapper.unmount(); }); + test('should render expected rows', () => { const mockSelected = [ { diff --git a/awx/ui_next/src/screens/ActivityStream/ActivityStream.test.jsx b/awx/ui_next/src/screens/ActivityStream/ActivityStream.test.jsx index b5afeef3d6..7db6360583 100644 --- a/awx/ui_next/src/screens/ActivityStream/ActivityStream.test.jsx +++ b/awx/ui_next/src/screens/ActivityStream/ActivityStream.test.jsx @@ -1,25 +1,17 @@ import React from 'react'; - +import { act } from 'react-dom/test-utils'; import { mountWithContexts } from '../../../testUtils/enzymeHelpers'; import ActivityStream from './ActivityStream'; -jest.mock('react-router-dom', () => ({ - ...jest.requireActual('react-router-dom'), -})); +jest.mock('../../api'); describe('', () => { - let pageWrapper; - - beforeEach(() => { - pageWrapper = mountWithContexts(); - }); - - afterEach(() => { - pageWrapper.unmount(); - }); - - test('initially renders without crashing', () => { + test('initially renders without crashing', async () => { + let pageWrapper; + await act(async () => { + pageWrapper = await mountWithContexts(); + }); expect(pageWrapper.length).toBe(1); }); }); diff --git a/awx/ui_next/src/screens/Application/Applications.test.jsx b/awx/ui_next/src/screens/Application/Applications.test.jsx index 80c5f9a34c..a60292e2a5 100644 --- a/awx/ui_next/src/screens/Application/Applications.test.jsx +++ b/awx/ui_next/src/screens/Application/Applications.test.jsx @@ -1,21 +1,13 @@ import React from 'react'; -import { act } from 'react-dom/test-utils'; import { createMemoryHistory } from 'history'; +import { shallow } from 'enzyme'; import { mountWithContexts } from '../../../testUtils/enzymeHelpers'; import Applications from './Applications'; -jest.mock('react-router-dom', () => ({ - ...jest.requireActual('react-router-dom'), -})); - describe('', () => { let wrapper; - afterEach(() => { - wrapper.unmount(); - }); - test('renders successfully', () => { wrapper = mountWithContexts(); const pageSections = wrapper.find('PageSection'); @@ -28,22 +20,20 @@ describe('', () => { const history = createMemoryHistory({ initialEntries: ['/applications/add'], }); - wrapper = mountWithContexts(, { + wrapper = shallow(, { context: { router: { history } }, }); expect(wrapper.find('Modal[title="Application information"]').length).toBe( 0 ); - await act(async () => { - wrapper - .find('ApplicationAdd') - .props() - .onSuccessfulAdd({ - name: 'test', - client_id: 'foobar', - client_secret: 'aaaaaaaaaaaaaaaaaaaaaaaaaa', - }); - }); + wrapper + .find('ApplicationAdd') + .props() + .onSuccessfulAdd({ + name: 'test', + client_id: 'foobar', + client_secret: 'aaaaaaaaaaaaaaaaaaaaaaaaaa', + }); wrapper.update(); expect(wrapper.find('Modal[title="Application information"]').length).toBe( 1 diff --git a/awx/ui_next/src/screens/Credential/CredentialAdd/CredentialAdd.test.jsx b/awx/ui_next/src/screens/Credential/CredentialAdd/CredentialAdd.test.jsx index 5318a3b7cf..0807fe6a99 100644 --- a/awx/ui_next/src/screens/Credential/CredentialAdd/CredentialAdd.test.jsx +++ b/awx/ui_next/src/screens/Credential/CredentialAdd/CredentialAdd.test.jsx @@ -196,7 +196,6 @@ describe('', () => { }); wrapper.update(); expect(wrapper.find('ContentError').length).toBe(1); - wrapper.unmount(); }); }); }); diff --git a/awx/ui_next/src/screens/Credential/CredentialEdit/CredentialEdit.test.jsx b/awx/ui_next/src/screens/Credential/CredentialEdit/CredentialEdit.test.jsx index 05e9ea301f..ff35ce1525 100644 --- a/awx/ui_next/src/screens/Credential/CredentialEdit/CredentialEdit.test.jsx +++ b/awx/ui_next/src/screens/Credential/CredentialEdit/CredentialEdit.test.jsx @@ -485,7 +485,6 @@ describe('', () => { }); wrapper.update(); expect(wrapper.find('ContentError').length).toBe(1); - wrapper.unmount(); }); }); }); diff --git a/awx/ui_next/src/screens/Credential/CredentialList/CredentialList.test.jsx b/awx/ui_next/src/screens/Credential/CredentialList/CredentialList.test.jsx index 35428638f0..0085c056a3 100644 --- a/awx/ui_next/src/screens/Credential/CredentialList/CredentialList.test.jsx +++ b/awx/ui_next/src/screens/Credential/CredentialList/CredentialList.test.jsx @@ -33,7 +33,6 @@ describe('', () => { afterEach(() => { jest.clearAllMocks(); - wrapper.unmount(); }); test('initially renders successfully', () => { diff --git a/awx/ui_next/src/screens/Credential/CredentialList/CredentialListItem.test.jsx b/awx/ui_next/src/screens/Credential/CredentialList/CredentialListItem.test.jsx index 74bb7e6915..8644c11bdf 100644 --- a/awx/ui_next/src/screens/Credential/CredentialList/CredentialListItem.test.jsx +++ b/awx/ui_next/src/screens/Credential/CredentialList/CredentialListItem.test.jsx @@ -10,10 +10,6 @@ jest.mock('../../../api'); describe('', () => { let wrapper; - afterEach(() => { - wrapper.unmount(); - }); - test('edit button shown to users with edit capabilities', () => { wrapper = mountWithContexts( diff --git a/awx/ui_next/src/screens/Credential/Credentials.test.jsx b/awx/ui_next/src/screens/Credential/Credentials.test.jsx index bbef6628b5..f31143106e 100644 --- a/awx/ui_next/src/screens/Credential/Credentials.test.jsx +++ b/awx/ui_next/src/screens/Credential/Credentials.test.jsx @@ -1,60 +1,16 @@ import React from 'react'; -import { createMemoryHistory } from 'history'; -import { mountWithContexts } from '../../../testUtils/enzymeHelpers'; +import { shallow } from 'enzyme'; import Credentials from './Credentials'; -jest.mock('react-router-dom', () => ({ - ...jest.requireActual('react-router-dom'), -})); - describe('', () => { - let wrapper; + test('should set breadcrumb config', () => { + const wrapper = shallow(); - afterEach(() => { - wrapper.unmount(); - }); - - test('initially renders successfully', () => { - wrapper = mountWithContexts(); - }); - - test('should display credential list breadcrumb heading', () => { - const history = createMemoryHistory({ - initialEntries: ['/credentials'], + const header = wrapper.find('ScreenHeader'); + expect(header.prop('streamType')).toEqual('credential'); + expect(header.prop('breadcrumbConfig')).toEqual({ + '/credentials': 'Credentials', + '/credentials/add': 'Create New Credential', }); - - wrapper = mountWithContexts(, { - context: { - router: { - history, - route: { - location: history.location, - }, - }, - }, - }); - - expect(wrapper.find('Crumb').length).toBe(0); - expect(wrapper.find('Title').text()).toBe('Credentials'); - }); - - test('should display create new credential breadcrumb heading', () => { - const history = createMemoryHistory({ - initialEntries: ['/credentials/add'], - }); - - wrapper = mountWithContexts(, { - context: { - router: { - history, - route: { - location: history.location, - }, - }, - }, - }); - - expect(wrapper.find('Crumb').length).toBe(2); - expect(wrapper.find('Title').text()).toBe('Create New Credential'); }); }); diff --git a/awx/ui_next/src/screens/Credential/shared/CredentialForm.test.jsx b/awx/ui_next/src/screens/Credential/shared/CredentialForm.test.jsx index 8d77e90b3d..1aa33a9910 100644 --- a/awx/ui_next/src/screens/Credential/shared/CredentialForm.test.jsx +++ b/awx/ui_next/src/screens/Credential/shared/CredentialForm.test.jsx @@ -95,15 +95,15 @@ describe('', () => { ); }); }); - afterAll(() => { - wrapper.unmount(); - }); + test('should display form fields on add properly', async () => { addFieldExpects(); }); + test('should hide Test button initially', () => { expect(wrapper.find('Button[children="Test"]').length).toBe(0); }); + test('should update form values', async () => { // name and description change await act(async () => { @@ -135,6 +135,7 @@ describe('', () => { name: 'organization', }); }); + test('should display cred type subform when scm type select has a value', async () => { await act(async () => { await wrapper @@ -218,6 +219,7 @@ describe('', () => { wrapper.find('textarea#credential-ssh_key_data').prop('value') ).toBe(''); }); + test('should update field when RSA Private Key file uploaded', async () => { await act(async () => { wrapper.find('FileUpload#credential-ssh_key_data').invoke('onChange')( @@ -232,6 +234,7 @@ describe('', () => { '-----BEGIN PRIVATE KEY-----\\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\\n-----END PRIVATE KEY-----\\n' ); }); + test('should show error when error thrown parsing JSON', async () => { await act(async () => { await wrapper @@ -295,9 +298,6 @@ describe('', () => { }); describe('Edit', () => { - afterEach(() => { - wrapper.unmount(); - }); test('Initially renders successfully', async () => { await act(async () => { wrapper = mountWithContexts( diff --git a/awx/ui_next/src/screens/Credential/shared/CredentialFormFields/CredentialField.test.jsx b/awx/ui_next/src/screens/Credential/shared/CredentialFormFields/CredentialField.test.jsx index e7bf9e7edb..65a9998357 100644 --- a/awx/ui_next/src/screens/Credential/shared/CredentialFormFields/CredentialField.test.jsx +++ b/awx/ui_next/src/screens/Credential/shared/CredentialFormFields/CredentialField.test.jsx @@ -15,9 +15,6 @@ const fieldOptions = { describe('', () => { let wrapper; - afterEach(() => { - wrapper.unmount(); - }); test('renders correctly without initial value', () => { wrapper = mountWithContexts( ', () => { expect(wrapper.find('KeyIcon').length).toBe(1); expect(wrapper.find('PficonHistoryIcon').length).toBe(0); }); + test('renders correctly with initial value', () => { wrapper = mountWithContexts( ', () => { expect(wrapper.find('KeyIcon').length).toBe(1); expect(wrapper.find('PficonHistoryIcon').length).toBe(1); }); + test('replace/revert button behaves as expected', async () => { wrapper = mountWithContexts( ', () => { let wrapper; describe('No plugin configured', () => { @@ -34,20 +37,23 @@ describe('', () => { ); }); - afterAll(() => { - wrapper.unmount(); - }); + test('renders the expected content', () => { expect(wrapper.find('input').length).toBe(1); expect(wrapper.find('KeyIcon').length).toBe(1); expect(wrapper.find('CredentialPluginSelected').length).toBe(0); }); - test('clicking plugin button shows plugin prompt', () => { + + test('clicking plugin button shows plugin prompt', async () => { expect(wrapper.find('CredentialPluginPrompt').length).toBe(0); - wrapper.find('KeyIcon').simulate('click'); + await act(async () => { + wrapper.find('KeyIcon').simulate('click'); + }); + wrapper.update(); expect(wrapper.find('CredentialPluginPrompt').length).toBe(1); }); }); + describe('Plugin already configured', () => { beforeAll(() => { wrapper = mountWithContexts( @@ -78,9 +84,7 @@ describe('', () => { ); }); - afterAll(() => { - wrapper.unmount(); - }); + test('renders the expected content', () => { expect(wrapper.find('CredentialPluginPrompt').length).toBe(0); expect(wrapper.find('input').length).toBe(0); diff --git a/awx/ui_next/src/screens/Credential/shared/CredentialPlugins/CredentialPluginPrompt/CredentialPluginPrompt.test.jsx b/awx/ui_next/src/screens/Credential/shared/CredentialPlugins/CredentialPluginPrompt/CredentialPluginPrompt.test.jsx index bf4804d11c..6ca8c5869a 100644 --- a/awx/ui_next/src/screens/Credential/shared/CredentialPlugins/CredentialPluginPrompt/CredentialPluginPrompt.test.jsx +++ b/awx/ui_next/src/screens/Credential/shared/CredentialPlugins/CredentialPluginPrompt/CredentialPluginPrompt.test.jsx @@ -99,10 +99,6 @@ describe('', () => { }); }); - afterAll(() => { - wrapper.unmount(); - }); - test('should render Wizard with all steps', async () => { const wizard = await waitForElement(wrapper, 'Wizard'); const steps = wizard.prop('steps'); @@ -119,15 +115,18 @@ describe('', () => { wrapper.find('Radio').filterWhere(radio => radio.isChecked).length ).toBe(0); }); + test('next button disabled until credential selected', () => { expect(wrapper.find('Button[children="Next"]').prop('isDisabled')).toBe( true ); }); + test('clicking cancel button calls correct function', () => { wrapper.find('Button[children="Cancel"]').simulate('click'); expect(onClose).toHaveBeenCalledTimes(1); }); + test('clicking credential row enables next button', async () => { await waitForElement(wrapper, 'CheckboxListItem', el => el.length > 0); await act(async () => { @@ -207,9 +206,7 @@ describe('', () => { ); }); }); - afterAll(() => { - wrapper.unmount(); - }); + test('should render Wizard with all steps', async () => { const wizard = await waitForElement(wrapper, 'Wizard'); const steps = wizard.prop('steps'); @@ -218,6 +215,7 @@ describe('', () => { expect(steps[0].name).toEqual('Credential'); expect(steps[1].name).toEqual('Metadata'); }); + test('credentials step renders correctly', async () => { await waitForElement(wrapper, 'CheckboxListItem', el => el.length > 0); @@ -233,6 +231,7 @@ describe('', () => { false ); }); + test('metadata step renders correctly', async () => { await act(async () => { wrapper.find('Button[children="Next"]').simulate('click'); @@ -247,6 +246,7 @@ describe('', () => { wrapper.find('input#credential-secret_version').prop('value') ).toBe('9000'); }); + test('clicking Test button makes correct call', async () => { await act(async () => { wrapper.find('Button[children="Test"]').simulate('click'); diff --git a/awx/ui_next/src/screens/Credential/shared/CredentialPlugins/CredentialPluginSelected.test.jsx b/awx/ui_next/src/screens/Credential/shared/CredentialPlugins/CredentialPluginSelected.test.jsx index ce69724904..f11ba45242 100644 --- a/awx/ui_next/src/screens/Credential/shared/CredentialPlugins/CredentialPluginSelected.test.jsx +++ b/awx/ui_next/src/screens/Credential/shared/CredentialPlugins/CredentialPluginSelected.test.jsx @@ -16,17 +16,17 @@ describe('', () => { /> ); }); - afterAll(() => { - wrapper.unmount(); - }); + test('renders the expected content', () => { expect(wrapper.find('CredentialChip').length).toBe(1); expect(wrapper.find('KeyIcon').length).toBe(1); }); + test('clearing plugin calls expected function', () => { wrapper.find('CredentialChip button').simulate('click'); expect(onClearPlugin).toBeCalledTimes(1); }); + test('editing plugin calls expected function', () => { wrapper.find('KeyIcon').simulate('click'); expect(onEditPlugin).toBeCalledTimes(1);