From 61f0edc5e89dd0e1b8983ce2de90cb2dce80eac5 Mon Sep 17 00:00:00 2001 From: mabashian Date: Tue, 27 Apr 2021 16:09:43 -0400 Subject: [PATCH 1/5] Fix `Each child in a list should have a unique "key" prop` warnings in unit tests --- .../JobList/JobListCancelButton.jsx | 28 +++++++++---------- .../ScheduleList/ScheduleListItem.jsx | 6 ++-- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/awx/ui_next/src/components/JobList/JobListCancelButton.jsx b/awx/ui_next/src/components/JobList/JobListCancelButton.jsx index 9b6d15c661..cfa18a43ef 100644 --- a/awx/ui_next/src/components/JobList/JobListCancelButton.jsx +++ b/awx/ui_next/src/components/JobList/JobListCancelButton.jsx @@ -58,13 +58,13 @@ function JobListCancelButton({ i18n, jobsToCancel, onCancel }) { one="You do not have permission to cancel the following job:" other="You do not have permission to cancel the following jobs:" /> - {cannotCancelPermissions.map((job, i) => - i === cannotCancelPermissions.length - 1 ? ( - {job} - ) : ( - {job}, - ) - )} + {cannotCancelPermissions.map((job, i) => ( + + {' '} + {job} + {i !== cannotCancelPermissions.length - 1 ? ',' : ''} + + ))} )} {cannotCancelNotRunning.length > 0 && ( @@ -74,13 +74,13 @@ function JobListCancelButton({ i18n, jobsToCancel, onCancel }) { one="You cannot cancel the following job because it is not running:" other="You cannot cancel the following jobs because they are not running:" /> - {cannotCancelNotRunning.map((job, i) => - i === cannotCancelNotRunning.length - 1 ? ( - {job} - ) : ( - {job}, - ) - )} + {cannotCancelNotRunning.map((job, i) => ( + + {' '} + {job} + {i !== cannotCancelNotRunning.length - 1 ? ',' : ''} + + ))} )} diff --git a/awx/ui_next/src/components/Schedule/ScheduleList/ScheduleListItem.jsx b/awx/ui_next/src/components/Schedule/ScheduleList/ScheduleListItem.jsx index c241e5b201..1e6bd30f1e 100644 --- a/awx/ui_next/src/components/Schedule/ScheduleList/ScheduleListItem.jsx +++ b/awx/ui_next/src/components/Schedule/ScheduleList/ScheduleListItem.jsx @@ -82,9 +82,9 @@ function ScheduleListItem({ {Boolean(isMissingInventory || isMissingSurvey) && ( ( -
{message}
- ))} + content={[isMissingInventory, isMissingSurvey].map(message => + message ?
{message}
: null + )} position="right" > From 94b9892a1b68522d85b31a348818a10e664fb3d3 Mon Sep 17 00:00:00 2001 From: mabashian Date: Tue, 27 Apr 2021 17:33:56 -0400 Subject: [PATCH 2/5] Fixes bug with workflow form test throwing warning about Failed prop type: The prop `value.name` is marked as required in `OrganizationLookup`, but its value is `undefined` --- .../shared/WorkflowJobTemplateForm.test.jsx | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/awx/ui_next/src/screens/Template/shared/WorkflowJobTemplateForm.test.jsx b/awx/ui_next/src/screens/Template/shared/WorkflowJobTemplateForm.test.jsx index 6f32a80d99..a9c87e8fd1 100644 --- a/awx/ui_next/src/screens/Template/shared/WorkflowJobTemplateForm.test.jsx +++ b/awx/ui_next/src/screens/Template/shared/WorkflowJobTemplateForm.test.jsx @@ -13,9 +13,18 @@ import { InventoriesAPI, ProjectsAPI, CredentialTypesAPI, + ExecutionEnvironmentsAPI, + CredentialsAPI, } from '../../../api'; -jest.mock('../../../api'); +jest.mock('../../../api/models/ExecutionEnvironments'); +jest.mock('../../../api/models/WorkflowJobTemplates'); +jest.mock('../../../api/models/Labels'); +jest.mock('../../../api/models/Organizations'); +jest.mock('../../../api/models/Inventories'); +jest.mock('../../../api/models/Projects'); +jest.mock('../../../api/models/CredentialTypes'); +jest.mock('../../../api/models/Credentials'); describe('', () => { let wrapper; @@ -61,7 +70,12 @@ describe('', () => { }, }); OrganizationsAPI.read.mockResolvedValue({ - results: [{ id: 1 }, { id: 2 }], + data: { + results: [ + { id: 1, name: 'Organization 1' }, + { id: 2, name: 'Organization 2' }, + ], + }, }); InventoriesAPI.read.mockResolvedValue({ results: [ @@ -78,6 +92,18 @@ describe('', () => { ProjectsAPI.readOptions.mockResolvedValue({ data: { actions: { GET: {}, POST: {} } }, }); + ExecutionEnvironmentsAPI.read.mockResolvedValue({ + data: { results: [] }, + }); + ExecutionEnvironmentsAPI.readOptions.mockResolvedValue({ + data: { actions: { GET: {}, POST: {} } }, + }); + CredentialsAPI.read.mockResolvedValue({ + data: { results: [] }, + }); + CredentialsAPI.readOptions.mockResolvedValue({ + data: { actions: { GET: {}, POST: {} } }, + }); history = createMemoryHistory({ initialEntries: ['/templates/workflow_job_template/6/edit'], From 04ca1cb1a3be0f174ae49b86f51bf52c3a8ba886 Mon Sep 17 00:00:00 2001 From: mabashian Date: Wed, 28 Apr 2021 09:35:37 -0400 Subject: [PATCH 3/5] Fixes Invalid prop `credential.id` of type `number` supplied to `CredentialEdit`, expected `object` warning in CredentialEdit test --- .../src/screens/Credential/CredentialEdit/CredentialEdit.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/awx/ui_next/src/screens/Credential/CredentialEdit/CredentialEdit.jsx b/awx/ui_next/src/screens/Credential/CredentialEdit/CredentialEdit.jsx index 84d9c7c882..63ea48902e 100644 --- a/awx/ui_next/src/screens/Credential/CredentialEdit/CredentialEdit.jsx +++ b/awx/ui_next/src/screens/Credential/CredentialEdit/CredentialEdit.jsx @@ -14,6 +14,7 @@ import ContentLoading from '../../../components/ContentLoading'; import CredentialForm from '../shared/CredentialForm'; import useRequest from '../../../util/useRequest'; import { useConfig } from '../../../contexts/Config'; +import { Credential } from '../../../types'; function CredentialEdit({ credential }) { const history = useHistory(); @@ -198,7 +199,7 @@ function CredentialEdit({ credential }) { } CredentialEdit.propTypes = { - credential: PropTypes.objectOf(PropTypes.object).isRequired, + credential: Credential.isRequired, }; export { CredentialEdit as _CredentialEdit }; From cc5a73aeb96433a21aa091bc27b59f9e0a90a572 Mon Sep 17 00:00:00 2001 From: mabashian Date: Wed, 28 Apr 2021 10:48:53 -0400 Subject: [PATCH 4/5] Fixes React does not recognize the `ouiaId` prop on a DOM element warning in NotificationTemplateList test --- .../NotificationTemplateList/NotificationTemplateList.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/ui_next/src/screens/NotificationTemplate/NotificationTemplateList/NotificationTemplateList.jsx b/awx/ui_next/src/screens/NotificationTemplate/NotificationTemplateList/NotificationTemplateList.jsx index ea06a49c03..d5079b079e 100644 --- a/awx/ui_next/src/screens/NotificationTemplate/NotificationTemplateList/NotificationTemplateList.jsx +++ b/awx/ui_next/src/screens/NotificationTemplate/NotificationTemplateList/NotificationTemplateList.jsx @@ -227,7 +227,7 @@ function NotificationTemplatesList({ i18n }) { {i18n._(t`Failed to delete one or more notification template.`)} - + {testToasts .filter(notification => notification.status !== 'pending') .map(notification => ( From 6f7d594d0f9451391af1f69185fe2d14f7899e9a Mon Sep 17 00:00:00 2001 From: mabashian Date: Wed, 28 Apr 2021 12:59:34 -0400 Subject: [PATCH 5/5] Fix linting errors --- .../src/screens/Credential/CredentialEdit/CredentialEdit.jsx | 1 - .../NotificationTemplateList/NotificationTemplateList.jsx | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/awx/ui_next/src/screens/Credential/CredentialEdit/CredentialEdit.jsx b/awx/ui_next/src/screens/Credential/CredentialEdit/CredentialEdit.jsx index 63ea48902e..a76f5440c9 100644 --- a/awx/ui_next/src/screens/Credential/CredentialEdit/CredentialEdit.jsx +++ b/awx/ui_next/src/screens/Credential/CredentialEdit/CredentialEdit.jsx @@ -1,6 +1,5 @@ import React, { useCallback, useEffect, useState } from 'react'; import { useHistory, useParams } from 'react-router-dom'; -import PropTypes from 'prop-types'; import { CardBody } from '../../../components/Card'; import { CredentialsAPI, diff --git a/awx/ui_next/src/screens/NotificationTemplate/NotificationTemplateList/NotificationTemplateList.jsx b/awx/ui_next/src/screens/NotificationTemplate/NotificationTemplateList/NotificationTemplateList.jsx index d5079b079e..c2d3a66690 100644 --- a/awx/ui_next/src/screens/NotificationTemplate/NotificationTemplateList/NotificationTemplateList.jsx +++ b/awx/ui_next/src/screens/NotificationTemplate/NotificationTemplateList/NotificationTemplateList.jsx @@ -120,6 +120,7 @@ function NotificationTemplatesList({ i18n }) { }; const canAdd = actions && actions.POST; + const alertGroupDataCy = 'notification-template-alerts'; return ( <> @@ -227,7 +228,7 @@ function NotificationTemplatesList({ i18n }) { {i18n._(t`Failed to delete one or more notification template.`)} - + {testToasts .filter(notification => notification.status !== 'pending') .map(notification => (