From 9b166dff03423601bdf009b63143a66aac0b2b5d Mon Sep 17 00:00:00 2001 From: Christos Nasikas Date: Thu, 22 Sep 2022 18:08:05 +0300 Subject: [PATCH 1/2] Fix flaky test --- .../jira/jira_params.test.tsx | 422 +++++++++++------- .../builtin_action_types/jira/jira_params.tsx | 297 ++++++------ .../jira/search_issues.tsx | 2 +- 3 files changed, 404 insertions(+), 317 deletions(-) diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/jira/jira_params.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/jira/jira_params.test.tsx index b7031f5c120e5..0df1dfb67fcc2 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/jira/jira_params.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/jira/jira_params.test.tsx @@ -6,20 +6,25 @@ */ import React from 'react'; -import { mount } from 'enzyme'; import JiraParamsFields from './jira_params'; import { useGetIssueTypes } from './use_get_issue_types'; import { useGetFieldsByIssueType } from './use_get_fields_by_issue_type'; +import { useGetIssues } from './use_get_issues'; +import { useGetSingleIssue } from './use_get_single_issue'; import { ActionConnector } from '../../../../types'; -import { EuiComboBoxOptionOption } from '@elastic/eui'; -jest.mock('../../../../common/lib/kibana'); +import { act, fireEvent, render, waitFor, within } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; +jest.mock('../../../../common/lib/kibana'); jest.mock('./use_get_issue_types'); jest.mock('./use_get_fields_by_issue_type'); -jest.mock('./search_issues', () => ({ SearchIssues: () => <> })); +jest.mock('./use_get_issues'); +jest.mock('./use_get_single_issue'); const useGetIssueTypesMock = useGetIssueTypes as jest.Mock; const useGetFieldsByIssueTypeMock = useGetFieldsByIssueType as jest.Mock; +const useGetIssuesMock = useGetIssues as jest.Mock; +const useGetSingleIssueMock = useGetSingleIssue as jest.Mock; const actionParams = { subAction: 'pushToService', @@ -40,8 +45,8 @@ const actionParams = { const connector: ActionConnector = { secrets: {}, config: {}, - id: 'test', - actionTypeId: '.test', + id: 'it', + actionTypeId: '.it', name: 'Test', isPreconfigured: false, isDeprecated: false, @@ -56,8 +61,7 @@ const defaultProps = { messageVariables: [], }; -// FLAKY: https://github.com/elastic/kibana/issues/139062 -describe.skip('JiraParamsFields renders', () => { +describe('JiraParamsFields renders', () => { const useGetIssueTypesResponse = { isLoading: false, issueTypes: [ @@ -84,11 +88,16 @@ describe.skip('JiraParamsFields renders', () => { name: 'Medium', id: '3', }, + { + name: 'High', + id: '1', + }, ], defaultValue: { name: 'Medium', id: '3' }, }, }, }; + const useGetFieldsByIssueTypeResponseNoPriority = { ...useGetFieldsByIssueTypeResponse, fields: { @@ -97,106 +106,116 @@ describe.skip('JiraParamsFields renders', () => { description: { allowedValues: [], defaultValue: {} }, }, }; + const useGetFieldsByIssueTypeResponseLoading = { isLoading: true, fields: {}, }; + const useGetIssuesResponse = { + isLoading: false, + issues: [{ id: '1', key: '1', title: 'parent issue' }], + }; + + const useGetSingleIssueResponse = { + issue: { id: '1', key: '1', title: 'parent issue' }, + isLoading: false, + }; + beforeEach(() => { jest.clearAllMocks(); useGetIssueTypesMock.mockReturnValue(useGetIssueTypesResponse); useGetFieldsByIssueTypeMock.mockReturnValue(useGetFieldsByIssueTypeResponse); + useGetIssuesMock.mockReturnValue(useGetIssuesResponse); + useGetSingleIssueMock.mockReturnValue(useGetSingleIssueResponse); }); - test('all params fields are rendered', () => { - const wrapper = mount(); - expect(wrapper.find('[data-test-subj="issueTypeSelect"]').first().prop('value')).toStrictEqual( - '10006' - ); - expect(wrapper.find('[data-test-subj="prioritySelect"]').first().prop('value')).toStrictEqual( - 'High' - ); - expect(wrapper.find('[data-test-subj="summaryInput"]').length > 0).toBeTruthy(); - expect(wrapper.find('[data-test-subj="descriptionTextArea"]').length > 0).toBeTruthy(); - expect(wrapper.find('[data-test-subj="labelsComboBox"]').length > 0).toBeTruthy(); - expect(wrapper.find('[data-test-subj="commentsTextArea"]').length > 0).toBeTruthy(); + it('all params fields are rendered', async () => { + const results = render(); + + expect(results.getByTestId('issueTypeSelect')).toBeInTheDocument(); + expect((results.getByRole('option', { name: 'Bug' }) as HTMLOptionElement).selected).toBe(true); + + expect(results.getByTestId('prioritySelect')).toBeInTheDocument(); + + await waitFor(() => { + expect((results.getByRole('option', { name: 'High' }) as HTMLOptionElement).selected).toBe( + true + ); + }); + + expect(results.getByTestId('summaryInput')).toBeInTheDocument(); + expect(results.getByTestId('descriptionTextArea')).toBeInTheDocument(); + expect(results.getByTestId('labelsComboBox')).toBeInTheDocument(); + expect(results.getByTestId('commentsTextArea')).toBeInTheDocument(); }); - test('it shows loading when loading issue types', () => { + it('it shows loading when loading issue types', () => { useGetIssueTypesMock.mockReturnValue({ ...useGetIssueTypesResponse, isLoading: true }); - const wrapper = mount(); + const results = render(); - expect( - wrapper.find('[data-test-subj="issueTypeSelect"]').first().prop('isLoading') - ).toBeTruthy(); + expect(results.getByRole('progressbar')).toBeInTheDocument(); }); - test('it shows loading when loading fields', () => { + it('it shows loading when loading fields', () => { useGetFieldsByIssueTypeMock.mockReturnValue({ ...useGetFieldsByIssueTypeResponse, isLoading: true, }); - const wrapper = mount(); + const results = render(); + + const prioritySelect = within(results.getByTestId('priority-wrapper')); + const labelsComboBox = within(results.getByTestId('labels-wrapper')); - expect( - wrapper.find('[data-test-subj="prioritySelect"]').first().prop('isLoading') - ).toBeTruthy(); - expect( - wrapper.find('[data-test-subj="labelsComboBox"]').first().prop('isLoading') - ).toBeTruthy(); + expect(prioritySelect.getByRole('progressbar')).toBeInTheDocument(); + expect(labelsComboBox.getByRole('progressbar')).toBeInTheDocument(); }); - test('it disabled the fields when loading issue types', () => { + it('it disabled the fields when loading issue types', async () => { useGetIssueTypesMock.mockReturnValue({ ...useGetIssueTypesResponse, isLoading: true }); - const wrapper = mount(); + const results = render(); + const labels = within(results.getByTestId('labelsComboBox')); - expect( - wrapper.find('[data-test-subj="issueTypeSelect"]').first().prop('disabled') - ).toBeTruthy(); - expect(wrapper.find('[data-test-subj="prioritySelect"]').first().prop('disabled')).toBeTruthy(); - expect( - wrapper.find('[data-test-subj="labelsComboBox"]').first().prop('isDisabled') - ).toBeTruthy(); + expect(results.getByTestId('issueTypeSelect')).toBeDisabled(); + expect(results.getByTestId('prioritySelect')).toBeDisabled(); + expect(labels.getByTestId('comboBoxSearchInput')).toBeDisabled(); }); - test('it disabled the fields when loading fields', () => { + it('it disabled the fields when loading fields', () => { useGetFieldsByIssueTypeMock.mockReturnValue({ ...useGetFieldsByIssueTypeResponse, isLoading: true, }); - const wrapper = mount(); + const results = render(); + const labels = within(results.getByTestId('labelsComboBox')); - expect( - wrapper.find('[data-test-subj="issueTypeSelect"]').first().prop('disabled') - ).toBeTruthy(); - expect(wrapper.find('[data-test-subj="prioritySelect"]').first().prop('disabled')).toBeTruthy(); - expect( - wrapper.find('[data-test-subj="labelsComboBox"]').first().prop('isDisabled') - ).toBeTruthy(); + expect(results.getByTestId('issueTypeSelect')).toBeDisabled(); + expect(results.getByTestId('prioritySelect')).toBeDisabled(); + expect(labels.getByTestId('comboBoxSearchInput')).toBeDisabled(); }); - test('hide unsupported fields', () => { + it('hide unsupported fields', () => { useGetIssueTypesMock.mockReturnValue(useGetIssueTypesResponse); useGetFieldsByIssueTypeMock.mockReturnValue({ ...useGetFieldsByIssueTypeResponse, fields: {}, }); - const wrapper = mount(); + const results = render(); - expect(wrapper.find('[data-test-subj="issueTypeSelect"]').exists()).toBeTruthy(); - expect(wrapper.find('[data-test-subj="summaryInput"]').exists()).toBeTruthy(); - expect(wrapper.find('[data-test-subj="commentsTextArea"]').exists()).toBeTruthy(); + expect(results.getByTestId('issueTypeSelect')).toBeInTheDocument(); + expect(results.getByTestId('summaryInput')).toBeInTheDocument(); + expect(results.getByTestId('commentsTextArea')).toBeInTheDocument(); - expect(wrapper.find('[data-test-subj="prioritySelect"]').exists()).toBeFalsy(); - expect(wrapper.find('[data-test-subj="descriptionTextArea"]').exists()).toBeFalsy(); - expect(wrapper.find('[data-test-subj="labelsComboBox"]').exists()).toBeFalsy(); - expect(wrapper.find('[data-test-subj="search-parent-issues"]').exists()).toBeFalsy(); + expect(results.queryByTestId('prioritySelect')).toBeFalsy(); + expect(results.queryByTestId('descriptionTextArea')).toBeFalsy(); + expect(results.queryByTestId('labelsComboBox')).toBeFalsy(); + expect(results.queryByTestId('search-parent-issues')).toBeFalsy(); }); - test('If issue type is undefined, set to first item in issueTypes', () => { + it('If issue type is undefined, set to first item in issueTypes', () => { const newProps = { ...defaultProps, actionParams: { @@ -210,13 +229,13 @@ describe.skip('JiraParamsFields renders', () => { }, }, }; - mount(); + render(); expect(editAction.mock.calls[0][1].incident.issueType).toEqual( useGetIssueTypesResponse.issueTypes[0].id ); }); - test('If issue type is not an option in issueTypes, set to first item in issueTypes', () => { + it('If issue type is not an option in issueTypes, set to first item in issueTypes', () => { const newProps = { ...defaultProps, actionParams: { @@ -230,13 +249,13 @@ describe.skip('JiraParamsFields renders', () => { }, }, }; - mount(); + render(); expect(editAction.mock.calls[0][1].incident.issueType).toEqual( useGetIssueTypesResponse.issueTypes[0].id ); }); - test('When issueType and fields are null, return empty priority', () => { + it('When issueType and fields are null, return empty priority', () => { useGetFieldsByIssueTypeMock.mockReturnValue({ ...useGetFieldsByIssueTypeResponse, fields: null, @@ -254,19 +273,24 @@ describe.skip('JiraParamsFields renders', () => { }, }, }; - const wrapper = mount(); - expect(wrapper.find('[data-test-subj="prioritySelect"]').exists()).toEqual(false); + + const results = render(); + expect(results.queryByTestId('prioritySelect')).toBeFalsy(); }); - test('If summary has errors, form row is invalid', () => { + + it('If summary has errors, form row is invalid', () => { const newProps = { ...defaultProps, errors: { 'subActionParams.incident.summary': ['error'] }, }; - const wrapper = mount(); - const summary = wrapper.find('[data-test-subj="summary-row"]').first(); - expect(summary.prop('isInvalid')).toBeTruthy(); + + const results = render(); + const summary = within(results.getByTestId('summary-row')); + + expect(summary.getByText('error')).toBeInTheDocument(); }); - test('When subActionParams is undefined, set to default', () => { + + it('When subActionParams is undefined, set to default', () => { useGetIssueTypesMock.mockReturnValue({ ...useGetIssueTypesResponse, issueTypes: [] }); const { subActionParams, ...newParams } = actionParams; @@ -274,13 +298,15 @@ describe.skip('JiraParamsFields renders', () => { ...defaultProps, actionParams: newParams, }; - mount(); + + render(); expect(editAction.mock.calls[0][1]).toEqual({ incident: {}, comments: [], }); }); - test('When subAction is undefined, set to default', () => { + + it('When subAction is undefined, set to default', () => { useGetIssueTypesMock.mockReturnValue({ ...useGetIssueTypesResponse, issueTypes: [] }); const { subAction, ...newParams } = actionParams; @@ -288,38 +314,83 @@ describe.skip('JiraParamsFields renders', () => { ...defaultProps, actionParams: newParams, }; - mount(); - expect(editAction.mock.calls[1][1]).toEqual('pushToService'); + + render(); + expect(editAction.mock.calls[0][1]).toEqual('pushToService'); }); - test('Resets fields when connector changes', () => { - const wrapper = mount(); + + it('Resets fields when connector changes', () => { + const results = render(); + + results.rerender( + + ); + expect(editAction.mock.calls.length).toEqual(1); - wrapper.setProps({ actionConnector: { ...connector, id: '1234' } }); - expect(editAction.mock.calls.length).toEqual(2); - expect(editAction.mock.calls[1][1]).toEqual({ + expect(editAction.mock.calls[0][1]).toEqual({ incident: {}, comments: [], }); }); + describe('UI updates', () => { - const changeEvent = { target: { value: 'Bug' } } as React.ChangeEvent; - const simpleFields = [ - { dataTestSubj: 'input[data-test-subj="summaryInput"]', key: 'summary' }, - { dataTestSubj: 'textarea[data-test-subj="descriptionTextArea"]', key: 'description' }, - { dataTestSubj: '[data-test-subj="issueTypeSelect"]', key: 'issueType' }, - { dataTestSubj: '[data-test-subj="prioritySelect"]', key: 'priority' }, - ]; - - simpleFields.forEach((field) => - test(`${field.key} update triggers editAction :D`, () => { - const wrapper = mount(); - const theField = wrapper.find(field.dataTestSubj).first(); - theField.prop('onChange')!(changeEvent); - expect(editAction.mock.calls[1][1].incident[field.key]).toEqual(changeEvent.target.value); - }) - ); + it('updates summary', () => { + const results = render(); + + fireEvent.change(results.getByTestId('summaryInput'), { target: { value: 'new title' } }); + expect(editAction.mock.calls[0][1].incident.summary).toEqual('new title'); + }); + + it('updates description', () => { + const results = render(); + + fireEvent.change(results.getByTestId('descriptionTextArea'), { + target: { value: 'new desc' }, + }); - test('Parent update triggers editAction', () => { + expect(editAction.mock.calls[0][1].incident.description).toEqual('new desc'); + }); + + it('updates issue type', () => { + const results = render(); + + expect(results.getByTestId('issueTypeSelect')).toBeInTheDocument(); + expect((results.getByRole('option', { name: 'Bug' }) as HTMLOptionElement).selected).toBe( + true + ); + + act(() => { + userEvent.selectOptions( + results.getByTestId('issueTypeSelect'), + results.getByRole('option', { name: 'Task' }) + ); + }); + + expect(editAction.mock.calls[0][1].incident.issueType).toEqual('10005'); + }); + + it('updates priority', async () => { + const results = render(); + + expect(results.getByTestId('prioritySelect')).toBeInTheDocument(); + + await waitFor(() => { + expect((results.getByRole('option', { name: 'High' }) as HTMLOptionElement).selected).toBe( + true + ); + }); + + act(() => { + userEvent.selectOptions( + results.getByTestId('prioritySelect'), + results.getByRole('option', { name: 'Medium' }) + ); + }); + + expect(editAction.mock.calls[0][1].incident.priority).toEqual('Medium'); + }); + + it('updates parent', async () => { useGetFieldsByIssueTypeMock.mockReturnValue({ ...useGetFieldsByIssueTypeResponse, fields: { @@ -327,40 +398,46 @@ describe.skip('JiraParamsFields renders', () => { parent: {}, }, }); - const newProps = { - ...defaultProps, - actionParams: { - ...actionParams, - subActionParams: { - ...actionParams.subActionParams, - incident: { - ...actionParams.subActionParams.incident, - parent: '10002', - }, - }, - }, - }; - const wrapper = mount(); - const parent = wrapper.find('[data-test-subj="parent-search"]'); - - ( - parent.props() as unknown as { - onChange: (val: string) => void; - } - ).onChange('Cool'); - expect(editAction.mock.calls[1][1].incident.parent).toEqual('Cool'); + + const results = render(); + + await waitFor(() => { + expect(results.getByTestId('search-parent-issues')).toBeInTheDocument(); + }); + + const parentField = within(results.getByTestId('search-parent-issues')); + + await act(async () => { + await userEvent.type(parentField.getByTestId('comboBoxSearchInput'), 'p{enter}', { + delay: 1, + }); + }); + + await waitFor(async () => { + expect(results.getByText('parent issue')).toBeInTheDocument(); + }); + + await waitFor(() => { + expect(editAction.mock.calls[0][1].incident.parent).toEqual('1'); + }); }); - test('Label update triggers editAction', () => { - const wrapper = mount(); - const labels = wrapper.find('[data-test-subj="labelsComboBox"]'); - ( - labels.at(0).props() as unknown as { - onChange: (a: EuiComboBoxOptionOption[]) => void; - } - ).onChange([{ label: 'Cool' }]); - expect(editAction.mock.calls[1][1].incident.labels).toEqual(['Cool']); + + it('updates labels correctly', async () => { + const results = render(); + const labels = within(results.getByTestId('labelsComboBox')); + + await act(async () => { + await userEvent.type(labels.getByTestId('comboBoxSearchInput'), 'l{enter}', { + delay: 1, + }); + }); + + await waitFor(() => { + expect(editAction.mock.calls[0][1].incident.labels).toEqual(['kibana', 'l']); + }); }); - test('Label undefined update triggers editAction', () => { + + it('Label undefined update triggers editAction', async () => { const newProps = { ...defaultProps, actionParams: { @@ -374,41 +451,35 @@ describe.skip('JiraParamsFields renders', () => { }, }, }; - const wrapper = mount(); - const labels = wrapper.find('[data-test-subj="labelsComboBox"]'); - - ( - labels.at(0).props() as unknown as { - onBlur: () => void; - } - ).onBlur(); - expect(editAction.mock.calls[1][1].incident.labels).toEqual([]); - }); - test('New label creation triggers editAction', () => { - const wrapper = mount(); - const labels = wrapper.find('[data-test-subj="labelsComboBox"]'); - const searchValue = 'neato'; - ( - labels.at(0).props() as unknown as { - onCreateOption: (searchValue: string) => void; - } - ).onCreateOption(searchValue); - expect(editAction.mock.calls[1][1].incident.labels).toEqual(['kibana', searchValue]); + const results = render(); + const labels = within(results.getByTestId('labelsComboBox')); + + fireEvent.focusOut(labels.getByTestId('comboBoxSearchInput')); + + await waitFor(() => { + expect(editAction.mock.calls[0][1].incident.labels).toEqual([]); + }); }); - test('A comment triggers editAction', () => { - const wrapper = mount(); - const comments = wrapper.find('[data-test-subj="commentsTextArea"] textarea'); - expect(editAction.mock.calls[0][1].comments.length).toEqual(0); - expect(comments.simulate('change', changeEvent)); - expect(editAction.mock.calls[1][1].comments.length).toEqual(1); + + it('updates a comment ', () => { + const results = render(); + const comments = results.getByTestId('commentsTextArea'); + + fireEvent.change(comments, { + target: { value: 'new comment' }, + }); + + expect(editAction.mock.calls[0][1].comments).toEqual([ + { comment: 'new comment', commentId: '1' }, + ]); }); - test('Clears any left behind priority when issueType changes and hasPriority becomes false', () => { + it('Clears any left behind priority when issueType changes and hasPriority becomes false', async () => { useGetFieldsByIssueTypeMock .mockReturnValueOnce(useGetFieldsByIssueTypeResponse) .mockReturnValue(useGetFieldsByIssueTypeResponseNoPriority); - const wrapper = mount(); - wrapper.setProps({ + + const rerenderProps = { ...{ ...defaultProps, actionParams: { @@ -416,23 +487,42 @@ describe.skip('JiraParamsFields renders', () => { incident: { issueType: '10001' }, }, }, + }; + + const results = render(); + + expect(results.getByTestId('prioritySelect')).toBeInTheDocument(); + + await waitFor(() => { + expect((results.getByRole('option', { name: 'High' }) as HTMLOptionElement).selected).toBe( + true + ); + }); + + results.rerender(); + + await waitFor(() => { + expect(results.queryByTestId('priority-wrapper')).toBeFalsy(); + expect(editAction.mock.calls[0][1].incident.priority).toEqual(null); }); - expect(editAction.mock.calls[0][1].incident.priority).toEqual('Medium'); - expect(editAction.mock.calls[1][1].incident.priority).toEqual(null); }); - test('Preserve priority when the issue type fields are loading and hasPriority becomes stale', () => { + it('Preserve priority when the issue type fields are loading and hasPriority becomes stale', async () => { useGetFieldsByIssueTypeMock .mockReturnValueOnce(useGetFieldsByIssueTypeResponseLoading) .mockReturnValue(useGetFieldsByIssueTypeResponse); - const wrapper = mount(); + + const results = render(); expect(editAction).not.toBeCalled(); - wrapper.setProps({ ...defaultProps }); // just to force component call useGetFieldsByIssueType again + results.rerender(); - expect(editAction).toBeCalledTimes(1); - expect(editAction.mock.calls[0][1].incident.priority).toEqual('Medium'); + await waitFor(() => { + expect((results.getByRole('option', { name: 'High' }) as HTMLOptionElement).selected).toBe( + true + ); + }); }); }); }); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/jira/jira_params.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/jira/jira_params.tsx index 1987e52c187f1..5228fbcaf119f 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/jira/jira_params.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/jira/jira_params.tsx @@ -196,49 +196,153 @@ const JiraParamsFields: React.FunctionComponent + + editSubActionProperty('issueType', e.target.value)} + /> + + + {hasParent && ( + <> + + + + { + editSubActionProperty('parent', parentIssueKey); + }} + /> + + + + + + )} <> + {hasPriority && ( + <> + + + + { + editSubActionProperty('priority', e.target.value); + }} + /> + + + + + + )} 0 && + incident.summary !== undefined + } label={i18n.translate( - 'xpack.triggersActionsUI.components.builtinActionTypes.jira.urgencySelectFieldLabel', + 'xpack.triggersActionsUI.components.builtinActionTypes.jira.summaryFieldLabel', { - defaultMessage: 'Issue type', + defaultMessage: 'Summary (required)', } )} > - editSubActionProperty('issueType', e.target.value)} + - - {hasParent && ( + + {hasLabels && ( <> - + - { - editSubActionProperty('parent', parentIssueKey); + { + const newOptions = [...labelOptions, { label: searchValue }]; + editSubActionProperty( + 'labels', + newOptions.map((newOption) => newOption.label) + ); }} + onChange={(selectedOptions: Array<{ label: string }>) => { + editSubActionProperty( + 'labels', + selectedOptions.map((selectedOption) => selectedOption.label) + ); + }} + onBlur={() => { + if (!incident.labels) { + editSubActionProperty('labels', []); + } + }} + isClearable={true} + data-test-subj="labelsComboBox" + isInvalid={areLabelsInvalid} /> @@ -246,141 +350,34 @@ const JiraParamsFields: React.FunctionComponent )} - <> - {hasPriority && ( - <> - - - - { - editSubActionProperty('priority', e.target.value); - }} - /> - - - - - - )} - 0 && - incident.summary !== undefined - } - label={i18n.translate( - 'xpack.triggersActionsUI.components.builtinActionTypes.jira.summaryFieldLabel', - { - defaultMessage: 'Summary (required)', - } - )} - > - - - - {hasLabels && ( - <> - - - - { - const newOptions = [...labelOptions, { label: searchValue }]; - editSubActionProperty( - 'labels', - newOptions.map((newOption) => newOption.label) - ); - }} - onChange={(selectedOptions: Array<{ label: string }>) => { - editSubActionProperty( - 'labels', - selectedOptions.map((selectedOption) => selectedOption.label) - ); - }} - onBlur={() => { - if (!incident.labels) { - editSubActionProperty('labels', []); - } - }} - isClearable={true} - data-test-subj="labelsComboBox" - isInvalid={areLabelsInvalid} - /> - - - - - - )} - {hasDescription && ( - - )} + {hasDescription && ( 0 ? comments[0].comment : undefined} + paramsProperty={'description'} + inputTargetValue={incident.description ?? undefined} label={i18n.translate( - 'xpack.triggersActionsUI.components.builtinActionTypes.jira.commentsTextAreaFieldLabel', + 'xpack.triggersActionsUI.components.builtinActionTypes.jira.descriptionTextAreaFieldLabel', { - defaultMessage: 'Additional comments', + defaultMessage: 'Description', } )} /> - + )} + 0 ? comments[0].comment : undefined} + label={i18n.translate( + 'xpack.triggersActionsUI.components.builtinActionTypes.jira.commentsTextAreaFieldLabel', + { + defaultMessage: 'Additional comments', + } + )} + /> ); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/jira/search_issues.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/jira/search_issues.tsx index f2f3aab1c2a7b..5b10542c296e9 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/jira/search_issues.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/jira/search_issues.tsx @@ -89,7 +89,7 @@ const SearchIssuesComponent: React.FC = ({ singleSelection fullWidth placeholder={inputPlaceholder} - data-test-sub={'search-parent-issues'} + data-test-subj={'search-parent-issues'} aria-label={i18n.SEARCH_ISSUES_COMBO_BOX_ARIA_LABEL} options={options} isLoading={isLoadingIssues || isLoadingSingleIssue} From fe8ac3d6293a95cd9d2a482dc88101548249d7a3 Mon Sep 17 00:00:00 2001 From: Christos Nasikas Date: Fri, 23 Sep 2022 13:36:25 +0300 Subject: [PATCH 2/2] Fix typo --- .../components/builtin_action_types/jira/jira_params.test.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/jira/jira_params.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/jira/jira_params.test.tsx index 0df1dfb67fcc2..8a478c84b509e 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/jira/jira_params.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/jira/jira_params.test.tsx @@ -45,8 +45,8 @@ const actionParams = { const connector: ActionConnector = { secrets: {}, config: {}, - id: 'it', - actionTypeId: '.it', + id: 'test', + actionTypeId: '.test', name: 'Test', isPreconfigured: false, isDeprecated: false,