Skip to content

Commit

Permalink
Hide next action select when there are no suggested actions
Browse files Browse the repository at this point in the history
  • Loading branch information
canac committed Oct 3, 2024
1 parent 1940761 commit 7e3f166
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
36 changes: 36 additions & 0 deletions src/components/Task/Modal/Form/LogForm/TaskModalLogForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,42 @@ describe('TaskModalLogForm', () => {
expect(getByRole('combobox', { name: 'Next Action' })).toBeInTheDocument();
});

it('hides next action for results with no suggested next actions', async () => {
const { getByRole, findByRole, queryByRole } = render(
<ThemeProvider theme={theme}>
<LocalizationProvider dateAdapter={AdapterLuxon}>
<SnackbarProvider>
<GqlMockedProvider<{
LoadConstants: LoadConstantsQuery;
}>
mocks={{
LoadConstants,
}}
>
<TaskModalLogForm
accountListId={accountListId}
onClose={jest.fn()}
/>
</GqlMockedProvider>
</SnackbarProvider>
</LocalizationProvider>
</ThemeProvider>,
);

userEvent.click(getByRole('combobox', { name: 'Task Type' }));
userEvent.click(await findByRole('option', { name: 'Initiation' }));

userEvent.click(getByRole('combobox', { name: 'Action' }));
userEvent.click(await findByRole('option', { name: 'In Person' }));

userEvent.click(getByRole('combobox', { name: 'Result' }));
userEvent.click(await findByRole('option', { name: 'Not Interested' }));

expect(
queryByRole('combobox', { name: 'Next Action' }),
).not.toBeInTheDocument();
});

it('opens the next action modal', async () => {
const mutationSpy = jest.fn();
const onClose = jest.fn();
Expand Down
2 changes: 1 addition & 1 deletion src/components/Task/Modal/Form/possibleNextActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const possibleNextActions = (
)
: null;

return result?.suggestedNextActions
return result?.suggestedNextActions?.length
? [ActivityTypeEnum.None, ...result.suggestedNextActions]
: [];
};

0 comments on commit 7e3f166

Please sign in to comment.