mirror of
https://github.com/ansible/awx.git
synced 2026-05-20 23:37:39 -02:30
Merge pull request #7738 from mabashian/test-console-cleanup
Test console cleanup Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
@@ -208,8 +208,10 @@ describe('<CredentialForm />', () => {
|
|||||||
});
|
});
|
||||||
wrapper.update();
|
wrapper.update();
|
||||||
expect(
|
expect(
|
||||||
wrapper.find('FormGroup[fieldId="credential-gce-file"]').prop('isValid')
|
wrapper
|
||||||
).toBe(false);
|
.find('FormGroup[fieldId="credential-gce-file"]')
|
||||||
|
.prop('validated')
|
||||||
|
).toBe('error');
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
wrapper
|
wrapper
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ function BecomeMethodField({ fieldOptions, isRequired }) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
isRequired={isRequired}
|
isRequired={isRequired}
|
||||||
isValid={!(meta.touched && meta.error)}
|
validated={!(meta.touched && meta.error) ? 'default' : 'error'}
|
||||||
>
|
>
|
||||||
<Select
|
<Select
|
||||||
maxHeight={200}
|
maxHeight={200}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ function CredentialInput({ fieldOptions, credentialKind, ...rest }) {
|
|||||||
onChange={(value, event) => {
|
onChange={(value, event) => {
|
||||||
subFormField.onChange(event);
|
subFormField.onChange(event);
|
||||||
}}
|
}}
|
||||||
isValid={isValid}
|
validated={isValid ? 'default' : 'error'}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -38,7 +38,6 @@ function CredentialInput({ fieldOptions, credentialKind, ...rest }) {
|
|||||||
<PasswordInput
|
<PasswordInput
|
||||||
{...subFormField}
|
{...subFormField}
|
||||||
id={`credential-${fieldOptions.id}`}
|
id={`credential-${fieldOptions.id}`}
|
||||||
isValid={isValid}
|
|
||||||
{...rest}
|
{...rest}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@@ -55,7 +54,7 @@ function CredentialInput({ fieldOptions, credentialKind, ...rest }) {
|
|||||||
onChange={(value, event) => {
|
onChange={(value, event) => {
|
||||||
subFormField.onChange(event);
|
subFormField.onChange(event);
|
||||||
}}
|
}}
|
||||||
isValid={isValid}
|
validated={isValid ? 'default' : 'error'}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -107,7 +106,7 @@ function CredentialField({ credentialType, fieldOptions, i18n }) {
|
|||||||
helperTextInvalid={meta.error}
|
helperTextInvalid={meta.error}
|
||||||
label={fieldOptions.label}
|
label={fieldOptions.label}
|
||||||
isRequired={isRequired}
|
isRequired={isRequired}
|
||||||
isValid={isValid}
|
validated={isValid ? 'default' : 'error'}
|
||||||
>
|
>
|
||||||
<AnsibleSelect
|
<AnsibleSelect
|
||||||
{...subFormField}
|
{...subFormField}
|
||||||
@@ -132,7 +131,7 @@ function CredentialField({ credentialType, fieldOptions, i18n }) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
isRequired={isRequired}
|
isRequired={isRequired}
|
||||||
isValid={isValid}
|
validated={isValid ? 'default' : 'error'}
|
||||||
>
|
>
|
||||||
<CredentialInput
|
<CredentialInput
|
||||||
credentialKind={credentialType.kind}
|
credentialKind={credentialType.kind}
|
||||||
@@ -150,7 +149,7 @@ function CredentialField({ credentialType, fieldOptions, i18n }) {
|
|||||||
<CredentialPluginField
|
<CredentialPluginField
|
||||||
fieldOptions={fieldOptions}
|
fieldOptions={fieldOptions}
|
||||||
isRequired={isRequired}
|
isRequired={isRequired}
|
||||||
isValid={isValid}
|
validated={isValid ? 'default' : 'error'}
|
||||||
>
|
>
|
||||||
<CredentialInput fieldOptions={fieldOptions} />
|
<CredentialInput fieldOptions={fieldOptions} />
|
||||||
</CredentialPluginField>
|
</CredentialPluginField>
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ function CredentialPluginInput(props) {
|
|||||||
{React.cloneElement(children, {
|
{React.cloneElement(children, {
|
||||||
...inputField,
|
...inputField,
|
||||||
isRequired,
|
isRequired,
|
||||||
isValid,
|
validated: isValid ? 'default' : 'error',
|
||||||
isDisabled: !!passwordPromptField.value,
|
isDisabled: !!passwordPromptField.value,
|
||||||
onChange: (_, event) => {
|
onChange: (_, event) => {
|
||||||
inputField.onChange(event);
|
inputField.onChange(event);
|
||||||
@@ -125,7 +125,7 @@ function CredentialPluginField(props) {
|
|||||||
fieldId={`credential-${fieldOptions.id}`}
|
fieldId={`credential-${fieldOptions.id}`}
|
||||||
helperTextInvalid={meta.error}
|
helperTextInvalid={meta.error}
|
||||||
isRequired={isRequired}
|
isRequired={isRequired}
|
||||||
isValid={isValid}
|
validated={isValid ? 'default' : 'error'}
|
||||||
label={fieldOptions.label}
|
label={fieldOptions.label}
|
||||||
labelIcon={
|
labelIcon={
|
||||||
fieldOptions.help_text && (
|
fieldOptions.help_text && (
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ function GceFileUploadField({ i18n }) {
|
|||||||
return (
|
return (
|
||||||
<FormGroup
|
<FormGroup
|
||||||
fieldId="credential-gce-file"
|
fieldId="credential-gce-file"
|
||||||
isValid={!fileError}
|
validated={!fileError ? 'default' : 'error'}
|
||||||
label={i18n._(t`Service account JSON file`)}
|
label={i18n._(t`Service account JSON file`)}
|
||||||
helperText={i18n._(
|
helperText={i18n._(
|
||||||
t`Select a JSON formatted service account key to autopopulate the following fields.`
|
t`Select a JSON formatted service account key to autopopulate the following fields.`
|
||||||
|
|||||||
@@ -51,11 +51,13 @@ describe('<InventoryAdd />', () => {
|
|||||||
];
|
];
|
||||||
await waitForElement(wrapper, 'isLoading', el => el.length === 0);
|
await waitForElement(wrapper, 'isLoading', el => el.length === 0);
|
||||||
|
|
||||||
wrapper.find('InventoryForm').prop('onSubmit')({
|
await act(async () => {
|
||||||
name: 'new Foo',
|
wrapper.find('InventoryForm').prop('onSubmit')({
|
||||||
organization: { id: 2 },
|
name: 'new Foo',
|
||||||
insights_credential: { id: 47 },
|
organization: { id: 2 },
|
||||||
instanceGroups,
|
insights_credential: { id: 47 },
|
||||||
|
instanceGroups,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
await sleep(1);
|
await sleep(1);
|
||||||
expect(InventoriesAPI.create).toHaveBeenCalledWith({
|
expect(InventoriesAPI.create).toHaveBeenCalledWith({
|
||||||
@@ -74,7 +76,9 @@ describe('<InventoryAdd />', () => {
|
|||||||
|
|
||||||
test('handleCancel should return the user back to the inventories list', async () => {
|
test('handleCancel should return the user back to the inventories list', async () => {
|
||||||
await waitForElement(wrapper, 'isLoading', el => el.length === 0);
|
await waitForElement(wrapper, 'isLoading', el => el.length === 0);
|
||||||
wrapper.find('Button[aria-label="Cancel"]').simulate('click');
|
await act(async () => {
|
||||||
|
wrapper.find('Button[aria-label="Cancel"]').simulate('click');
|
||||||
|
});
|
||||||
expect(history.location.pathname).toEqual('/inventories');
|
expect(history.location.pathname).toEqual('/inventories');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -102,7 +102,9 @@ describe('<InventoryEdit />', () => {
|
|||||||
|
|
||||||
test('handleCancel returns the user to inventory detail', async () => {
|
test('handleCancel returns the user to inventory detail', async () => {
|
||||||
await waitForElement(wrapper, 'isLoading', el => el.length === 0);
|
await waitForElement(wrapper, 'isLoading', el => el.length === 0);
|
||||||
wrapper.find('Button[aria-label="Cancel"]').simulate('click');
|
await act(async () => {
|
||||||
|
wrapper.find('Button[aria-label="Cancel"]').simulate('click');
|
||||||
|
});
|
||||||
expect(history.location.pathname).toEqual(
|
expect(history.location.pathname).toEqual(
|
||||||
'/inventories/inventory/1/details'
|
'/inventories/inventory/1/details'
|
||||||
);
|
);
|
||||||
@@ -114,12 +116,14 @@ describe('<InventoryEdit />', () => {
|
|||||||
{ name: 'Bizz', id: 2 },
|
{ name: 'Bizz', id: 2 },
|
||||||
{ name: 'Buzz', id: 3 },
|
{ name: 'Buzz', id: 3 },
|
||||||
];
|
];
|
||||||
wrapper.find('InventoryForm').prop('onSubmit')({
|
await act(async () => {
|
||||||
name: 'Foo',
|
wrapper.find('InventoryForm').prop('onSubmit')({
|
||||||
id: 13,
|
name: 'Foo',
|
||||||
organization: { id: 1 },
|
id: 13,
|
||||||
insights_credential: { id: 13 },
|
organization: { id: 1 },
|
||||||
instanceGroups,
|
insights_credential: { id: 13 },
|
||||||
|
instanceGroups,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
await sleep(0);
|
await sleep(0);
|
||||||
instanceGroups.map(IG =>
|
instanceGroups.map(IG =>
|
||||||
|
|||||||
@@ -241,7 +241,9 @@ describe('<JobTemplateAdd />', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
await waitForElement(wrapper, 'EmptyStateBody', el => el.length === 0);
|
await waitForElement(wrapper, 'EmptyStateBody', el => el.length === 0);
|
||||||
wrapper.find('button[aria-label="Cancel"]').invoke('onClick')();
|
await act(async () => {
|
||||||
|
wrapper.find('button[aria-label="Cancel"]').invoke('onClick')();
|
||||||
|
});
|
||||||
expect(history.location.pathname).toEqual('/templates');
|
expect(history.location.pathname).toEqual('/templates');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -131,7 +131,9 @@ function WorkflowJobTemplateForm({
|
|||||||
<TextInput
|
<TextInput
|
||||||
id="text-wfjt-limit"
|
id="text-wfjt-limit"
|
||||||
{...limitField}
|
{...limitField}
|
||||||
isValid={!limitMeta.touched || !limitMeta.error}
|
validated={
|
||||||
|
!limitMeta.touched || !limitMeta.error ? 'default' : 'error'
|
||||||
|
}
|
||||||
onChange={value => {
|
onChange={value => {
|
||||||
limitHelpers.setValue(value);
|
limitHelpers.setValue(value);
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -12,3 +12,10 @@ require('@nteract/mockument');
|
|||||||
|
|
||||||
// eslint-disable-next-line import/prefer-default-export
|
// eslint-disable-next-line import/prefer-default-export
|
||||||
export const asyncFlush = () => new Promise(resolve => setImmediate(resolve));
|
export const asyncFlush = () => new Promise(resolve => setImmediate(resolve));
|
||||||
|
|
||||||
|
// this ensures that debug messages don't get logged out to the console
|
||||||
|
// while tests are running i.e. websocket connect/disconnect
|
||||||
|
global.console = {
|
||||||
|
...console,
|
||||||
|
debug: jest.fn(),
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user