[Cases] [104961] Remove conditional preventing additional comment field to be blank (#117901)

* Remove conditional preventing additional comment field to be blank

* Remove tests for unwanted feature

* Update server to prevent empty string comments

* PR fix

Co-authored-by: Kristof-Pierre Cummings <kristofpierre.cummings@elastic.co>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Kristof C 2021-11-22 16:20:17 -06:00 committed by GitHub
parent 51f7986242
commit 782f152713
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 9 additions and 54 deletions

View file

@ -80,6 +80,9 @@ const pushToServiceHandler = async ({
if (comments && Array.isArray(comments) && comments.length > 0) {
res.comments = [];
for (const currentComment of comments) {
if (!currentComment.comment) {
continue;
}
const comment = await externalService.createComment({
incidentId: res.id,
comment: currentComment,

View file

@ -400,14 +400,7 @@ describe('JiraParamsFields renders', () => {
expect(comments.simulate('change', changeEvent));
expect(editAction.mock.calls[1][1].comments.length).toEqual(1);
});
test('An empty comment does not trigger editAction', () => {
const wrapper = mount(<JiraParamsFields {...defaultProps} />);
const emptyComment = { target: { value: '' } };
const comments = wrapper.find('[data-test-subj="commentsTextArea"] textarea');
expect(editAction.mock.calls[0][1].comments.length).toEqual(0);
expect(comments.simulate('change', emptyComment));
expect(editAction.mock.calls.length).toEqual(1);
});
test('Clears any left behind priority when issueType changes and hasPriority becomes false', () => {
useGetFieldsByIssueTypeMock
.mockReturnValueOnce(useGetFieldsByIssueTypeResponse)

View file

@ -94,9 +94,7 @@ const JiraParamsFields: React.FunctionComponent<ActionParamsProps<JiraActionPara
);
const editComment = useCallback(
(key, value) => {
if (value.length > 0) {
editSubActionProperty(key, [{ commentId: '1', comment: value }]);
}
editSubActionProperty(key, [{ commentId: '1', comment: value }]);
},
[editSubActionProperty]
);

View file

@ -223,12 +223,5 @@ describe('ResilientParamsFields renders', () => {
expect(comments.simulate('change', changeEvent));
expect(editAction.mock.calls[0][1].comments.length).toEqual(1);
});
test('An empty comment does not trigger editAction', () => {
const wrapper = mount(<ResilientParamsFields {...defaultProps} />);
const emptyComment = { target: { value: '' } };
const comments = wrapper.find('[data-test-subj="commentsTextArea"] textarea');
expect(comments.simulate('change', emptyComment));
expect(editAction.mock.calls.length).toEqual(0);
});
});
});

View file

@ -108,9 +108,7 @@ const ResilientParamsFields: React.FunctionComponent<ActionParamsProps<Resilient
);
const editComment = useCallback(
(key, value) => {
if (value.length > 0) {
editSubActionProperty(key, [{ commentId: '1', comment: value }]);
}
editSubActionProperty(key, [{ commentId: '1', comment: value }]);
},
[editSubActionProperty]
);

View file

@ -259,13 +259,5 @@ describe('ServiceNowITSMParamsFields renders', () => {
expect(comments.simulate('change', changeEvent));
expect(editAction.mock.calls[0][1].comments.length).toEqual(1);
});
test('An empty comment does not trigger editAction', () => {
const wrapper = mountWithIntl(<ServiceNowITSMParamsFields {...defaultProps} />);
const emptyComment = { target: { value: '' } };
const comments = wrapper.find('[data-test-subj="commentsTextArea"] textarea');
expect(comments.simulate('change', emptyComment));
expect(editAction.mock.calls.length).toEqual(0);
});
});
});

View file

@ -75,9 +75,7 @@ const ServiceNowParamsFields: React.FunctionComponent<
const editComment = useCallback(
(key, value) => {
if (value.length > 0) {
editSubActionProperty(key, [{ commentId: '1', comment: value }]);
}
editSubActionProperty(key, [{ commentId: '1', comment: value }]);
},
[editSubActionProperty]
);

View file

@ -306,13 +306,5 @@ describe('ServiceNowSIRParamsFields renders', () => {
expect(comments.simulate('change', changeEvent));
expect(editAction.mock.calls[0][1].comments.length).toEqual(1);
});
test('An empty comment does not trigger editAction', () => {
const wrapper = mountWithIntl(<ServiceNowSIRParamsFields {...defaultProps} />);
const emptyComment = { target: { value: '' } };
const comments = wrapper.find('[data-test-subj="commentsTextArea"] textarea');
expect(comments.simulate('change', emptyComment));
expect(editAction.mock.calls.length).toEqual(0);
});
});
});

View file

@ -72,9 +72,7 @@ const ServiceNowSIRParamsFields: React.FunctionComponent<
const editComment = useCallback(
(key, value) => {
if (value.length > 0) {
editSubActionProperty(key, [{ commentId: '1', comment: value }]);
}
editSubActionProperty(key, [{ commentId: '1', comment: value }]);
},
[editSubActionProperty]
);

View file

@ -125,13 +125,5 @@ describe('SwimlaneParamsFields renders', () => {
expect(comments.simulate('change', changeEvent));
expect(editAction.mock.calls[0][1].comments.length).toEqual(1);
});
test('An empty comment does not trigger editAction', () => {
const wrapper = mountWithIntl(<SwimlaneParamsFields {...defaultProps} />);
const emptyComment = { target: { value: '' } };
const comments = wrapper.find('[data-test-subj="commentsTextArea"] textarea');
expect(comments.simulate('change', emptyComment));
expect(editAction.mock.calls.length).toEqual(0);
});
});
});

View file

@ -77,9 +77,7 @@ const SwimlaneParamsFields: React.FunctionComponent<ActionParamsProps<SwimlaneAc
const editComment = useCallback(
(key, value) => {
if (value.length > 0) {
editSubActionProperty(key, [{ commentId: '1', comment: value }]);
}
editSubActionProperty(key, [{ commentId: '1', comment: value }]);
},
[editSubActionProperty]
);