From 6b2cee2f69b5e501738d78efaf47e780ed35bc8b Mon Sep 17 00:00:00 2001 From: "Keith J. Grant" Date: Mon, 8 Mar 2021 11:31:03 -0800 Subject: [PATCH] add tests ensuring forms pass correct value to CodeEditor fields --- .../SmartInventoryEdit.test.jsx | 4 +++ .../Inventory/shared/InventoryForm.test.jsx | 1 + .../shared/NotificationTemplateForm.test.jsx | 27 +++++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/awx/ui_next/src/screens/Inventory/SmartInventoryEdit/SmartInventoryEdit.test.jsx b/awx/ui_next/src/screens/Inventory/SmartInventoryEdit/SmartInventoryEdit.test.jsx index 90ed4abb6f..789d8067c9 100644 --- a/awx/ui_next/src/screens/Inventory/SmartInventoryEdit/SmartInventoryEdit.test.jsx +++ b/awx/ui_next/src/screens/Inventory/SmartInventoryEdit/SmartInventoryEdit.test.jsx @@ -74,6 +74,10 @@ describe('', () => { wrapper.unmount(); }); + test('should render CodeEditor field', () => { + expect(wrapper.find('CodeEditor').prop('value')).toEqual('---'); + }); + test('should fetch related instance groups on initial render', async () => { expect(InventoriesAPI.readInstanceGroups).toHaveBeenCalledTimes(1); }); diff --git a/awx/ui_next/src/screens/Inventory/shared/InventoryForm.test.jsx b/awx/ui_next/src/screens/Inventory/shared/InventoryForm.test.jsx index 86ea72e52c..dc2b5bd246 100644 --- a/awx/ui_next/src/screens/Inventory/shared/InventoryForm.test.jsx +++ b/awx/ui_next/src/screens/Inventory/shared/InventoryForm.test.jsx @@ -94,6 +94,7 @@ describe('', () => { 1 ); expect(wrapper.find('VariablesField[label="Variables"]').length).toBe(1); + expect(wrapper.find('CodeEditor').prop('value')).toEqual('---'); }); test('should update form values', async () => { diff --git a/awx/ui_next/src/screens/NotificationTemplate/shared/NotificationTemplateForm.test.jsx b/awx/ui_next/src/screens/NotificationTemplate/shared/NotificationTemplateForm.test.jsx index c828b1450f..5b90fd5e8d 100644 --- a/awx/ui_next/src/screens/NotificationTemplate/shared/NotificationTemplateForm.test.jsx +++ b/awx/ui_next/src/screens/NotificationTemplate/shared/NotificationTemplateForm.test.jsx @@ -79,6 +79,33 @@ describe('', () => { ).toEqual(defaultMessages); }); + test('should render custom messages fields', () => { + const wrapper = mountWithContexts( + + ); + + expect( + wrapper + .find('CodeEditor') + .at(0) + .prop('value') + ).toEqual('Started'); + }); + test('should submit', async () => { const handleSubmit = jest.fn(); const wrapper = mountWithContexts(