Skip to content

Commit 0d34027

Browse files
committed
Adds test.
1 parent 4b9fcf3 commit 0d34027

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

src/components/Task/Modal/Form/TaskModalForm.test.tsx

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,66 @@ describe('TaskModalForm', () => {
199199
});
200200
}, 10000);
201201

202+
it('should toggle suggested tags and additional tags', async () => {
203+
const { findByRole, getByRole, queryByRole } = render(
204+
<LocalizationProvider dateAdapter={AdapterLuxon}>
205+
<SnackbarProvider>
206+
<GqlMockedProvider<{
207+
AssigneeOptions: AssigneeOptionsQuery;
208+
ContactOptions: ContactOptionsQuery;
209+
TagOptions: TagOptionsQuery;
210+
}>
211+
mocks={{
212+
AssigneeOptions: {
213+
accountListUsers: {
214+
nodes: [
215+
{
216+
user: { id: 'user-1', firstName: 'User', lastName: '1' },
217+
},
218+
{
219+
user: { id: 'user-2', firstName: 'User', lastName: '2' },
220+
},
221+
],
222+
},
223+
},
224+
ContactOptions: {
225+
contacts: {
226+
nodes: [
227+
{ id: 'contact-1', name: 'Contact 1' },
228+
{ id: 'contact-2', name: 'Contact 2' },
229+
],
230+
},
231+
},
232+
TagOptions: {
233+
accountList: {
234+
taskTagList: ['tag-1', 'tag-2'],
235+
},
236+
},
237+
}}
238+
onCall={mutationSpy}
239+
>
240+
<TaskModalForm accountListId={accountListId} onClose={onClose} />
241+
</GqlMockedProvider>
242+
</SnackbarProvider>
243+
</LocalizationProvider>,
244+
);
245+
246+
userEvent.click(getByRole('combobox', { name: 'Task Type' }));
247+
userEvent.click(await findByRole('option', { name: 'Appointment' }));
248+
249+
expect(getByRole('combobox', { name: 'Tags' })).toBeInTheDocument();
250+
251+
userEvent.click(getByRole('combobox', { name: 'Tags' }));
252+
userEvent.click(await findByRole('option', { name: 'tag-1' }));
253+
254+
expect(getByRole('button', { name: 'tag-1' })).toBeInTheDocument();
255+
256+
userEvent.click(getByRole('combobox', { name: 'Tags' }));
257+
await waitFor(() =>
258+
expect(queryByRole('option', { name: 'tag-1' })).not.toBeInTheDocument(),
259+
);
260+
}, 10000);
261+
202262
it('persisted', async () => {
203263
const {
204264
getByRole,

0 commit comments

Comments
 (0)