diff --git a/__tests__/__snapshots__/enzymeHelpers.test.jsx.snap b/__tests__/__snapshots__/enzymeHelpers.test.jsx.snap index 892684faf0..50ac85a193 100644 --- a/__tests__/__snapshots__/enzymeHelpers.test.jsx.snap +++ b/__tests__/__snapshots__/enzymeHelpers.test.jsx.snap @@ -21,29 +21,28 @@ exports[`mountWithContexts injected ConfigProvider should mount and render with exports[`mountWithContexts injected I18nProvider should mount and render 1`] = `
- - - Text content - - + + Text content +
`; exports[`mountWithContexts injected I18nProvider should mount and render deeply nested consumer 1`] = ` - + -
- Text content -
+ +
+ Text content +
+
-
+
`; diff --git a/__tests__/components/AddResourceRole.test.jsx b/__tests__/components/AddResourceRole.test.jsx index edd8dcf1c2..3a3b4a2241 100644 --- a/__tests__/components/AddResourceRole.test.jsx +++ b/__tests__/components/AddResourceRole.test.jsx @@ -1,9 +1,9 @@ import React from 'react'; import { shallow } from 'enzyme'; import { mountWithContexts } from '../enzymeHelpers'; -import AddResourceRole from '../../src/components/AddRole/AddResourceRole'; +import AddResourceRole, { _AddResourceRole } from '../../src/components/AddRole/AddResourceRole'; -describe('', () => { +describe('<_AddResourceRole />', () => { const readUsers = jest.fn().mockResolvedValue({ data: { count: 2, @@ -31,21 +31,23 @@ describe('', () => { }; test('initially renders without crashing', () => { shallow( - {}} onSave={() => {}} roles={roles} + i18n={{ _: val => val.toString() }} /> ); }); test('handleRoleCheckboxClick properly updates state', () => { const wrapper = shallow( - {}} onSave={() => {}} roles={roles} + i18n={{ _: val => val.toString() }} /> ); wrapper.setState({ @@ -76,11 +78,12 @@ describe('', () => { }); test('handleResourceCheckboxClick properly updates state', () => { const wrapper = shallow( - {}} onSave={() => {}} roles={roles} + i18n={{ _: val => val.toString() }} /> ); wrapper.setState({ @@ -106,14 +109,13 @@ describe('', () => { }]); }); test('clicking user/team cards updates state', () => { - const spy = jest.spyOn(AddResourceRole.prototype, 'handleResourceSelect'); + const spy = jest.spyOn(_AddResourceRole.prototype, 'handleResourceSelect'); const wrapper = mountWithContexts( {}} onSave={() => {}} - api={api} roles={roles} - /> + />, { context: { network: { api, handleHttpError: () => {} } } } ).find('AddResourceRole'); const selectableCardWrapper = wrapper.find('SelectableCard'); expect(selectableCardWrapper.length).toBe(2); @@ -126,11 +128,12 @@ describe('', () => { }); test('readUsers and readTeams call out to corresponding api functions', () => { const wrapper = shallow( - {}} onSave={() => {}} roles={roles} + i18n={{ _: val => val.toString() }} /> ); wrapper.instance().readUsers({ @@ -150,11 +153,12 @@ describe('', () => { test('handleResourceSelect clears out selected lists and sets selectedResource', () => { const wrapper = shallow( - {}} onSave={() => {}} roles={roles} + i18n={{ _: val => val.toString() }} /> ); wrapper.setState({ @@ -193,11 +197,10 @@ describe('', () => { const handleSave = jest.fn(); const wrapper = mountWithContexts( {}} onSave={handleSave} roles={roles} - /> + />, { context: { network: { api, handleHttpError: () => {} } } } ).find('AddResourceRole'); wrapper.setState({ selectedResource: 'users', diff --git a/__tests__/components/AnsibleSelect.test.jsx b/__tests__/components/AnsibleSelect.test.jsx index cd308f2cfc..08d64ef811 100644 --- a/__tests__/components/AnsibleSelect.test.jsx +++ b/__tests__/components/AnsibleSelect.test.jsx @@ -1,6 +1,7 @@ import React from 'react'; import { mountWithContexts } from '../enzymeHelpers'; import AnsibleSelect from '../../src/components/AnsibleSelect'; +import { _AnsibleSelect } from '../../src/components/AnsibleSelect/AnsibleSelect'; const label = 'test select'; const mockData = ['/venv/baz/', '/venv/ansible/']; @@ -18,7 +19,7 @@ describe('', () => { }); test('calls "onSelectChange" on dropdown select change', () => { - const spy = jest.spyOn(AnsibleSelect.prototype, 'onSelectChange'); + const spy = jest.spyOn(_AnsibleSelect.prototype, 'onSelectChange'); const wrapper = mountWithContexts( ', () => { getItems={getItems} handleHttpError={() => {}} location={{ history }} + i18n={{ _: val => val.toString() }} /> ); diff --git a/__tests__/components/NotifyAndRedirect.test.jsx b/__tests__/components/NotifyAndRedirect.test.jsx index 910174db28..df4845359f 100644 --- a/__tests__/components/NotifyAndRedirect.test.jsx +++ b/__tests__/components/NotifyAndRedirect.test.jsx @@ -11,6 +11,7 @@ describe('', () => { to="foo" setRootDialogMessage={setRootDialogMessage} location={{ pathname: 'foo' }} + i18n={{ _: val => val.toString() }} /> ); expect(setRootDialogMessage).toHaveBeenCalled(); diff --git a/__tests__/components/PaginatedDataList/__snapshots__/DeleteToolbarButton.test.jsx.snap b/__tests__/components/PaginatedDataList/__snapshots__/DeleteToolbarButton.test.jsx.snap index 3315e9feb0..f230c0abbe 100644 --- a/__tests__/components/PaginatedDataList/__snapshots__/DeleteToolbarButton.test.jsx.snap +++ b/__tests__/components/PaginatedDataList/__snapshots__/DeleteToolbarButton.test.jsx.snap @@ -2,202 +2,202 @@ exports[` should render button 1`] = ` - - + + + Select a row to delete + + + } + delay={ + Array [ + 500, + 500, + ] + } + distance={15} + flip={true} + lazy={true} maxWidth="18.75rem" - position="left" + onCreate={[Function]} + performance={true} + placement="left" + popperOptions={ + Object { + "modifiers": Object { + "hide": Object { + "enabled": true, + }, + "preventOverflow": Object { + "enabled": true, + }, + }, + } + } + theme="pf-tippy" trigger="mouseenter focus" zIndex={9999} > - - - - Select a row to delete - - - } - delay={ - Array [ - 500, - 500, - ] - } - distance={15} - flip={true} - lazy={true} - maxWidth="18.75rem" - onCreate={[Function]} - performance={true} - placement="left" - popperOptions={ - Object { - "modifiers": Object { - "hide": Object { - "enabled": true, - }, - "preventOverflow": Object { - "enabled": true, - }, - }, - } - } - theme="pf-tippy" - trigger="mouseenter focus" - zIndex={9999} + - svg{color:#d2d2d2;}}}&:hover{background-color:#d9534f;> svg{color:white;}}", + ], + }, + "displayName": "ToolbarDeleteButton__Button", + "foldedComponentIds": Array [], + "render": [Function], + "styledComponentId": "ToolbarDeleteButton__Button-sc-1e3r0eg-0", + "target": [Function], + "toString": [Function], + "warnTooManyClasses": [Function], + "withComponent": [Function], + } + } + forwardedRef={null} isDisabled={true} onClick={[Function]} variant="plain" > - svg{color:#d2d2d2;}}}&:hover{background-color:#d9534f;> svg{color:white;}}", - ], - }, - "displayName": "ToolbarDeleteButton__Button", - "foldedComponentIds": Array [], - "render": [Function], - "styledComponentId": "ToolbarDeleteButton__Button-sc-1e3r0eg-0", - "target": [Function], - "toString": [Function], - "warnTooManyClasses": [Function], - "withComponent": [Function], - } - } - forwardedRef={null} + className="awx-ToolBarBtn ToolbarDeleteButton__Button-sc-1e3r0eg-0 iyjqWq" + component="button" + isActive={false} + isBlock={false} isDisabled={true} + isFocus={false} + isHover={false} onClick={[Function]} + type="button" variant="plain" > - - - - - - - } - > -
- + + + + + + + + - - - - + } + > +
+ +
+ + +
+ Select a row to delete +
+
+
+ + + `; diff --git a/__tests__/components/SelectResourceStep.test.jsx b/__tests__/components/SelectResourceStep.test.jsx index 6188fdf217..12912de606 100644 --- a/__tests__/components/SelectResourceStep.test.jsx +++ b/__tests__/components/SelectResourceStep.test.jsx @@ -3,7 +3,7 @@ import { createMemoryHistory } from 'history'; import { shallow } from 'enzyme'; import { mountWithContexts } from '../enzymeHelpers'; import { sleep } from '../testUtils'; -import SelectResourceStep, { _SelectResourceStep } from '../../src/components/AddRole/SelectResourceStep'; +import SelectResourceStep from '../../src/components/AddRole/SelectResourceStep'; describe('', () => { const columns = [ @@ -67,15 +67,14 @@ describe('', () => { initialEntries: ['/organizations/1/access?resource.page=1&resource.order_by=-username'], }); const wrapper = await mountWithContexts( - <_SelectResourceStep + {}} onSearch={handleSearch} selectedResourceRows={selectedResourceRows} sortedColumnKey="username" - location={history.location} - /> + />, { context: { router: { history, route: { location: history.location } } } } ).find('SelectResourceStep'); await wrapper.instance().readResourceList(); expect(handleSearch).toHaveBeenCalledWith({ diff --git a/__tests__/components/SelectRoleStep.test.jsx b/__tests__/components/SelectRoleStep.test.jsx index 6e323e2936..221014e18f 100644 --- a/__tests__/components/SelectRoleStep.test.jsx +++ b/__tests__/components/SelectRoleStep.test.jsx @@ -1,5 +1,6 @@ import React from 'react'; -import { mount, shallow } from 'enzyme'; +import { shallow } from 'enzyme'; +import { mountWithContexts } from '../enzymeHelpers'; import SelectRoleStep from '../../src/components/AddRole/SelectRoleStep'; describe('', () => { @@ -42,7 +43,7 @@ describe('', () => { }); test('clicking role fires onRolesClick callback', () => { const onRolesClick = jest.fn(); - wrapper = mount( + wrapper = mountWithContexts( initially renders succe canToggleNotifications={true} detailUrl="/foo" errorTurnedOn={false} + i18n={"/i18n/"} notification={ Object { "id": 9000, @@ -15,446 +16,526 @@ exports[` initially renders succe successTurnedOn={false} toggleNotification={[MockFunction]} > - - -
  • - -
    - - - - Foo - - - - slack - - , + - - - , - ] - } - key=".0" - rowid="items-list-item-9000" - > -
    - - - -
    + + + slack + + , + + + + , + ] + } + key=".0" + rowid="items-list-item-9000" + > +
    + + + +
    + - - - - - - Foo - - - - - - + + + + + + - - - - slack - - - - -
    -
    -
    -
    - + + + +
    + + + + + - - -
    - - - - - - - - + + + + + + + - - - - - - -
    -
    -
    -
    -
    - -
    - -
  • -
    -
    + Failure + + + + + + +
    + + + +
    + + + + + + + + + + + + `; diff --git a/__tests__/enzymeHelpers.test.jsx b/__tests__/enzymeHelpers.test.jsx index 3248cdbaf1..5ee423800a 100644 --- a/__tests__/enzymeHelpers.test.jsx +++ b/__tests__/enzymeHelpers.test.jsx @@ -1,7 +1,6 @@ import React from 'react'; import { Link } from 'react-router-dom'; -// import { mount } from 'enzyme'; -import { I18n } from '@lingui/react'; +import { withI18n } from '@lingui/react'; import { t } from '@lingui/macro'; import { mountWithContexts } from './enzymeHelpers'; import { Config } from '../src/contexts/Config'; @@ -11,26 +10,19 @@ import { withRootDialog } from '../src/contexts/RootDialog'; describe('mountWithContexts', () => { describe('injected I18nProvider', () => { test('should mount and render', () => { - const wrapper = mountWithContexts( + const Child = withI18n()(({ i18n }) => (
    - - {({ i18n }) => ( - {i18n._(t`Text content`)} - )} - + {i18n._(t`Text content`)}
    - ); + )); + const wrapper = mountWithContexts(); expect(wrapper.find('div')).toMatchSnapshot(); }); test('should mount and render deeply nested consumer', () => { - const Child = () => ( - - {({ i18n }) => ( -
    {i18n._(t`Text content`)}
    - )} -
    - ); + const Child = withI18n()(({ i18n }) => ( +
    {i18n._(t`Text content`)}
    + )); const Parent = () => (); const wrapper = mountWithContexts(); expect(wrapper.find('Parent')).toMatchSnapshot(); diff --git a/__tests__/pages/Applications.test.jsx b/__tests__/pages/Applications.test.jsx index f86759b04f..a8afd7cd43 100644 --- a/__tests__/pages/Applications.test.jsx +++ b/__tests__/pages/Applications.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { mount } from 'enzyme'; +import { mountWithContexts } from '../enzymeHelpers'; import Applications from '../../src/pages/Applications'; describe('', () => { @@ -8,7 +8,7 @@ describe('', () => { let title; beforeEach(() => { - pageWrapper = mount(); + pageWrapper = mountWithContexts(); pageSections = pageWrapper.find('PageSection'); title = pageWrapper.find('Title'); }); diff --git a/__tests__/pages/AuthSettings.test.jsx b/__tests__/pages/AuthSettings.test.jsx index afd11eeca5..18cc15903c 100644 --- a/__tests__/pages/AuthSettings.test.jsx +++ b/__tests__/pages/AuthSettings.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { mount } from 'enzyme'; +import { mountWithContexts } from '../enzymeHelpers'; import AuthSettings from '../../src/pages/AuthSettings'; describe('', () => { @@ -8,7 +8,7 @@ describe('', () => { let title; beforeEach(() => { - pageWrapper = mount(); + pageWrapper = mountWithContexts(); pageSections = pageWrapper.find('PageSection'); title = pageWrapper.find('Title'); }); diff --git a/__tests__/pages/CredentialTypes.test.jsx b/__tests__/pages/CredentialTypes.test.jsx index 9d5f9ea3d7..7b233aeaeb 100644 --- a/__tests__/pages/CredentialTypes.test.jsx +++ b/__tests__/pages/CredentialTypes.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { mount } from 'enzyme'; +import { mountWithContexts } from '../enzymeHelpers'; import CredentialTypes from '../../src/pages/CredentialTypes'; describe('', () => { @@ -8,7 +8,7 @@ describe('', () => { let title; beforeEach(() => { - pageWrapper = mount(); + pageWrapper = mountWithContexts(); pageSections = pageWrapper.find('PageSection'); title = pageWrapper.find('Title'); }); diff --git a/__tests__/pages/Credentials.test.jsx b/__tests__/pages/Credentials.test.jsx index 6acf0d4dc3..7f4f66022e 100644 --- a/__tests__/pages/Credentials.test.jsx +++ b/__tests__/pages/Credentials.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { mount } from 'enzyme'; +import { mountWithContexts } from '../enzymeHelpers'; import Credentials from '../../src/pages/Credentials'; describe('', () => { @@ -8,7 +8,7 @@ describe('', () => { let title; beforeEach(() => { - pageWrapper = mount(); + pageWrapper = mountWithContexts(); pageSections = pageWrapper.find('PageSection'); title = pageWrapper.find('Title'); }); diff --git a/__tests__/pages/Dashboard.test.jsx b/__tests__/pages/Dashboard.test.jsx index b5e9b9049a..43ff67f5f4 100644 --- a/__tests__/pages/Dashboard.test.jsx +++ b/__tests__/pages/Dashboard.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { mount } from 'enzyme'; +import { mountWithContexts } from '../enzymeHelpers'; import Dashboard from '../../src/pages/Dashboard'; describe('', () => { @@ -8,7 +8,7 @@ describe('', () => { let title; beforeEach(() => { - pageWrapper = mount(); + pageWrapper = mountWithContexts(); pageSections = pageWrapper.find('PageSection'); title = pageWrapper.find('Title'); }); diff --git a/__tests__/pages/InstanceGroups.test.jsx b/__tests__/pages/InstanceGroups.test.jsx index a78c2ff9c2..7cfbdf5397 100644 --- a/__tests__/pages/InstanceGroups.test.jsx +++ b/__tests__/pages/InstanceGroups.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { mount } from 'enzyme'; +import { mountWithContexts } from '../enzymeHelpers'; import InstanceGroups from '../../src/pages/InstanceGroups'; describe('', () => { @@ -8,7 +8,7 @@ describe('', () => { let title; beforeEach(() => { - pageWrapper = mount(); + pageWrapper = mountWithContexts(); pageSections = pageWrapper.find('PageSection'); title = pageWrapper.find('Title'); }); diff --git a/__tests__/pages/Inventories.test.jsx b/__tests__/pages/Inventories.test.jsx index 2296fc165c..8c98c52486 100644 --- a/__tests__/pages/Inventories.test.jsx +++ b/__tests__/pages/Inventories.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { mount } from 'enzyme'; +import { mountWithContexts } from '../enzymeHelpers'; import Inventories from '../../src/pages/Inventories'; describe('', () => { @@ -8,7 +8,7 @@ describe('', () => { let title; beforeEach(() => { - pageWrapper = mount(); + pageWrapper = mountWithContexts(); pageSections = pageWrapper.find('PageSection'); title = pageWrapper.find('Title'); }); diff --git a/__tests__/pages/InventoryScripts.test.jsx b/__tests__/pages/InventoryScripts.test.jsx index 253f7da7e4..e7f3e94687 100644 --- a/__tests__/pages/InventoryScripts.test.jsx +++ b/__tests__/pages/InventoryScripts.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { mount } from 'enzyme'; +import { mountWithContexts } from '../enzymeHelpers'; import InventoryScripts from '../../src/pages/InventoryScripts'; describe('', () => { @@ -8,7 +8,7 @@ describe('', () => { let title; beforeEach(() => { - pageWrapper = mount(); + pageWrapper = mountWithContexts(); pageSections = pageWrapper.find('PageSection'); title = pageWrapper.find('Title'); }); diff --git a/__tests__/pages/Jobs.test.jsx b/__tests__/pages/Jobs.test.jsx index 7529c3a831..82fbe1867e 100644 --- a/__tests__/pages/Jobs.test.jsx +++ b/__tests__/pages/Jobs.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { mount } from 'enzyme'; +import { mountWithContexts } from '../enzymeHelpers'; import Jobs from '../../src/pages/Jobs'; describe('', () => { @@ -8,7 +8,7 @@ describe('', () => { let title; beforeEach(() => { - pageWrapper = mount(); + pageWrapper = mountWithContexts(); pageSections = pageWrapper.find('PageSection'); title = pageWrapper.find('Title'); }); diff --git a/__tests__/pages/JobsSettings.test.jsx b/__tests__/pages/JobsSettings.test.jsx index 136e3a2d9f..af36ebb3a7 100644 --- a/__tests__/pages/JobsSettings.test.jsx +++ b/__tests__/pages/JobsSettings.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { mount } from 'enzyme'; +import { mountWithContexts } from '../enzymeHelpers'; import JobsSettings from '../../src/pages/JobsSettings'; describe('', () => { @@ -8,7 +8,7 @@ describe('', () => { let title; beforeEach(() => { - pageWrapper = mount(); + pageWrapper = mountWithContexts(); pageSections = pageWrapper.find('PageSection'); title = pageWrapper.find('Title'); }); diff --git a/__tests__/pages/License.test.jsx b/__tests__/pages/License.test.jsx index 3b637dd5c3..7a614c0410 100644 --- a/__tests__/pages/License.test.jsx +++ b/__tests__/pages/License.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { mount } from 'enzyme'; +import { mountWithContexts } from '../enzymeHelpers'; import License from '../../src/pages/License'; describe('', () => { @@ -8,7 +8,7 @@ describe('', () => { let title; beforeEach(() => { - pageWrapper = mount(); + pageWrapper = mountWithContexts(); pageSections = pageWrapper.find('PageSection'); title = pageWrapper.find('Title'); }); diff --git a/__tests__/pages/Login.test.jsx b/__tests__/pages/Login.test.jsx index 29a707fd59..57d4be3634 100644 --- a/__tests__/pages/Login.test.jsx +++ b/__tests__/pages/Login.test.jsx @@ -1,9 +1,7 @@ import React from 'react'; -import { MemoryRouter } from 'react-router-dom'; -import { mount } from 'enzyme'; -import { I18nProvider } from '@lingui/react'; +import { mountWithContexts } from '../enzymeHelpers'; import { asyncFlush } from '../../jest.setup'; -import { _AWXLogin } from '../../src/pages/Login'; +import AWXLogin from '../../src/pages/Login'; import APIClient from '../../src/api'; describe('', () => { @@ -18,6 +16,12 @@ describe('', () => { const api = new APIClient({}); + const mountLogin = () => { + loginWrapper = mountWithContexts(, { context: { network: { + api, handleHttpError: () => {} + } } }); + }; + const findChildren = () => { awxLogin = loginWrapper.find('AWXLogin'); loginPage = loginWrapper.find('LoginPage'); @@ -28,22 +32,13 @@ describe('', () => { loginHeaderLogo = loginPage.find('img'); }; - beforeEach(() => { - loginWrapper = mount( - - - <_AWXLogin api={api} clearRootDialogMessage={() => {}} handleHttpError={() => {}} /> - - - ); - findChildren(); - }); - afterEach(() => { loginWrapper.unmount(); }); test('initially renders without crashing', () => { + mountLogin(); + findChildren(); expect(loginWrapper.length).toBe(1); expect(loginPage.length).toBe(1); expect(loginForm.length).toBe(1); @@ -58,13 +53,7 @@ describe('', () => { }); test('custom logo renders Brand component with correct src and alt', () => { - loginWrapper = mount( - - - <_AWXLogin api={api} logo="images/foo.jpg" alt="Foo Application" /> - - - ); + loginWrapper = mountWithContexts(); findChildren(); expect(loginHeaderLogo.length).toBe(1); expect(loginHeaderLogo.props().src).toBe('data:image/jpeg;images/foo.jpg'); @@ -72,13 +61,7 @@ describe('', () => { }); test('default logo renders Brand component with correct src and alt', () => { - loginWrapper = mount( - - - <_AWXLogin api={api} /> - - - ); + mountLogin(); findChildren(); expect(loginHeaderLogo.length).toBe(1); expect(loginHeaderLogo.props().src).toBe('tower-logo-header.svg'); @@ -86,6 +69,8 @@ describe('', () => { }); test('state maps to un/pw input value props', () => { + mountLogin(); + findChildren(); awxLogin.setState({ username: 'un', password: 'pw' }); expect(awxLogin.state().username).toBe('un'); expect(awxLogin.state().password).toBe('pw'); @@ -95,6 +80,8 @@ describe('', () => { }); test('updating un/pw clears out error', () => { + mountLogin(); + findChildren(); awxLogin.setState({ isInputValid: false }); expect(loginWrapper.find('.pf-c-form__helper-text.pf-m-error').length).toBe(1); usernameInput.instance().value = 'uname'; @@ -113,6 +100,8 @@ describe('', () => { test('api.login not called when loading', () => { api.login = jest.fn().mockImplementation(() => Promise.resolve({})); + mountLogin(); + findChildren(); expect(awxLogin.state().isLoading).toBe(false); awxLogin.setState({ isLoading: true }); submitButton.simulate('click'); @@ -121,6 +110,8 @@ describe('', () => { test('submit calls api.login successfully', async () => { api.login = jest.fn().mockImplementation(() => Promise.resolve({})); + mountLogin(); + findChildren(); expect(awxLogin.state().isLoading).toBe(false); awxLogin.setState({ username: 'unamee', password: 'pwordd' }); submitButton.simulate('click'); @@ -137,6 +128,8 @@ describe('', () => { err.response = { status: 401, message: 'problem' }; return Promise.reject(err); }); + mountLogin(); + findChildren(); expect(awxLogin.state().isLoading).toBe(false); expect(awxLogin.state().isInputValid).toBe(true); awxLogin.setState({ username: 'unamee', password: 'pwordd' }); @@ -155,6 +148,8 @@ describe('', () => { err.response = { status: 500, message: 'problem' }; return Promise.reject(err); }); + mountLogin(); + findChildren(); expect(awxLogin.state().isLoading).toBe(false); awxLogin.setState({ username: 'unamee', password: 'pwordd' }); submitButton.simulate('click'); @@ -166,6 +161,8 @@ describe('', () => { }); test('render Redirect to / when already authenticated', () => { + mountLogin(); + findChildren(); awxLogin.setState({ isAuthenticated: true }); const redirectElem = loginWrapper.find('Redirect'); expect(redirectElem.length).toBe(1); diff --git a/__tests__/pages/ManagementJobs.test.jsx b/__tests__/pages/ManagementJobs.test.jsx index 0f26614b94..b2f2dbdc61 100644 --- a/__tests__/pages/ManagementJobs.test.jsx +++ b/__tests__/pages/ManagementJobs.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { mount } from 'enzyme'; +import { mountWithContexts } from '../enzymeHelpers'; import ManagementJobs from '../../src/pages/ManagementJobs'; describe('', () => { @@ -8,7 +8,7 @@ describe('', () => { let title; beforeEach(() => { - pageWrapper = mount(); + pageWrapper = mountWithContexts(); pageSections = pageWrapper.find('PageSection'); title = pageWrapper.find('Title'); }); diff --git a/__tests__/pages/NotifcationTemplates.test.jsx b/__tests__/pages/NotifcationTemplates.test.jsx index 4603c8c85e..9039d5475f 100644 --- a/__tests__/pages/NotifcationTemplates.test.jsx +++ b/__tests__/pages/NotifcationTemplates.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { mount } from 'enzyme'; +import { mountWithContexts } from '../enzymeHelpers'; import NotificationTemplates from '../../src/pages/NotificationTemplates'; describe('', () => { @@ -8,7 +8,7 @@ describe('', () => { let title; beforeEach(() => { - pageWrapper = mount(); + pageWrapper = mountWithContexts(); pageSections = pageWrapper.find('PageSection'); title = pageWrapper.find('Title'); }); diff --git a/__tests__/pages/Organizations/components/__snapshots__/DeleteRoleConfirmationModal.test.jsx.snap b/__tests__/pages/Organizations/components/__snapshots__/DeleteRoleConfirmationModal.test.jsx.snap index 57b9ffa547..015774b1c2 100644 --- a/__tests__/pages/Organizations/components/__snapshots__/DeleteRoleConfirmationModal.test.jsx.snap +++ b/__tests__/pages/Organizations/components/__snapshots__/DeleteRoleConfirmationModal.test.jsx.snap @@ -2,6 +2,7 @@ exports[` should render initially 1`] = ` should render initially 1`] = ` } username="jane" > - + Delete + , + , + ] + } + isOpen={true} + onClose={[Function]} + title="Remove {0} Access" + variant="danger" > - <_default + should render initially 1`] = ` , ] } + ariaDescribedById="" + className="awx-c-modal at-c-alertModal at-c-alertModal--danger" + hideTitle={false} + isLarge={false} isOpen={true} + isSmall={false} onClose={[Function]} - title="Remove Team Access" - variant="danger" + title="Remove {0} Access" + width={null} > - +
    - Delete - , - , - ] - } - ariaDescribedById="" - className="awx-c-modal at-c-alertModal at-c-alertModal--danger" - hideTitle={false} - isLarge={false} - isOpen={true} - isSmall={false} - onClose={[Function]} - title="Remove Team Access" - width={null} - > -
    - } - > - - Delete - , - , - ] - } - ariaDescribedById="" - className="awx-c-modal at-c-alertModal at-c-alertModal--danger" - hideTitle={false} - id="pf-modal-0" - isLarge={false} - isOpen={true} - isSmall={false} - onClose={[Function]} - title="Remove Team Access" - width={null} - > - -
    + } + > + - , + , + ] + } + ariaDescribedById="" + className="awx-c-modal at-c-alertModal at-c-alertModal--danger" + hideTitle={false} + id="pf-modal-0" + isLarge={false} + isOpen={true} + isSmall={false} + onClose={[Function]} + title="Remove {0} Access" + width={null} + > + +
    + +
    -
    - +
    -
    - -
    - - - - - - - <h3 - className="pf-c-title pf-m-2xl" - > - - Remove Team Access - - </h3> - - - -
    - , - , -
    , -
    , - , - , - ] - } - id="Are you sure you want to remove<0> {0} access from<1> {1}? Doing so affects all members of the team.<2/><3/>If you<4><5> only want to remove access for this particular user, please remove them from the team." - values={ - Object { - "0": "Member", - "1": "The Team", - } - } - > - - , - , -
    , -
    , - , - , - ] - } - i18n={"/i18n/"} - id="Are you sure you want to remove<0> {0} access from<1> {1}? Doing so affects all members of the team.<2/><3/>If you<4><5> only want to remove access for this particular user, please remove them from the team." - values={ - Object { - "0": "Member", - "1": "The Team", - } - } - > - -
    -
    -
    - should render initially 1`] = ` should render initially 1`] = ` "verticalAlign": "-0.125em", } } - viewBox="0 0 512 512" + viewBox="0 0 352 512" width="1em" > - -
    -
    - + + + + + - <div - className="pf-c-modal-box__footer" + <h3 + className="pf-c-title pf-m-2xl" > - <Button - aria-label="Confirm delete" - className="" - component="button" - isActive={false} - isBlock={false} - isDisabled={false} - isFocus={false} - isHover={false} - key="delete" - onClick={[Function]} - type="button" - variant="danger" - > - <button - aria-disabled={null} - aria-label="Confirm delete" - className="pf-c-button pf-m-danger" - disabled={false} - onClick={[Function]} - tabIndex={null} - type="button" - > - Delete - </button> - </Button> - <Button - aria-label={null} - className="" - component="button" - isActive={false} - isBlock={false} - isDisabled={false} - isFocus={false} - isHover={false} - key="cancel" - onClick={[Function]} - type="button" - variant="secondary" - > - <button - aria-disabled={null} - aria-label={null} - className="pf-c-button pf-m-secondary" - disabled={false} - onClick={[Function]} - tabIndex={null} - type="button" - > - Cancel - </button> - </Button> + Remove {0} Access - </div> - </ModalBoxFooter> - </div> - </ModalBox> - </div> - </FocusTrap> - </div> - </Bullseye> - </div> - </Backdrop> - </ModalContent> - </Portal> - </Modal> - </_default> - </I18n> + </h3> + + + +
    + Are you sure you want to remove {0} access from {1}? Doing so affects all members of the team. +
    +
    + If you {0} want to remove access for this particular user, please remove them from the team. + + + + + +
    +
    + +
    + + + + + + +
    +
    +
    +
    +
    + +
    + +
    + + + + + `; diff --git a/__tests__/pages/Organizations/components/__snapshots__/OrganizationAccessItem.test.jsx.snap b/__tests__/pages/Organizations/components/__snapshots__/OrganizationAccessItem.test.jsx.snap index 38ae63010b..d8a646bade 100644 --- a/__tests__/pages/Organizations/components/__snapshots__/OrganizationAccessItem.test.jsx.snap +++ b/__tests__/pages/Organizations/components/__snapshots__/OrganizationAccessItem.test.jsx.snap @@ -29,43 +29,146 @@ exports[` initially renders succesfully 1`] = ` "username": "jane", } } + i18n={"/i18n/"} onRoleDelete={[Function]} > - - -
  • - -
    - + - + + jane + + + + + , + +
      + + Team Roles + + + Member + +
    +
    , + ] + } + key=".0" + rowid="access-list-item" + > +
    + +
    + +
    initially renders succesfully 1`] = ` } } > - - jane - - - - - , - -
      - - Team Roles - - - Member - -
    -
    , - ] - } - key=".0" - rowid="access-list-item" - > -
    - -
    - - - - - -
    initially renders succesfully 1`] = ` } } > - Name + jane - -

    - jane brown -

    -
    -
    -
    -
    -
    -
    - -
    + +
    + + -
      - -
      initially renders succesfully 1`] = ` } } > - Team Roles -
      -
      - - -
    • - - Member - - + + +

      + jane brown +

      +
      +
    + +
    +
    + + +
    +
      + +
      + Team Roles +
      +
      + + +
    • + + Member + + + - - -
    • -
      -
      -
    -
    -
    -
    - -
    - -
  • -
    -
    + } + viewBox="0 0 512 512" + width="1em" + > + + + + + + + + + + +
    + +
    + +
    + + + `; diff --git a/__tests__/pages/Organizations/screens/Organization/__snapshots__/OrganizationAccess.test.jsx.snap b/__tests__/pages/Organizations/screens/Organization/__snapshots__/OrganizationAccess.test.jsx.snap index d9faca0720..e03c838e8d 100644 --- a/__tests__/pages/Organizations/screens/Organization/__snapshots__/OrganizationAccess.test.jsx.snap +++ b/__tests__/pages/Organizations/screens/Organization/__snapshots__/OrganizationAccess.test.jsx.snap @@ -5,6 +5,7 @@ exports[` initially renders succesfully 1`] = ` api={"/api/"} handleHttpError={[Function]} history={"/history/"} + i18n={"/i18n/"} location={ Object { "hash": "", diff --git a/__tests__/pages/Organizations/screens/Organization/__snapshots__/OrganizationNotifications.test.jsx.snap b/__tests__/pages/Organizations/screens/Organization/__snapshots__/OrganizationNotifications.test.jsx.snap index 0f2db3c9df..093b1885d8 100644 --- a/__tests__/pages/Organizations/screens/Organization/__snapshots__/OrganizationNotifications.test.jsx.snap +++ b/__tests__/pages/Organizations/screens/Organization/__snapshots__/OrganizationNotifications.test.jsx.snap @@ -57,7 +57,7 @@ exports[` initially renders succesfully 1`] = ` } } > - initially renders succesfully 1`] = ` ] } > - - + initially renders succesfully 1`] = ` }, ] } - location={ - Object { - "hash": "", - "pathname": "", - "search": "", - "state": "", - } - } - match={ - Object { - "isExact": false, - "params": Object {}, - "path": "", - "url": "", - } - } - onSelectAll={null} - paginationStyling={null} qsConfig={ Object { "defaultParams": Object { @@ -171,8 +152,6 @@ exports[` initially renders succesfully 1`] = ` } } renderItem={[Function]} - showPageSizeOptions={true} - showSelectAll={false} toolbarColumns={ Array [ Object { @@ -195,13 +174,68 @@ exports[` initially renders succesfully 1`] = ` ] } > - - + initially renders succesfully 1`] = ` }, ] } - isAllSelected={false} - isCompact={false} - noLeftMargin={false} - onCompact={null} - onExpand={null} - onSearch={[Function]} - onSelectAll={null} - onSort={[Function]} - showSelectAll={false} - sortOrder="ascending" - sortedColumnKey="name" > - - - + -
    - - + +
    - -
    - - +
    -
    - - + +
    + + + +
    + + + +
    + + Modified + , + + Created + , + ] + } + isOpen={false} + onSelect={[Function]} + onToggle={[Function]} + toggle={ + + Name + + } + > + + Modified + , + + Created + , + ] + } + forwardedComponent={ + Object { + "$$typeof": Symbol(react.forward_ref), + "attrs": Array [], + "componentStyle": ComponentStyle { + "componentId": "Search__Dropdown-sc-1dwuww3-2", + "isStatic": true, + "lastClassName": "kcnywV", + "rules": Array [ + "&&&{> button{min-height:30px;min-width:70px;height:30px;padding:0 10px;margin:0px;> span{width:auto;}> svg{margin:0px;padding-top:3px;padding-left:3px;}}}", + ], + }, + "displayName": "Search__Dropdown", + "foldedComponentIds": Array [], + "render": [Function], + "styledComponentId": "Search__Dropdown-sc-1dwuww3-2", + "target": [Function], + "toString": [Function], + "warnTooManyClasses": [Function], + "withComponent": [Function], + } + } + forwardedRef={null} + isOpen={false} + onSelect={[Function]} + onToggle={[Function]} + toggle={ + + Name + + } + > + + Modified + , + + Created + , + ] + } + isOpen={false} + isPlain={false} + onSelect={[Function]} + onToggle={[Function]} + position="left" + toggle={ + + Name + + } + > +
    + + +
    + } + > + + +
    + } + > + + + +
    + +
    + + + + + + + + + + + + + + +
    + + + +
    + + + + +
    + +
    +
    +
    +
    +
    + + +
    - initially renders succesfully 1`] = ` }, ] } - onSearch={[Function]} + onSort={[Function]} + sortOrder="ascending" sortedColumnKey="name" > -
    - initially renders succesfully 1`] = ` isOpen={false} onSelect={[Function]} onToggle={[Function]} + style={ + Object { + "marginRight": "20px", + } + } toggle={ initially renders succesfully 1`] = ` "$$typeof": Symbol(react.forward_ref), "attrs": Array [], "componentStyle": ComponentStyle { - "componentId": "Search__Dropdown-sc-1dwuww3-2", + "componentId": "Sort__Dropdown-sc-21g5aw-0", "isStatic": true, - "lastClassName": "kcnywV", + "lastClassName": "kdSQuN", "rules": Array [ "&&&{> button{min-height:30px;min-width:70px;height:30px;padding:0 10px;margin:0px;> span{width:auto;}> svg{margin:0px;padding-top:3px;padding-left:3px;}}}", ], }, - "displayName": "Search__Dropdown", + "displayName": "Sort__Dropdown", "foldedComponentIds": Array [], "render": [Function], - "styledComponentId": "Search__Dropdown-sc-1dwuww3-2", + "styledComponentId": "Sort__Dropdown-sc-21g5aw-0", "target": [Function], "toString": [Function], "warnTooManyClasses": [Function], @@ -491,11 +1204,16 @@ exports[` initially renders succesfully 1`] = ` isOpen={false} onSelect={[Function]} onToggle={[Function]} + style={ + Object { + "marginRight": "20px", + } + } toggle={ initially renders succesfully 1`] = ` } > initially renders succesfully 1`] = ` onSelect={[Function]} onToggle={[Function]} position="left" + style={ + Object { + "marginRight": "20px", + } + } toggle={ initially renders succesfully 1`] = ` } >
    initially renders succesfully 1`] = ` onToggle={[Function]} parentRef={
    - - - - - - - - - + initially renders succesfully 1`] = ` } forwardedRef={null} onClick={[Function]} - variant="tertiary" + variant="plain" > - -
    + + - +
    - - - -
    - + +
    + + +
    +
    + +
    + + + +
    + + + + + + +
      + + + + +
    • + +
      + + + + Notification one + + + + email + + , + + -
      - -
    -
    - - - + , + ] } - forwardedRef={null} + key=".0" + rowid="items-list-item-1" >
    - -
    - - - - Modified - , - - Created - , - ] - } - isOpen={false} - onSelect={[Function]} - onToggle={[Function]} - style={ - Object { - "marginRight": "20px", - } - } - toggle={ - - Name - - } - > - - Modified - , - - Created - , - ] - } - forwardedComponent={ - Object { - "$$typeof": Symbol(react.forward_ref), - "attrs": Array [], - "componentStyle": ComponentStyle { - "componentId": "Sort__Dropdown-sc-21g5aw-0", - "isStatic": true, - "lastClassName": "kdSQuN", - "rules": Array [ - "&&&{> button{min-height:30px;min-width:70px;height:30px;padding:0 10px;margin:0px;> span{width:auto;}> svg{margin:0px;padding-top:3px;padding-left:3px;}}}", - ], - }, - "displayName": "Sort__Dropdown", - "foldedComponentIds": Array [], - "render": [Function], - "styledComponentId": "Sort__Dropdown-sc-21g5aw-0", - "target": [Function], - "toString": [Function], - "warnTooManyClasses": [Function], - "withComponent": [Function], - } - } - forwardedRef={null} - isOpen={false} - onSelect={[Function]} - onToggle={[Function]} - style={ - Object { - "marginRight": "20px", - } - } - toggle={ - - Name - - } - > - - Modified - , - - Created - , - ] - } - isOpen={false} - isPlain={false} - onSelect={[Function]} - onToggle={[Function]} - position="left" - style={ - Object { - "marginRight": "20px", - } - } - toggle={ - - Name - - } - > -
    - - -
    - } - > - - -
    - } - > - - - -
    - -
    - - - - - - - - - -
    - - initially renders succesfully 1`] = ` } forwardedRef={null} > -
    - - -
    -
    - -
    - -
    -
    -
    -
    -
    -
    -
    - -
      - - - -
    • - -
      - - - - Notification one - - - - email - - , - - - - , - ] - } - key=".0" - rowid="items-list-item-1" - > -
      - - - -
      - - - - - - Notification one - - - - - - - - + + Notification one + + + + + + - - email - - - - -
      -
      -
      -
      - - - + + email + + + + +
      + + + + -
      - - - - - - - - - - + + + + + + + + + - - - - -
      - - -
      -
      - -
    - - - -
    - - - - -
  • - -
    - - - - Notification two - - - - email - - , - - - - , - ] - } - key=".0" - rowid="items-list-item-2" - > -
    - + + + + + + + + +
    + + + +
    + + initially renders succesfully 1`] = ` } } forwardedRef={null} + id="notification-1-error-toggle" + isChecked={false} + isDisabled={false} + label="Failure" + onChange={[Function]} + rowid="items-list-item-1" > - -
    - + + + + + + + +
    +
    +
  • +
    +
    +
    + + + + + +
  • + +
    + + - - + + + email + + , + + + + , + ] + } + key=".0" + rowid="items-list-item-2" + > +
    + + + +
    + - - - Notification two - - - - - - - - + + Notification two + + + + + + - - email - - - - -
    -
    -
    -
    - + + email + + + + +
    + + + + + + +
    + + + + + + + + + + + + + + +
    +
    +
    +
    +
    + + initially renders succesfully 1`] = ` } } forwardedRef={null} - righthalf="true" + id="notification-2-error-toggle" + isChecked={true} + isDisabled={false} + label="Failure" + onChange={[Function]} + rowid="items-list-item-2" > - -
    - - - - - - - - + + -
    -
    + Failure + + + +
    - +
    - - -
    -
  • -
    -
    - - - - - + + + + +
    + + + -
    -
    - - - - - - - - - 50 - , - - 25 - , - - 10 - , - ] - } - isOpen={false} - isPlain={false} - onSelect={[Function]} - onToggle={[Function]} - position="left" - toggle={ - - 5 - - } +
    - + 50 + , + + 25 + , + + 10 + , + ] + } isOpen={false} isPlain={false} - key=".0" - onEnter={[Function]} + onSelect={[Function]} onToggle={[Function]} - parentRef={ -
    - -
    + 5 +
    } > - + + +
    + } + > + + +
    + } > -
    - } - > - - - + + +
    + - - -
    -
    - - - - - - - + Items {itemMin} – {itemMax} of {count} +
    +
    - - - - - - - - + + +
    + + + + + diff --git a/__tests__/pages/Portal.test.jsx b/__tests__/pages/Portal.test.jsx index ba411fdac1..892034ba76 100644 --- a/__tests__/pages/Portal.test.jsx +++ b/__tests__/pages/Portal.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { mount } from 'enzyme'; +import { mountWithContexts } from '../enzymeHelpers'; import Portal from '../../src/pages/Portal'; describe('', () => { @@ -8,7 +8,7 @@ describe('', () => { let title; beforeEach(() => { - pageWrapper = mount(); + pageWrapper = mountWithContexts(); pageSections = pageWrapper.find('PageSection'); title = pageWrapper.find('Title'); }); diff --git a/__tests__/pages/Projects.test.jsx b/__tests__/pages/Projects.test.jsx index 8ec7510325..9e7ec2c623 100644 --- a/__tests__/pages/Projects.test.jsx +++ b/__tests__/pages/Projects.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { mount } from 'enzyme'; +import { mountWithContexts } from '../enzymeHelpers'; import Projects from '../../src/pages/Projects'; describe('', () => { @@ -8,7 +8,7 @@ describe('', () => { let title; beforeEach(() => { - pageWrapper = mount(); + pageWrapper = mountWithContexts(); pageSections = pageWrapper.find('PageSection'); title = pageWrapper.find('Title'); }); diff --git a/__tests__/pages/Schedules.test.jsx b/__tests__/pages/Schedules.test.jsx index a144c5e985..b2255f9fc1 100644 --- a/__tests__/pages/Schedules.test.jsx +++ b/__tests__/pages/Schedules.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { mount } from 'enzyme'; +import { mountWithContexts } from '../enzymeHelpers'; import Schedules from '../../src/pages/Schedules'; describe('', () => { @@ -8,7 +8,7 @@ describe('', () => { let title; beforeEach(() => { - pageWrapper = mount(); + pageWrapper = mountWithContexts(); pageSections = pageWrapper.find('PageSection'); title = pageWrapper.find('Title'); }); diff --git a/__tests__/pages/SystemSettings.test.jsx b/__tests__/pages/SystemSettings.test.jsx index cc86976a52..9fa1f751c7 100644 --- a/__tests__/pages/SystemSettings.test.jsx +++ b/__tests__/pages/SystemSettings.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { mount } from 'enzyme'; +import { mountWithContexts } from '../enzymeHelpers'; import SystemSettings from '../../src/pages/SystemSettings'; describe('', () => { @@ -8,7 +8,7 @@ describe('', () => { let title; beforeEach(() => { - pageWrapper = mount(); + pageWrapper = mountWithContexts(); pageSections = pageWrapper.find('PageSection'); title = pageWrapper.find('Title'); }); diff --git a/__tests__/pages/Teams.test.jsx b/__tests__/pages/Teams.test.jsx index 80f52cbc69..9d10331dcf 100644 --- a/__tests__/pages/Teams.test.jsx +++ b/__tests__/pages/Teams.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { mount } from 'enzyme'; +import { mountWithContexts } from '../enzymeHelpers'; import Teams from '../../src/pages/Teams'; describe('', () => { @@ -8,7 +8,7 @@ describe('', () => { let title; beforeEach(() => { - pageWrapper = mount(); + pageWrapper = mountWithContexts(); pageSections = pageWrapper.find('PageSection'); title = pageWrapper.find('Title'); }); diff --git a/__tests__/pages/Templates.test.jsx b/__tests__/pages/Templates.test.jsx index 2a3f4ef869..433c1648b2 100644 --- a/__tests__/pages/Templates.test.jsx +++ b/__tests__/pages/Templates.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { mount } from 'enzyme'; +import { mountWithContexts } from '../enzymeHelpers'; import Templates from '../../src/pages/Templates'; describe('', () => { @@ -8,7 +8,7 @@ describe('', () => { let title; beforeEach(() => { - pageWrapper = mount(); + pageWrapper = mountWithContexts(); pageSections = pageWrapper.find('PageSection'); title = pageWrapper.find('Title'); }); diff --git a/__tests__/pages/UISettings.test.jsx b/__tests__/pages/UISettings.test.jsx index 3d6c6c88d2..3ecab146bf 100644 --- a/__tests__/pages/UISettings.test.jsx +++ b/__tests__/pages/UISettings.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { mount } from 'enzyme'; +import { mountWithContexts } from '../enzymeHelpers'; import UISettings from '../../src/pages/UISettings'; describe('', () => { @@ -8,7 +8,7 @@ describe('', () => { let title; beforeEach(() => { - pageWrapper = mount(); + pageWrapper = mountWithContexts(); pageSections = pageWrapper.find('PageSection'); title = pageWrapper.find('Title'); }); diff --git a/__tests__/pages/Users.test.jsx b/__tests__/pages/Users.test.jsx index 48199690a9..bdacf86be1 100644 --- a/__tests__/pages/Users.test.jsx +++ b/__tests__/pages/Users.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { mount } from 'enzyme'; +import { mountWithContexts } from '../enzymeHelpers'; import Users from '../../src/pages/Users'; describe('', () => { @@ -8,7 +8,7 @@ describe('', () => { let title; beforeEach(() => { - pageWrapper = mount(); + pageWrapper = mountWithContexts(); pageSections = pageWrapper.find('PageSection'); title = pageWrapper.find('Title'); }); diff --git a/__tests__/util/validators.test.js b/__tests__/util/validators.test.js index d197c61a21..3021f804cb 100644 --- a/__tests__/util/validators.test.js +++ b/__tests__/util/validators.test.js @@ -1,34 +1,36 @@ import { required, maxLength } from '../../src/util/validators'; +const i18n = { _: val => val }; + describe('validators', () => { test('required returns undefined if value given', () => { - expect(required()('some value')).toBeUndefined(); - expect(required('oops')('some value')).toBeUndefined(); + expect(required(null, i18n)('some value')).toBeUndefined(); + expect(required('oops', i18n)('some value')).toBeUndefined(); }); test('required returns default message if value missing', () => { - expect(required()('')).toEqual('This field must not be blank'); + expect(required(null, i18n)('')).toEqual({ id: 'This field must not be blank' }); }); test('required returns custom message if value missing', () => { - expect(required('oops')('')).toEqual('oops'); + expect(required('oops', i18n)('')).toEqual('oops'); }); test('required interprets white space as empty value', () => { - expect(required()(' ')).toEqual('This field must not be blank'); - expect(required()('\t')).toEqual('This field must not be blank'); + expect(required(null, i18n)(' ')).toEqual({ id: 'This field must not be blank' }); + expect(required(null, i18n)('\t')).toEqual({ id: 'This field must not be blank' }); }); test('maxLength accepts value below max', () => { - expect(maxLength(10)('snazzy')).toBeUndefined(); + expect(maxLength(10, i18n)('snazzy')).toBeUndefined(); }); test('maxLength accepts value equal to max', () => { - expect(maxLength(10)('abracadbra')).toBeUndefined(); + expect(maxLength(10, i18n)('abracadbra')).toBeUndefined(); }); test('maxLength rejects value above max', () => { - expect(maxLength(8)('abracadbra')) - .toEqual('This field must not exceed 8 characters'); + expect(maxLength(8, i18n)('abracadbra')) + .toEqual({ id: 'This field must not exceed {max} characters', values: { max: 8 } }); }); }); diff --git a/src/components/AddRole/AddResourceRole.jsx b/src/components/AddRole/AddResourceRole.jsx index 17b3a78b17..13039bde15 100644 --- a/src/components/AddRole/AddResourceRole.jsx +++ b/src/components/AddRole/AddResourceRole.jsx @@ -3,6 +3,7 @@ import PropTypes from 'prop-types'; import { withI18n } from '@lingui/react'; import { t } from '@lingui/macro'; import { Wizard } from '@patternfly/react-core'; +import { withNetwork } from '../../contexts/Network'; import SelectResourceStep from './SelectResourceStep'; import SelectRoleStep from './SelectRoleStep'; import SelectableCard from './SelectableCard'; @@ -249,4 +250,5 @@ AddResourceRole.defaultProps = { roles: {} }; -export default withI18n()(AddResourceRole); +export { AddResourceRole as _AddResourceRole }; +export default withI18n()(withNetwork(AddResourceRole)); diff --git a/src/components/AnsibleSelect/AnsibleSelect.jsx b/src/components/AnsibleSelect/AnsibleSelect.jsx index 062a8dacc3..fe6e352811 100644 --- a/src/components/AnsibleSelect/AnsibleSelect.jsx +++ b/src/components/AnsibleSelect/AnsibleSelect.jsx @@ -58,4 +58,5 @@ AnsibleSelect.propTypes = { value: PropTypes.string.isRequired, }; +export { AnsibleSelect as _AnsibleSelect }; export default withI18n()(AnsibleSelect); diff --git a/src/components/PaginatedDataList/PaginatedDataList.jsx b/src/components/PaginatedDataList/PaginatedDataList.jsx index bd831be897..267b0caad8 100644 --- a/src/components/PaginatedDataList/PaginatedDataList.jsx +++ b/src/components/PaginatedDataList/PaginatedDataList.jsx @@ -113,7 +113,7 @@ class PaginatedDataList extends React.Component { const { error } = this.state; const [orderBy, sortOrder] = this.getSortOrder(); const queryParams = parseNamespacedQueryString(qsConfig, location.search); - const columns = toolbarColumns || [{ name: i18n._(t`Name`), key: 'name', isSortable: true }]; + const columns = toolbarColumns.length ? toolbarColumns : [{ name: i18n._(t`Name`), key: 'name', isSortable: true }]; return ( {error && ( @@ -141,7 +141,7 @@ class PaginatedDataList extends React.Component { { }} onSort={this.handleSort} showSelectAll={showSelectAll} diff --git a/src/components/Pagination/Pagination.jsx b/src/components/Pagination/Pagination.jsx index e508209b14..9058648177 100644 --- a/src/components/Pagination/Pagination.jsx +++ b/src/components/Pagination/Pagination.jsx @@ -187,13 +187,15 @@ class Pagination extends Component { className="awx-pagination__page-input-form" onSubmit={this.onSubmit} > - {i18n._(t`Page ${()} of ${pageCount}`)} + /> + {i18n._(t` of ${pageCount}`)}