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