diff --git a/x-pack/plugins/cases/public/components/connectors/servicenow/servicenow_itsm_case_fields.test.tsx b/x-pack/plugins/cases/public/components/connectors/servicenow/servicenow_itsm_case_fields.test.tsx index 755d9c16a332f3..462bf6b1087dad 100644 --- a/x-pack/plugins/cases/public/components/connectors/servicenow/servicenow_itsm_case_fields.test.tsx +++ b/x-pack/plugins/cases/public/components/connectors/servicenow/servicenow_itsm_case_fields.test.tsx @@ -41,18 +41,18 @@ describe('ServiceNowITSM Fields', () => { jest.clearAllMocks(); }); - it('all params fields are rendered', () => { + it('all params fields are rendered', async () => { appMockRenderer.render( ); - expect(screen.getByTestId('severitySelect')).toBeInTheDocument(); - expect(screen.getByTestId('urgencySelect')).toBeInTheDocument(); - expect(screen.getByTestId('impactSelect')).toBeInTheDocument(); - expect(screen.getByTestId('categorySelect')).toBeInTheDocument(); - expect(screen.getByTestId('subcategorySelect')).toBeInTheDocument(); + expect(await screen.findByTestId('severitySelect')).toBeInTheDocument(); + expect(await screen.findByTestId('urgencySelect')).toBeInTheDocument(); + expect(await screen.findByTestId('impactSelect')).toBeInTheDocument(); + expect(await screen.findByTestId('categorySelect')).toBeInTheDocument(); + expect(await screen.findByTestId('subcategorySelect')).toBeInTheDocument(); }); it('transforms the categories to options correctly', async () => { @@ -62,11 +62,11 @@ describe('ServiceNowITSM Fields', () => { ); - expect(screen.getByRole('option', { name: 'Privilege Escalation' })); - expect(screen.getByRole('option', { name: 'Criminal activity/investigation' })); - expect(screen.getByRole('option', { name: 'Denial of Service' })); - expect(screen.getByRole('option', { name: 'Software' })); - expect(screen.getByRole('option', { name: 'Failed Login' })); + expect(await screen.findByRole('option', { name: 'Privilege Escalation' })); + expect(await screen.findByRole('option', { name: 'Criminal activity/investigation' })); + expect(await screen.findByRole('option', { name: 'Denial of Service' })); + expect(await screen.findByRole('option', { name: 'Software' })); + expect(await screen.findByRole('option', { name: 'Failed Login' })); }); it('transforms the subcategories to options correctly', async () => { @@ -76,7 +76,7 @@ describe('ServiceNowITSM Fields', () => { ); - expect(screen.getByRole('option', { name: 'Operation System' })); + expect(await screen.findByRole('option', { name: 'Operation System' })); }); it('transforms the options correctly', async () => { @@ -86,6 +86,8 @@ describe('ServiceNowITSM Fields', () => { ); + expect(await screen.findByTestId('connector-fields-sn-itsm')).toBeInTheDocument(); + const testers = ['severity', 'urgency', 'impact']; testers.forEach((subj) => { const select = within(screen.getByTestId(`${subj}Select`)); @@ -106,7 +108,7 @@ describe('ServiceNowITSM Fields', () => { ); - expect(screen.getByTestId('deprecated-connector-warning-callout')).toBeInTheDocument(); + expect(await screen.findByTestId('deprecated-connector-warning-callout')).toBeInTheDocument(); }); it('does not show the deprecated callout when the connector is not deprecated', async () => { @@ -135,7 +137,7 @@ describe('ServiceNowITSM Fields', () => { ); - expect(screen.queryByTestId('deprecated-connector-warning-callout')).toBeInTheDocument(); + expect(await screen.findByTestId('deprecated-connector-warning-callout')).toBeInTheDocument(); }); it('shows the subcategory if the selected category does not have subcategories', async () => { @@ -152,21 +154,21 @@ describe('ServiceNowITSM Fields', () => { ); - expect(screen.getByTestId('subcategorySelect')).toBeInTheDocument(); - expect(screen.getByTestId('subcategorySelect')).not.toHaveValue(); + expect(await screen.findByTestId('subcategorySelect')).toBeInTheDocument(); + expect(await screen.findByTestId('subcategorySelect')).not.toHaveValue(); }); describe('changing selectables', () => { const testers = ['severity', 'urgency', 'impact']; testers.forEach((subj) => - it(`${subj.toUpperCase()}`, () => { + it(`${subj.toUpperCase()}`, async () => { appMockRenderer.render( ); - const select = screen.getByTestId(`${subj}Select`); + const select = await screen.findByTestId(`${subj}Select`); userEvent.selectOptions(select, '4 - Low'); expect(select).toHaveValue('4'); @@ -181,9 +183,9 @@ describe('ServiceNowITSM Fields', () => { ); - const severitySelect = screen.getByTestId('severitySelect'); - const urgencySelect = screen.getByTestId('urgencySelect'); - const impactSelect = screen.getByTestId('impactSelect'); + const severitySelect = await screen.findByTestId('severitySelect'); + const urgencySelect = await screen.findByTestId('urgencySelect'); + const impactSelect = await screen.findByTestId('impactSelect'); const selectables: Array<[HTMLElement, 'severity' | 'urgency' | 'impact']> = [ [severitySelect, 'severity'], @@ -195,19 +197,15 @@ describe('ServiceNowITSM Fields', () => { userEvent.selectOptions(element, ['2']); }); - const categorySelect = screen.getByTestId('categorySelect'); + const categorySelect = await screen.findByTestId('categorySelect'); - await waitFor(() => { - expect(within(categorySelect).getByRole('option', { name: 'Software' })); - }); + expect(await within(categorySelect).findByRole('option', { name: 'Software' })); userEvent.selectOptions(categorySelect, ['software']); - const subcategorySelect = screen.getByTestId('subcategorySelect'); + const subcategorySelect = await screen.findByTestId('subcategorySelect'); - await waitFor(() => { - expect(within(subcategorySelect).getByRole('option', { name: 'Operation System' })); - }); + expect(await within(subcategorySelect).findByRole('option', { name: 'Operation System' })); userEvent.selectOptions(subcategorySelect, ['os']); @@ -225,19 +223,15 @@ describe('ServiceNowITSM Fields', () => { ); - const categorySelect = screen.getByTestId('categorySelect'); + const categorySelect = await screen.findByTestId('categorySelect'); - await waitFor(() => { - expect(within(categorySelect).getByRole('option', { name: 'Software' })); - }); + expect(await within(categorySelect).findByRole('option', { name: 'Software' })); userEvent.selectOptions(categorySelect, ['software']); - const subcategorySelect = screen.getByTestId('subcategorySelect'); + const subcategorySelect = await screen.findByTestId('subcategorySelect'); - await waitFor(() => { - expect(within(subcategorySelect).getByRole('option', { name: 'Operation System' })); - }); + expect(await within(subcategorySelect).findByRole('option', { name: 'Operation System' })); expect(subcategorySelect).toHaveValue('os');