diff --git a/x-pack/plugins/cases/public/components/connectors/jira/case_fields.test.tsx b/x-pack/plugins/cases/public/components/connectors/jira/case_fields.test.tsx
index c35252f81b12d..743ecac4cdc91 100644
--- a/x-pack/plugins/cases/public/components/connectors/jira/case_fields.test.tsx
+++ b/x-pack/plugins/cases/public/components/connectors/jira/case_fields.test.tsx
@@ -101,9 +101,10 @@ describe('Jira Fields', () => {
);
+ expect(await screen.findByTestId('prioritySelect')).toBeInTheDocument();
+ expect(await screen.findByTestId('issueTypeSelect')).toBeInTheDocument();
+
await waitFor(() => {
- expect(screen.getByTestId('prioritySelect')).toBeInTheDocument();
- expect(screen.getByTestId('issueTypeSelect')).toBeInTheDocument();
expect(screen.queryByTestId('search-parent-issues')).toBeInTheDocument();
});
});
@@ -115,15 +116,15 @@ describe('Jira Fields', () => {
);
- const issueTypeSelect = screen.getByTestId('issueTypeSelect');
+ const issueTypeSelect = await screen.findByTestId('issueTypeSelect');
expect(issueTypeSelect).toBeInTheDocument();
- userEvent.selectOptions(issueTypeSelect, 'Task');
-
- await waitFor(() => {
- expect(screen.getByTestId('prioritySelect')).toBeInTheDocument();
- expect(screen.getByTestId('search-parent-issues')).toBeInTheDocument();
+ fireEvent.change(issueTypeSelect, {
+ target: { value: 'Task' },
});
+
+ expect(await screen.findByTestId('prioritySelect')).toBeInTheDocument();
+ expect(await screen.findByTestId('search-parent-issues')).toBeInTheDocument();
});
it('sets parent correctly', async () => {
@@ -132,7 +133,7 @@ describe('Jira Fields', () => {
);
- const input = screen.getByTestId('comboBoxSearchInput');
+ const input = await screen.findByTestId('comboBoxSearchInput');
fireEvent.change(input, { target: { value: 'parentId' } });
@@ -146,15 +147,18 @@ describe('Jira Fields', () => {
);
- const checkbox = within(screen.getByTestId('search-parent-issues')).getByTestId(
+ const checkbox = within(await screen.findByTestId('search-parent-issues')).getByTestId(
'comboBoxSearchInput'
);
- userEvent.type(checkbox, 'Person Task{enter}');
- expect(checkbox).toHaveValue('Person Task');
+ fireEvent.change(checkbox, {
+ target: { value: 'Person Task{enter}' },
+ });
+
+ expect(checkbox).toHaveValue('Person Task{enter}');
});
- it('disabled the fields when loading issue types', () => {
+ it('disabled the fields when loading issue types', async () => {
useGetIssueTypesMock.mockReturnValue({ ...useGetIssueTypesResponse, isLoading: true });
appMockRenderer.render(
@@ -163,11 +167,11 @@ describe('Jira Fields', () => {
);
- expect(screen.getByTestId('issueTypeSelect')).toBeDisabled();
- expect(screen.getByTestId('prioritySelect')).toBeDisabled();
+ expect(await screen.findByTestId('issueTypeSelect')).toBeDisabled();
+ expect(await screen.findByTestId('prioritySelect')).toBeDisabled();
});
- it('disabled the priority when loading fields', () => {
+ it('disabled the priority when loading fields', async () => {
useGetFieldsByIssueTypeMock.mockReturnValue({
...useGetFieldsByIssueTypeResponse,
isLoading: true,
@@ -179,7 +183,7 @@ describe('Jira Fields', () => {
);
- expect(screen.getByTestId('prioritySelect')).toBeDisabled();
+ expect(await screen.findByTestId('prioritySelect')).toBeDisabled();
});
it('hides the priority if not supported', () => {
@@ -210,27 +214,27 @@ describe('Jira Fields', () => {
expect(screen.queryByTestId('search-parent-issues')).not.toBeVisible();
});
- it('sets issue type correctly', () => {
+ it('sets issue type correctly', async () => {
appMockRenderer.render(
);
- userEvent.selectOptions(screen.getByTestId('issueTypeSelect'), '10007');
- expect(screen.getByTestId('issueTypeSelect')).toHaveValue('10007');
+ userEvent.selectOptions(await screen.findByTestId('issueTypeSelect'), '10007');
+ expect(await screen.findByTestId('issueTypeSelect')).toHaveValue('10007');
});
- it('sets priority correctly', () => {
+ it('sets priority correctly', async () => {
appMockRenderer.render(
);
- userEvent.selectOptions(screen.getByTestId('prioritySelect'), 'Low');
+ userEvent.selectOptions(await screen.findByTestId('prioritySelect'), 'Low');
- expect(screen.getByTestId('prioritySelect')).toHaveValue('Low');
+ expect(await screen.findByTestId('prioritySelect')).toHaveValue('Low');
});
it('should submit Jira connector', async () => {
@@ -240,25 +244,25 @@ describe('Jira Fields', () => {
);
- const issueTypeSelect = screen.getByTestId('issueTypeSelect');
+ const issueTypeSelect = await screen.findByTestId('issueTypeSelect');
expect(issueTypeSelect).toBeInTheDocument();
userEvent.selectOptions(issueTypeSelect, 'Bug');
- await waitFor(() => {
- expect(screen.getByTestId('prioritySelect')).toBeInTheDocument();
- expect(screen.getByTestId('search-parent-issues')).toBeInTheDocument();
- });
+ expect(await screen.findByTestId('prioritySelect')).toBeInTheDocument();
+ expect(await screen.findByTestId('search-parent-issues')).toBeInTheDocument();
- const checkbox = within(screen.getByTestId('search-parent-issues')).getByTestId(
+ const checkbox = within(await screen.findByTestId('search-parent-issues')).getByTestId(
'comboBoxSearchInput'
);
- userEvent.type(checkbox, 'Person Task{enter}');
- userEvent.selectOptions(screen.getByTestId('prioritySelect'), ['Low']);
+ fireEvent.change(checkbox, {
+ target: { value: 'Person Task' },
+ });
+ userEvent.selectOptions(await screen.findByTestId('prioritySelect'), ['Low']);
- expect(screen.getByTestId('issueTypeSelect')).toHaveValue('10007');
- expect(screen.getByTestId('prioritySelect')).toHaveValue('Low');
+ expect(await screen.findByTestId('issueTypeSelect')).toHaveValue('10007');
+ expect(await screen.findByTestId('prioritySelect')).toHaveValue('Low');
expect(checkbox).toHaveValue('Person Task');
});
@@ -269,17 +273,16 @@ describe('Jira Fields', () => {
);
+ expect(await screen.findByTestId('prioritySelect')).toBeInTheDocument();
+ expect(await screen.findByTestId('issueTypeSelect')).toBeInTheDocument();
+
await waitFor(() => {
- expect(screen.getByTestId('prioritySelect')).toBeInTheDocument();
- expect(screen.getByTestId('issueTypeSelect')).toBeInTheDocument();
expect(screen.queryByTestId('search-parent-issues')).toBeInTheDocument();
});
- userEvent.click(screen.getByTestId('submit-form'));
+ userEvent.click(await screen.findByTestId('submit-form'));
- await waitFor(() => {
- expect(screen.getByText('Issue type is required')).toBeInTheDocument();
- });
+ expect(await screen.findByText('Issue type is required')).toBeInTheDocument();
});
it('should not show the loading skeleton when loading issue types', async () => {
@@ -328,6 +331,6 @@ describe('Jira Fields', () => {
);
- expect(screen.getByTestId('fields-by-issue-type-loading')).toBeInTheDocument();
+ expect(await screen.findByTestId('fields-by-issue-type-loading')).toBeInTheDocument();
});
});