Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: unable to submit after fixing validation errors #114

Merged
merged 1 commit into from
Oct 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/Launch/LaunchForm/launchMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ const baseStateConfig: StatesConfig<
},
[LaunchState.INVALID_INPUTS]: {
on: {
VALIDATE: LaunchState.VALIDATING_INPUTS
VALIDATE: LaunchState.VALIDATING_INPUTS,
SUBMIT: LaunchState.SUBMIT_VALIDATING
}
},
[LaunchState.SUBMIT_VALIDATING]: {
Expand Down
24 changes: 24 additions & 0 deletions src/components/Launch/LaunchForm/test/LaunchTaskForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,30 @@ describe('LaunchForm: Task', () => {
await waitFor(() => expect(integerInput).toBeValid());
});

it('should allow submission after fixing validation errors', async () => {
const { container, getByLabelText } = renderForm();
await waitFor(() => {});

const integerInput = await waitFor(() =>
getByLabelText(integerInputName, {
exact: false
})
);
fillInputs(container);
const submitButton = getSubmitButton(container);
fireEvent.change(integerInput, { target: { value: 'abc' } });
fireEvent.click(submitButton);
await waitFor(() => expect(integerInput).toBeInvalid());
expect(mockCreateWorkflowExecution).not.toHaveBeenCalled();

fireEvent.change(integerInput, { target: { value: '123' } });
await waitFor(() => expect(integerInput).toBeValid());
fireEvent.click(submitButton);
await waitFor(() =>
expect(mockCreateWorkflowExecution).toHaveBeenCalled()
);
});

it('should update inputs when selecting a new task version', async () => {
const { queryByLabelText, getByTitle } = renderForm();
const taskVersionDiv = await waitFor(() =>
Expand Down
23 changes: 23 additions & 0 deletions src/components/Launch/LaunchForm/test/LaunchWorkflowForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,29 @@ describe('LaunchForm: Workflow', () => {
expect(integerInput).toBeValid();
});

it('should allow submission after fixing validation errors', async () => {
const { container, getByLabelText } = renderForm();
await waitFor(() => {});

const integerInput = await waitFor(() =>
getByLabelText(integerInputName, {
exact: false
})
);
const submitButton = getSubmitButton(container);
fireEvent.change(integerInput, { target: { value: 'abc' } });
fireEvent.click(submitButton);
await waitFor(() => expect(integerInput).toBeInvalid());
expect(mockCreateWorkflowExecution).not.toHaveBeenCalled();

fireEvent.change(integerInput, { target: { value: '123' } });
await waitFor(() => expect(integerInput).toBeValid());
fireEvent.click(submitButton);
await waitFor(() =>
expect(mockCreateWorkflowExecution).toHaveBeenCalled()
);
});

it('should update launch plan when selecting a new workflow version', async () => {
const { getByTitle } = renderForm();
await waitFor(() => getByTitle(formStrings.launchPlan));
Expand Down