Merge pull request #10041 from mabashian/test-warning-cleanup-2

Unit test warning cleanup

SUMMARY
Cleans up warnings thrown on several unit tests
COMPONENT NAME

UI

Reviewed-by: Kersom <None>
This commit is contained in:
softwarefactory-project-zuul[bot]
2021-04-28 19:15:28 +00:00
committed by GitHub
5 changed files with 49 additions and 22 deletions

View File

@@ -58,13 +58,13 @@ function JobListCancelButton({ i18n, jobsToCancel, onCancel }) {
one="You do not have permission to cancel the following job:" one="You do not have permission to cancel the following job:"
other="You do not have permission to cancel the following jobs:" other="You do not have permission to cancel the following jobs:"
/> />
{cannotCancelPermissions.map((job, i) => {cannotCancelPermissions.map((job, i) => (
i === cannotCancelPermissions.length - 1 ? ( <strong key={job}>
<strong> {job}</strong> {' '}
) : ( {job}
<strong> {job},</strong> {i !== cannotCancelPermissions.length - 1 ? ',' : ''}
) </strong>
)} ))}
</div> </div>
)} )}
{cannotCancelNotRunning.length > 0 && ( {cannotCancelNotRunning.length > 0 && (
@@ -74,13 +74,13 @@ function JobListCancelButton({ i18n, jobsToCancel, onCancel }) {
one="You cannot cancel the following job because it is not running:" one="You cannot cancel the following job because it is not running:"
other="You cannot cancel the following jobs because they are not running:" other="You cannot cancel the following jobs because they are not running:"
/> />
{cannotCancelNotRunning.map((job, i) => {cannotCancelNotRunning.map((job, i) => (
i === cannotCancelNotRunning.length - 1 ? ( <strong key={job}>
<strong> {job}</strong> {' '}
) : ( {job}
<strong> {job},</strong> {i !== cannotCancelNotRunning.length - 1 ? ',' : ''}
) </strong>
)} ))}
</div> </div>
)} )}
</div> </div>

View File

@@ -82,9 +82,9 @@ function ScheduleListItem({
{Boolean(isMissingInventory || isMissingSurvey) && ( {Boolean(isMissingInventory || isMissingSurvey) && (
<span> <span>
<Tooltip <Tooltip
content={[isMissingInventory, isMissingSurvey].map(message => ( content={[isMissingInventory, isMissingSurvey].map(message =>
<div key={message}>{message}</div> message ? <div key={message}>{message}</div> : null
))} )}
position="right" position="right"
> >
<ExclamationTriangleIcon /> <ExclamationTriangleIcon />

View File

@@ -1,6 +1,5 @@
import React, { useCallback, useEffect, useState } from 'react'; import React, { useCallback, useEffect, useState } from 'react';
import { useHistory, useParams } from 'react-router-dom'; import { useHistory, useParams } from 'react-router-dom';
import PropTypes from 'prop-types';
import { CardBody } from '../../../components/Card'; import { CardBody } from '../../../components/Card';
import { import {
CredentialsAPI, CredentialsAPI,
@@ -14,6 +13,7 @@ import ContentLoading from '../../../components/ContentLoading';
import CredentialForm from '../shared/CredentialForm'; import CredentialForm from '../shared/CredentialForm';
import useRequest from '../../../util/useRequest'; import useRequest from '../../../util/useRequest';
import { useConfig } from '../../../contexts/Config'; import { useConfig } from '../../../contexts/Config';
import { Credential } from '../../../types';
function CredentialEdit({ credential }) { function CredentialEdit({ credential }) {
const history = useHistory(); const history = useHistory();
@@ -198,7 +198,7 @@ function CredentialEdit({ credential }) {
} }
CredentialEdit.propTypes = { CredentialEdit.propTypes = {
credential: PropTypes.objectOf(PropTypes.object).isRequired, credential: Credential.isRequired,
}; };
export { CredentialEdit as _CredentialEdit }; export { CredentialEdit as _CredentialEdit };

View File

@@ -120,6 +120,7 @@ function NotificationTemplatesList({ i18n }) {
}; };
const canAdd = actions && actions.POST; const canAdd = actions && actions.POST;
const alertGroupDataCy = 'notification-template-alerts';
return ( return (
<> <>
@@ -227,7 +228,7 @@ function NotificationTemplatesList({ i18n }) {
{i18n._(t`Failed to delete one or more notification template.`)} {i18n._(t`Failed to delete one or more notification template.`)}
<ErrorDetail error={deletionError} /> <ErrorDetail error={deletionError} />
</AlertModal> </AlertModal>
<AlertGroup ouiaId="notification-template-alerts" isToast> <AlertGroup data-cy={alertGroupDataCy} isToast>
{testToasts {testToasts
.filter(notification => notification.status !== 'pending') .filter(notification => notification.status !== 'pending')
.map(notification => ( .map(notification => (

View File

@@ -13,9 +13,18 @@ import {
InventoriesAPI, InventoriesAPI,
ProjectsAPI, ProjectsAPI,
CredentialTypesAPI, CredentialTypesAPI,
ExecutionEnvironmentsAPI,
CredentialsAPI,
} from '../../../api'; } 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('<WorkflowJobTemplateForm/>', () => { describe('<WorkflowJobTemplateForm/>', () => {
let wrapper; let wrapper;
@@ -61,7 +70,12 @@ describe('<WorkflowJobTemplateForm/>', () => {
}, },
}); });
OrganizationsAPI.read.mockResolvedValue({ OrganizationsAPI.read.mockResolvedValue({
results: [{ id: 1 }, { id: 2 }], data: {
results: [
{ id: 1, name: 'Organization 1' },
{ id: 2, name: 'Organization 2' },
],
},
}); });
InventoriesAPI.read.mockResolvedValue({ InventoriesAPI.read.mockResolvedValue({
results: [ results: [
@@ -78,6 +92,18 @@ describe('<WorkflowJobTemplateForm/>', () => {
ProjectsAPI.readOptions.mockResolvedValue({ ProjectsAPI.readOptions.mockResolvedValue({
data: { actions: { GET: {}, POST: {} } }, 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({ history = createMemoryHistory({
initialEntries: ['/templates/workflow_job_template/6/edit'], initialEntries: ['/templates/workflow_job_template/6/edit'],