From 54c599d1d283b44d905e6624f6a7d616f9b51c78 Mon Sep 17 00:00:00 2001 From: Aleksander Nicacio da Silva Date: Thu, 22 Aug 2024 15:09:27 -0300 Subject: [PATCH] test: get by role instead of testId on AssignExtensionModal --- .../users/voip/AssignExtensionModal.spec.tsx | 19 +++++++++++-------- .../admin/users/voip/AssignExtensionModal.tsx | 1 - 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/apps/meteor/client/views/admin/users/voip/AssignExtensionModal.spec.tsx b/apps/meteor/client/views/admin/users/voip/AssignExtensionModal.spec.tsx index 8c058f82565f..38bb02f9bb8d 100644 --- a/apps/meteor/client/views/admin/users/voip/AssignExtensionModal.spec.tsx +++ b/apps/meteor/client/views/admin/users/voip/AssignExtensionModal.spec.tsx @@ -42,9 +42,9 @@ const root = mockAppRoot() success: true, })); -// TODO: it('should load with default user', async () => {}); +it.todo('should load with default user'); -// TODO: it('should load with default extension', async () => {}); +it.todo('should load with default extension'); it('should only enable "Free Extension Numbers" field if username is informed', async () => { render( undefined} />, { @@ -52,14 +52,15 @@ it('should only enable "Free Extension Numbers" field if username is informed', wrapper: root.build(), }); - expect(screen.getByTestId('input-free-extension-numbers')).toHaveClass('disabled'); + const extensionsSelect = screen.getByRole('button', { name: /Select_an_option/i }); + expect(extensionsSelect).toHaveClass('disabled'); expect(screen.getByLabelText('User_Without_Extensions')).toBeEnabled(); screen.getByLabelText('User_Without_Extensions').focus(); const userOption = await screen.findByRole('option', { name: 'Jane Doe' }); await userEvent.click(userOption); - await waitFor(() => expect(screen.getByTestId('input-free-extension-numbers')).not.toHaveClass('disabled')); + await waitFor(() => expect(extensionsSelect).not.toHaveClass('disabled')); }); it('should only enable "Associate" button both username and extension is informed', async () => { @@ -74,9 +75,10 @@ it('should only enable "Associate" button both username and extension is informe const userOption = await screen.findByRole('option', { name: 'Jane Doe' }); await userEvent.click(userOption); - await waitFor(() => expect(screen.getByTestId('input-free-extension-numbers')).not.toHaveClass('disabled')); + const extensionsSelect = screen.getByRole('button', { name: /Select_an_option/i }); + await waitFor(() => expect(extensionsSelect).not.toHaveClass('disabled')); - screen.getByTestId('input-free-extension-numbers').click(); + extensionsSelect.click(); const extOption = await screen.findByRole('option', { name: '1000' }); await userEvent.click(extOption); @@ -94,9 +96,10 @@ it('should call onClose when extension is associated', async () => { const userOption = await screen.findByRole('option', { name: 'Jane Doe' }); await userEvent.click(userOption); - await waitFor(() => expect(screen.getByTestId('input-free-extension-numbers')).not.toHaveClass('disabled')); + const extensionsSelect = screen.getByRole('button', { name: /Select_an_option/i }); + await waitFor(() => expect(extensionsSelect).not.toHaveClass('disabled')); - screen.getByTestId('input-free-extension-numbers').click(); + extensionsSelect.click(); const extOption = await screen.findByRole('option', { name: '1000' }); await userEvent.click(extOption); diff --git a/apps/meteor/client/views/admin/users/voip/AssignExtensionModal.tsx b/apps/meteor/client/views/admin/users/voip/AssignExtensionModal.tsx index b463c5c227ca..3534c6605bbd 100644 --- a/apps/meteor/client/views/admin/users/voip/AssignExtensionModal.tsx +++ b/apps/meteor/client/views/admin/users/voip/AssignExtensionModal.tsx @@ -126,7 +126,6 @@ const AssignExtensionModal = ({ defaultExtension, defaultUsername, onClose }: As placeholder={t('Select_an_option')} value={field.value} onChange={field.onChange} - data-testid='input-free-extension-numbers' /> )} />