mirror of
https://github.com/ansible/awx.git
synced 2026-03-13 23:17:32 -02:30
fix errors being logged during tests; de-lint
This commit is contained in:
@@ -10,8 +10,7 @@ function FormSubmitError({ error }) {
|
||||
if (!error) {
|
||||
return;
|
||||
}
|
||||
// check for field-specific errors from API
|
||||
if (error.response?.data && typeof error.response.data === 'object') {
|
||||
if (error?.response?.data && typeof error.response.data === 'object') {
|
||||
const errorMessages = error.response.data;
|
||||
setErrors(errorMessages);
|
||||
if (errorMessages.__all__) {
|
||||
|
||||
@@ -30,6 +30,12 @@ describe('<HostAdd />', () => {
|
||||
});
|
||||
|
||||
test('handleSubmit should post to api', async () => {
|
||||
HostsAPI.create.mockResolvedValueOnce({
|
||||
data: {
|
||||
...hostData,
|
||||
id: 5,
|
||||
},
|
||||
});
|
||||
await act(async () => {
|
||||
wrapper.find('HostForm').prop('handleSubmit')(hostData);
|
||||
});
|
||||
|
||||
@@ -2,7 +2,6 @@ import React, { useState, useEffect } from 'react';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import { PageSection, Card } from '@patternfly/react-core';
|
||||
import { CardBody } from '@components/Card';
|
||||
import ContentError from '@components/ContentError';
|
||||
import ContentLoading from '@components/ContentLoading';
|
||||
|
||||
import { InventoriesAPI, CredentialTypesAPI } from '@api';
|
||||
|
||||
@@ -5,7 +5,6 @@ import { object } from 'prop-types';
|
||||
import { CardBody } from '@components/Card';
|
||||
import { InventoriesAPI, CredentialTypesAPI } from '@api';
|
||||
import ContentLoading from '@components/ContentLoading';
|
||||
import ContentError from '@components/ContentError';
|
||||
import InventoryForm from '../shared/InventoryForm';
|
||||
import { getAddedAndRemoved } from '../../../util/lists';
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ describe('<OrganizationAdd />', () => {
|
||||
description: 'new description',
|
||||
custom_virtualenv: 'Buzz',
|
||||
};
|
||||
OrganizationsAPI.create.mockResolvedValueOnce({ data: {} });
|
||||
await act(async () => {
|
||||
const wrapper = mountWithContexts(<OrganizationAdd />);
|
||||
wrapper.find('OrganizationForm').prop('onSubmit')(updatedOrgData, [], []);
|
||||
|
||||
@@ -12,7 +12,7 @@ class TeamAdd extends React.Component {
|
||||
super(props);
|
||||
this.handleSubmit = this.handleSubmit.bind(this);
|
||||
this.handleCancel = this.handleCancel.bind(this);
|
||||
this.state = { error: '' };
|
||||
this.state = { error: null };
|
||||
}
|
||||
|
||||
async handleSubmit(values) {
|
||||
|
||||
@@ -9,6 +9,7 @@ jest.mock('@api');
|
||||
|
||||
describe('<TeamAdd />', () => {
|
||||
test('handleSubmit should post to api', async () => {
|
||||
TeamsAPI.create.mockResolvedValueOnce({ data: {} });
|
||||
const wrapper = mountWithContexts(<TeamAdd />);
|
||||
const updatedTeamData = {
|
||||
name: 'new name',
|
||||
|
||||
@@ -13,6 +13,7 @@ describe('<UserAdd />', () => {
|
||||
await act(async () => {
|
||||
wrapper = mountWithContexts(<UserAdd />);
|
||||
});
|
||||
UsersAPI.create.mockResolvedValueOnce({ data: {} });
|
||||
const updatedUserData = {
|
||||
username: 'sysadmin',
|
||||
email: 'sysadmin@ansible.com',
|
||||
|
||||
Reference in New Issue
Block a user