Skip to content

Commit

Permalink
fix: missing state transition when fixing Launch validation errors (#114
Browse files Browse the repository at this point in the history
)
  • Loading branch information
schottra authored Oct 23, 2020
1 parent 2a24278 commit e8173f6
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
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

0 comments on commit e8173f6

Please sign in to comment.