Fix for Save button not responding on Job Settings page

Signed-off-by: Vidya Nambiar <vnambiar@redhat.com>
This commit is contained in:
Vidya Nambiar 2022-12-22 11:23:03 -05:00
parent 8f6849fc22
commit 68e555824d
3 changed files with 27 additions and 6 deletions

View File

@ -141,14 +141,14 @@ function JobsEdit() {
<FormColumnLayout>
<InputField
name="AWX_ISOLATION_BASE_PATH"
config={jobs.AWX_ISOLATION_BASE_PATH}
isRequired
config={jobs.AWX_ISOLATION_BASE_PATH ?? null}
isRequired={Boolean(options?.AWX_ISOLATION_BASE_PATH)}
/>
<InputField
name="SCHEDULE_MAX_JOBS"
config={jobs.SCHEDULE_MAX_JOBS}
type="number"
isRequired
config={jobs.SCHEDULE_MAX_JOBS ?? null}
type={options?.SCHEDULE_MAX_JOBS ? 'number' : undefined}
isRequired={Boolean(options?.SCHEDULE_MAX_JOBS)}
/>
<InputField
name="DEFAULT_JOB_TIMEOUT"

View File

@ -122,4 +122,22 @@ describe('<JobsEdit />', () => {
await waitForElement(wrapper, 'ContentLoading', (el) => el.length === 0);
expect(wrapper.find('ContentError').length).toBe(1);
});
test('Form input fields that are invisible (due to being set manually via a settings file) should not prevent submitting the form', async () => {
const mockOptions = Object.assign({}, mockAllOptions);
// If AWX_ISOLATION_BASE_PATH has been set in a settings file it will be absent in the PUT options
delete mockOptions['actions']['PUT']['AWX_ISOLATION_BASE_PATH'];
await act(async () => {
wrapper = mountWithContexts(
<SettingsProvider value={mockOptions.actions}>
<JobsEdit />
</SettingsProvider>
);
});
await waitForElement(wrapper, 'ContentLoading', (el) => el.length === 0);
await act(async () => {
wrapper.find('Form').invoke('onSubmit')();
});
expect(SettingsAPI.updateAll).toHaveBeenCalledTimes(1);
});
});

View File

@ -397,7 +397,10 @@ const InputField = ({ name, config, type = 'text', isRequired = false }) => {
};
InputField.propTypes = {
name: string.isRequired,
config: shape({}).isRequired,
config: shape({}),
};
InputField.defaultProps = {
config: null,
};
const TextAreaField = ({ name, config, isRequired = false }) => {