From 55a9a4ca46c7aecd4e6e3c19bd9708749b6df190 Mon Sep 17 00:00:00 2001 From: "Keith J. Grant" Date: Thu, 22 Jul 2021 09:55:01 -0700 Subject: [PATCH] update selectors in tests to match id changes --- .../Application/ApplicationAdd/ApplicationAdd.test.js | 4 ++-- .../ApplicationEdit/ApplicationEdit.test.js | 5 ++++- .../screens/Application/shared/ApplicationForm.test.js | 2 +- .../Template/JobTemplateEdit/JobTemplateEdit.test.js | 10 ++++------ .../src/screens/Template/shared/WebhookSubForm.test.js | 4 ++-- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/awx/ui_next/src/screens/Application/ApplicationAdd/ApplicationAdd.test.js b/awx/ui_next/src/screens/Application/ApplicationAdd/ApplicationAdd.test.js index eabcf0d3c7..c16fe24ba9 100644 --- a/awx/ui_next/src/screens/Application/ApplicationAdd/ApplicationAdd.test.js +++ b/awx/ui_next/src/screens/Application/ApplicationAdd/ApplicationAdd.test.js @@ -98,7 +98,7 @@ describe('', () => { wrapper.update(); expect(wrapper.find('input#name').prop('value')).toBe('new foo'); expect(wrapper.find('input#description').prop('value')).toBe('new bar'); - expect(wrapper.find('input#organization-input').prop('value')).toBe( + expect(wrapper.find('input#organization').prop('value')).toBe( 'organization' ); expect( @@ -180,7 +180,7 @@ describe('', () => { }); }); - waitForElement(wrapper, 'FormSubmitError', (el) => el.length > 0); + waitForElement(wrapper, 'FormSubmitError', el => el.length > 0); }); test('should render content error on failed read options request', async () => { ApplicationsAPI.readOptions.mockRejectedValue( diff --git a/awx/ui_next/src/screens/Application/ApplicationEdit/ApplicationEdit.test.js b/awx/ui_next/src/screens/Application/ApplicationEdit/ApplicationEdit.test.js index fd60b79c4c..0447d2d470 100644 --- a/awx/ui_next/src/screens/Application/ApplicationEdit/ApplicationEdit.test.js +++ b/awx/ui_next/src/screens/Application/ApplicationEdit/ApplicationEdit.test.js @@ -88,6 +88,7 @@ describe('', () => { }); expect(wrapper.find('ApplicationEdit').length).toBe(1); }); + test('should cancel form properly', async () => { const history = createMemoryHistory({ initialEntries: ['/applications/1/edit'], @@ -110,6 +111,7 @@ describe('', () => { expect(history.location.pathname).toBe('/applications/1/details'); }); }); + test('should throw error on submit', async () => { const error = { response: { @@ -147,6 +149,7 @@ describe('', () => { wrapper.update(); expect(wrapper.find('FormSubmitError').length).toBe(1); }); + test('expect values to be updated and submitted properly', async () => { const history = createMemoryHistory({ initialEntries: ['/applications/1/edit'], @@ -188,7 +191,7 @@ describe('', () => { wrapper.update(); expect(wrapper.find('input#name').prop('value')).toBe('new foo'); expect(wrapper.find('input#description').prop('value')).toBe('new bar'); - expect(wrapper.find('input#organization-input').prop('value')).toBe( + expect(wrapper.find('input#organization').prop('value')).toBe( 'organization' ); expect( diff --git a/awx/ui_next/src/screens/Application/shared/ApplicationForm.test.js b/awx/ui_next/src/screens/Application/shared/ApplicationForm.test.js index 7776f1bf93..a01cc40838 100644 --- a/awx/ui_next/src/screens/Application/shared/ApplicationForm.test.js +++ b/awx/ui_next/src/screens/Application/shared/ApplicationForm.test.js @@ -107,7 +107,7 @@ describe(' { wrapper.update(); expect(wrapper.find('input#name').prop('value')).toBe('new foo'); expect(wrapper.find('input#description').prop('value')).toBe('new bar'); - expect(wrapper.find('input#organization-input').prop('value')).toBe( + expect(wrapper.find('input#organization').prop('value')).toBe( 'organization' ); expect( diff --git a/awx/ui_next/src/screens/Template/JobTemplateEdit/JobTemplateEdit.test.js b/awx/ui_next/src/screens/Template/JobTemplateEdit/JobTemplateEdit.test.js index d5c20d3c3c..31859ca261 100644 --- a/awx/ui_next/src/screens/Template/JobTemplateEdit/JobTemplateEdit.test.js +++ b/awx/ui_next/src/screens/Template/JobTemplateEdit/JobTemplateEdit.test.js @@ -274,7 +274,7 @@ describe('', () => { data: { actions: { GET: {}, POST: {} } }, }); - useDebounce.mockImplementation((fn) => fn); + useDebounce.mockImplementation(fn => fn); }); afterEach(() => { @@ -321,7 +321,7 @@ describe('', () => { { id: 5, name: 'Maple' }, { id: 6, name: 'Tree' }, ]; - await waitForElement(wrapper, 'LabelSelect', (el) => el.length > 0); + await waitForElement(wrapper, 'LabelSelect', el => el.length > 0); act(() => { wrapper.find('LabelSelect').invoke('onChange')(labels); wrapper.update(); @@ -339,9 +339,7 @@ describe('', () => { name: 'Other Inventory', }); - wrapper.find('TextInput#execution-environments-input').invoke('onChange')( - '' - ); + wrapper.find('TextInput#execution-environments').invoke('onChange')(''); }); wrapper.update(); @@ -384,7 +382,7 @@ describe('', () => { cancelButton = await waitForElement( wrapper, 'button[aria-label="Cancel"]', - (e) => e.length === 1 + e => e.length === 1 ); }); await act(async () => { diff --git a/awx/ui_next/src/screens/Template/shared/WebhookSubForm.test.js b/awx/ui_next/src/screens/Template/shared/WebhookSubForm.test.js index 32000a31eb..3574dfa847 100644 --- a/awx/ui_next/src/screens/Template/shared/WebhookSubForm.test.js +++ b/awx/ui_next/src/screens/Template/shared/WebhookSubForm.test.js @@ -58,7 +58,7 @@ describe('', () => { }); test('should render initial values properly', () => { - waitForElement(wrapper, 'Lookup__ChipHolder', (el) => el.lenth > 0); + waitForElement(wrapper, 'Lookup__ChipHolder', el => el.lenth > 0); expect(wrapper.find('AnsibleSelect').prop('value')).toBe('github'); expect( wrapper.find('TextInputBase[aria-label="Webhook URL"]').prop('value') @@ -68,7 +68,7 @@ describe('', () => { .find('TextInputBase[aria-label="workflow job template webhook key"]') .prop('value') ).toBe('webhook key'); - expect(wrapper.find('input#credential-input').prop('value')).toBe( + expect(wrapper.find('input#credential').prop('value')).toBe( 'Github credential' ); });