diff --git a/awx/ui_next/src/screens/Credential/shared/CredentialPlugins/CredentialPluginTestAlert.test.jsx b/awx/ui_next/src/screens/Credential/shared/CredentialPlugins/CredentialPluginTestAlert.test.jsx
index 3934c866e6..533e6623e4 100644
--- a/awx/ui_next/src/screens/Credential/shared/CredentialPlugins/CredentialPluginTestAlert.test.jsx
+++ b/awx/ui_next/src/screens/Credential/shared/CredentialPlugins/CredentialPluginTestAlert.test.jsx
@@ -4,9 +4,7 @@ import CredentialPluginTestAlert from './CredentialPluginTestAlert';
describe('', () => {
let wrapper;
- afterEach(() => {
- wrapper.unmount();
- });
+
test('renders expected content when test is successful', () => {
wrapper = mountWithContexts(
', () => {
'Test passed'
);
});
+
test('renders expected content when test fails with the expected return string formatting', () => {
wrapper = mountWithContexts(
', () => {
'HTTP 404: not found'
);
});
+
test('renders expected content when test fails without the expected return string formatting', () => {
wrapper = mountWithContexts(
', () => {
let wrapper;
- afterEach(() => wrapper.unmount());
+
test('should display metadata fields correctly', async () => {
wrapper = mountWithContexts(
', () => {
expect(wrapper.find('input#credential-secret_key').length).toBe(1);
expect(wrapper.find('input#credential-secret_version').length).toBe(1);
});
+
test('should make the test request correctly when testing an existing credential', async () => {
wrapper = mountWithContexts(
', () => {
},
});
});
+
test('should make the test request correctly when testing a new credential', async () => {
wrapper = mountWithContexts(
', () => {
},
});
});
+
test('should display the alert after a successful test', async () => {
CredentialTypesAPI.test.mockResolvedValue({});
wrapper = mountWithContexts(
@@ -148,6 +151,7 @@ describe('', () => {
expect(wrapper.find('Alert').length).toBe(1);
expect(wrapper.find('Alert').props().variant).toBe('success');
});
+
test('should display the alert after a failed test', async () => {
CredentialTypesAPI.test.mockRejectedValue({
inputs: `HTTP 404
diff --git a/awx/ui_next/src/screens/CredentialType/CredentialTypes.test.jsx b/awx/ui_next/src/screens/CredentialType/CredentialTypes.test.jsx
index bd8eff8e21..e6321a2876 100644
--- a/awx/ui_next/src/screens/CredentialType/CredentialTypes.test.jsx
+++ b/awx/ui_next/src/screens/CredentialType/CredentialTypes.test.jsx
@@ -4,10 +4,6 @@ import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
import CredentialTypes from './CredentialTypes';
-jest.mock('react-router-dom', () => ({
- ...jest.requireActual('react-router-dom'),
-}));
-
describe('', () => {
let pageWrapper;
let pageSections;
@@ -17,10 +13,6 @@ describe('', () => {
pageSections = pageWrapper.find('PageSection');
});
- afterEach(() => {
- pageWrapper.unmount();
- });
-
test('initially renders without crashing', () => {
expect(pageWrapper.length).toBe(1);
expect(pageSections.length).toBe(1);
diff --git a/awx/ui_next/src/screens/Dashboard/Dashboard.test.jsx b/awx/ui_next/src/screens/Dashboard/Dashboard.test.jsx
index a412ee2a48..e58d063313 100644
--- a/awx/ui_next/src/screens/Dashboard/Dashboard.test.jsx
+++ b/awx/ui_next/src/screens/Dashboard/Dashboard.test.jsx
@@ -7,9 +7,6 @@ import { DashboardAPI } from '../../api';
import Dashboard from './Dashboard';
jest.mock('../../api');
-jest.mock('react-router-dom', () => ({
- ...jest.requireActual('react-router-dom'),
-}));
describe('', () => {
let pageWrapper;
@@ -24,10 +21,6 @@ describe('', () => {
});
});
- afterEach(() => {
- pageWrapper.unmount();
- });
-
test('initially renders without crashing', () => {
expect(pageWrapper.length).toBe(1);
});
diff --git a/awx/ui_next/src/screens/Dashboard/DashboardGraph.test.jsx b/awx/ui_next/src/screens/Dashboard/DashboardGraph.test.jsx
index d25d9d8d56..ca3c37bed8 100644
--- a/awx/ui_next/src/screens/Dashboard/DashboardGraph.test.jsx
+++ b/awx/ui_next/src/screens/Dashboard/DashboardGraph.test.jsx
@@ -7,9 +7,6 @@ import { DashboardAPI } from '../../api';
import DashboardGraph from './DashboardGraph';
jest.mock('../../api');
-jest.mock('react-router-dom', () => ({
- ...jest.requireActual('react-router-dom'),
-}));
describe('', () => {
let pageWrapper;
@@ -24,9 +21,6 @@ describe('', () => {
});
});
- afterEach(() => {
- pageWrapper.unmount();
- });
test('renders month-based/all job type chart by default', () => {
expect(graphRequest).toHaveBeenCalledWith({
job_type: 'all',
diff --git a/awx/ui_next/src/screens/Dashboard/shared/Count.test.jsx b/awx/ui_next/src/screens/Dashboard/shared/Count.test.jsx
index 58b67ff9c3..ded7ad951b 100644
--- a/awx/ui_next/src/screens/Dashboard/shared/Count.test.jsx
+++ b/awx/ui_next/src/screens/Dashboard/shared/Count.test.jsx
@@ -7,10 +7,6 @@ import Count from './Count';
describe('', () => {
let pageWrapper;
- afterEach(() => {
- pageWrapper.unmount();
- });
-
test('initially renders without crashing', () => {
pageWrapper = mountWithContexts();
expect(pageWrapper.length).toBe(1);
diff --git a/awx/ui_next/src/screens/ExecutionEnvironment/ExecutionEnvironmentAdd/ExecutionEnvironmentAdd.test.jsx b/awx/ui_next/src/screens/ExecutionEnvironment/ExecutionEnvironmentAdd/ExecutionEnvironmentAdd.test.jsx
index 7d24185997..6616b527b7 100644
--- a/awx/ui_next/src/screens/ExecutionEnvironment/ExecutionEnvironmentAdd/ExecutionEnvironmentAdd.test.jsx
+++ b/awx/ui_next/src/screens/ExecutionEnvironment/ExecutionEnvironmentAdd/ExecutionEnvironmentAdd.test.jsx
@@ -90,7 +90,6 @@ describe('', () => {
afterEach(() => {
jest.clearAllMocks();
- wrapper.unmount();
});
test('handleSubmit should call the api and redirect to details page', async () => {
diff --git a/awx/ui_next/src/screens/ExecutionEnvironment/ExecutionEnvironmentEdit/ExecutionEnvironmentEdit.test.jsx b/awx/ui_next/src/screens/ExecutionEnvironment/ExecutionEnvironmentEdit/ExecutionEnvironmentEdit.test.jsx
index 0477c346b9..eab08b97ab 100644
--- a/awx/ui_next/src/screens/ExecutionEnvironment/ExecutionEnvironmentEdit/ExecutionEnvironmentEdit.test.jsx
+++ b/awx/ui_next/src/screens/ExecutionEnvironment/ExecutionEnvironmentEdit/ExecutionEnvironmentEdit.test.jsx
@@ -82,7 +82,6 @@ describe('', () => {
afterAll(() => {
jest.clearAllMocks();
- wrapper.unmount();
});
test('handleSubmit should call the api and redirect to details page', async () => {
diff --git a/awx/ui_next/src/screens/ExecutionEnvironment/ExecutionEnvironments.test.jsx b/awx/ui_next/src/screens/ExecutionEnvironment/ExecutionEnvironments.test.jsx
index 5ceb36ac93..e036174dc9 100644
--- a/awx/ui_next/src/screens/ExecutionEnvironment/ExecutionEnvironments.test.jsx
+++ b/awx/ui_next/src/screens/ExecutionEnvironment/ExecutionEnvironments.test.jsx
@@ -13,10 +13,6 @@ describe('', () => {
pageSections = pageWrapper.find('PageSection');
});
- afterEach(() => {
- pageWrapper.unmount();
- });
-
test('initially renders without crashing', () => {
expect(pageWrapper.length).toBe(1);
expect(pageSections.length).toBe(1);
diff --git a/awx/ui_next/src/screens/Host/Host.test.jsx b/awx/ui_next/src/screens/Host/Host.test.jsx
index a875d8777e..f825405621 100644
--- a/awx/ui_next/src/screens/Host/Host.test.jsx
+++ b/awx/ui_next/src/screens/Host/Host.test.jsx
@@ -37,10 +37,6 @@ describe('', () => {
});
});
- afterEach(() => {
- wrapper.unmount();
- });
-
test('should render expected tabs', async () => {
const expectedTabs = ['Details', 'Facts', 'Groups', 'Completed Jobs'];
wrapper.find('RoutedTabs li').forEach((tab, index) => {
diff --git a/awx/ui_next/src/screens/Host/HostList/HostListItem.test.jsx b/awx/ui_next/src/screens/Host/HostList/HostListItem.test.jsx
index 15d6db5ab1..3b19991bac 100644
--- a/awx/ui_next/src/screens/Host/HostList/HostListItem.test.jsx
+++ b/awx/ui_next/src/screens/Host/HostList/HostListItem.test.jsx
@@ -38,10 +38,6 @@ describe('', () => {
);
});
- afterEach(() => {
- wrapper.unmount();
- });
-
test('edit button shown to users with edit capabilities', () => {
expect(wrapper.find('PencilAltIcon').exists()).toBeTruthy();
});
diff --git a/awx/ui_next/src/screens/Host/Hosts.test.jsx b/awx/ui_next/src/screens/Host/Hosts.test.jsx
index 530e312609..6ca584eda4 100644
--- a/awx/ui_next/src/screens/Host/Hosts.test.jsx
+++ b/awx/ui_next/src/screens/Host/Hosts.test.jsx
@@ -1,41 +1,28 @@
import React from 'react';
import { createMemoryHistory } from 'history';
+import { shallow } from 'enzyme';
+import { act } from 'react-dom/test-utils';
import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
import Hosts from './Hosts';
-jest.mock('react-router-dom', () => ({
- ...jest.requireActual('react-router-dom'),
-}));
+jest.mock('../../api');
describe('', () => {
- test('initially renders successfully', () => {
- mountWithContexts();
- });
-
test('should display a breadcrumb heading', () => {
- const history = createMemoryHistory({
- initialEntries: ['/hosts'],
- });
- const match = { path: '/hosts', url: '/hosts', isExact: true };
+ const wrapper = shallow();
- const wrapper = mountWithContexts(, {
- context: {
- router: {
- history,
- route: {
- location: history.location,
- match,
- },
- },
- },
+ const header = wrapper.find('ScreenHeader');
+ expect(header.prop('streamType')).toEqual('host');
+ expect(header.prop('breadcrumbConfig')).toEqual({
+ '/hosts': 'Hosts',
+ '/hosts/add': 'Create New Host',
});
- expect(wrapper.find('Title').length).toBe(1);
- wrapper.unmount();
});
- test('should render Host component', () => {
+ test('should render Host component', async () => {
+ let wrapper;
const history = createMemoryHistory({
initialEntries: ['/hosts/1'],
});
@@ -46,11 +33,12 @@ describe('', () => {
isExact: true,
};
- const wrapper = mountWithContexts(, {
- context: { router: { history, route: { match } } },
+ await act(async () => {
+ wrapper = await mountWithContexts(, {
+ context: { router: { history, route: { match } } },
+ });
});
expect(wrapper.find('Host').length).toBe(1);
- wrapper.unmount();
});
});
diff --git a/awx/ui_next/src/screens/InstanceGroup/InstanceGroupEdit/InstanceGroupEdit.test.jsx b/awx/ui_next/src/screens/InstanceGroup/InstanceGroupEdit/InstanceGroupEdit.test.jsx
index 9cf57a033d..21b957d150 100644
--- a/awx/ui_next/src/screens/InstanceGroup/InstanceGroupEdit/InstanceGroupEdit.test.jsx
+++ b/awx/ui_next/src/screens/InstanceGroup/InstanceGroupEdit/InstanceGroupEdit.test.jsx
@@ -68,7 +68,6 @@ describe('', () => {
afterAll(() => {
jest.clearAllMocks();
- wrapper.unmount();
});
test('controlplane instance group name can not be updated', async () => {
diff --git a/awx/ui_next/src/screens/InstanceGroup/InstanceGroups.test.jsx b/awx/ui_next/src/screens/InstanceGroup/InstanceGroups.test.jsx
index db32e7e4eb..43d23a4475 100644
--- a/awx/ui_next/src/screens/InstanceGroup/InstanceGroups.test.jsx
+++ b/awx/ui_next/src/screens/InstanceGroup/InstanceGroups.test.jsx
@@ -4,10 +4,6 @@ import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
import InstanceGroups from './InstanceGroups';
-jest.mock('react-router-dom', () => ({
- ...jest.requireActual('react-router-dom'),
-}));
-
describe('', () => {
let pageWrapper;
let pageSections;
@@ -17,10 +13,6 @@ describe('', () => {
pageSections = pageWrapper.find('PageSection');
});
- afterEach(() => {
- pageWrapper.unmount();
- });
-
test('initially renders without crashing', () => {
expect(pageWrapper.length).toBe(1);
expect(pageSections.length).toBe(1);
diff --git a/awx/ui_next/src/screens/InstanceGroup/Instances/InstanceList.test.jsx b/awx/ui_next/src/screens/InstanceGroup/Instances/InstanceList.test.jsx
index d2c7edf32d..eee50ae06e 100644
--- a/awx/ui_next/src/screens/InstanceGroup/Instances/InstanceList.test.jsx
+++ b/awx/ui_next/src/screens/InstanceGroup/Instances/InstanceList.test.jsx
@@ -134,7 +134,6 @@ describe('', () => {
afterEach(() => {
jest.clearAllMocks();
- wrapper.unmount();
});
test('should have data fetched', () => {