mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
# Backport This will backport the following commits from `main` to `8.11`: - [[Cases] Fix flaky "add comment" tests. (#170400)](https://github.com/elastic/kibana/pull/170400) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Antonio","email":"antonio.coelho@elastic.co"},"sourceCommit":{"committedDate":"2023-11-06T10:45:16Z","message":"[Cases] Fix flaky \"add comment\" tests. (#170400)\n\nFixes #168505\r\nFixes #168506\r\nFixes #168507\r\nFixes #168508\r\nFixes #168509\r\n(I hope)\r\n\r\n## Summary\r\n\r\nCovered most of the logic in e2e tests.\r\n\r\nFlaky test runner:\r\n-\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/3869\r\n\r\n## Checklist\r\n\r\nDelete any items that are not applicable to this PR.\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"96a4d5b63fd2fedc94905729edf06e5df7cac2aa","branchLabelMapping":{"^v8.12.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:ResponseOps","Feature:Cases","v8.11.0","v8.12.0"],"number":170400,"url":"https://github.com/elastic/kibana/pull/170400","mergeCommit":{"message":"[Cases] Fix flaky \"add comment\" tests. (#170400)\n\nFixes #168505\r\nFixes #168506\r\nFixes #168507\r\nFixes #168508\r\nFixes #168509\r\n(I hope)\r\n\r\n## Summary\r\n\r\nCovered most of the logic in e2e tests.\r\n\r\nFlaky test runner:\r\n-\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/3869\r\n\r\n## Checklist\r\n\r\nDelete any items that are not applicable to this PR.\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"96a4d5b63fd2fedc94905729edf06e5df7cac2aa"}},"sourceBranch":"main","suggestedTargetBranches":["8.11"],"targetPullRequestStates":[{"branch":"8.11","label":"v8.11.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.12.0","labelRegex":"^v8.12.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/170400","number":170400,"mergeCommit":{"message":"[Cases] Fix flaky \"add comment\" tests. (#170400)\n\nFixes #168505\r\nFixes #168506\r\nFixes #168507\r\nFixes #168508\r\nFixes #168509\r\n(I hope)\r\n\r\n## Summary\r\n\r\nCovered most of the logic in e2e tests.\r\n\r\nFlaky test runner:\r\n-\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/3869\r\n\r\n## Checklist\r\n\r\nDelete any items that are not applicable to this PR.\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"96a4d5b63fd2fedc94905729edf06e5df7cac2aa"}}]}] BACKPORT--> Co-authored-by: Antonio <antonio.coelho@elastic.co>
This commit is contained in:
parent
4e0fc5adaf
commit
1a65a4a1e0
2 changed files with 32 additions and 35 deletions
|
@ -137,42 +137,15 @@ describe.skip('AddComment ', () => {
|
|||
|
||||
appMockRender.render(<AddComment {...addCommentProps} ref={ref} />);
|
||||
|
||||
userEvent.type(screen.getByTestId('euiMarkdownEditorTextArea'), sampleData.comment);
|
||||
userEvent.paste(await screen.findByTestId('euiMarkdownEditorTextArea'), sampleData.comment);
|
||||
|
||||
await act(async () => {
|
||||
ref.current!.addQuote(sampleQuote);
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByTestId('euiMarkdownEditorTextArea').textContent).toContain(
|
||||
`${sampleData.comment}\n\n> what a cool quote \n> with new lines \n\n`
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('should call onFocus when adding a quote', async () => {
|
||||
const ref = React.createRef<AddCommentRefObject>();
|
||||
|
||||
appMockRender.render(<AddComment {...addCommentProps} ref={ref} />);
|
||||
|
||||
ref.current!.editor!.textarea!.focus = jest.fn();
|
||||
|
||||
await act(async () => {
|
||||
ref.current!.addQuote('a comment');
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
expect(ref.current!.editor!.textarea!.focus).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
it('should NOT call onFocus on mount', async () => {
|
||||
const ref = React.createRef<AddCommentRefObject>();
|
||||
|
||||
appMockRender.render(<AddComment {...addCommentProps} ref={ref} />);
|
||||
|
||||
ref.current!.editor!.textarea!.focus = jest.fn();
|
||||
expect(ref.current!.editor!.textarea!.focus).not.toHaveBeenCalled();
|
||||
expect((await screen.findByTestId('euiMarkdownEditorTextArea')).textContent).toContain(
|
||||
`${sampleData.comment}\n\n> what a cool quote \n> with new lines \n\n`
|
||||
);
|
||||
});
|
||||
|
||||
it('it should insert a timeline', async () => {
|
||||
|
@ -191,13 +164,13 @@ describe.skip('AddComment ', () => {
|
|||
</CasesTimelineIntegrationProvider>
|
||||
);
|
||||
|
||||
act(() => {
|
||||
await act(async () => {
|
||||
attachTimeline('[title](url)');
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByTestId('euiMarkdownEditorTextArea')).toHaveTextContent('[title](url)');
|
||||
});
|
||||
expect(await screen.findByTestId('euiMarkdownEditorTextArea')).toHaveTextContent(
|
||||
'[title](url)'
|
||||
);
|
||||
});
|
||||
|
||||
describe('errors', () => {
|
||||
|
|
|
@ -33,6 +33,12 @@ export default ({ getPageObject, getService }: FtrProviderContext) => {
|
|||
const kibanaServer = getService('kibanaServer');
|
||||
const browser = getService('browser');
|
||||
|
||||
const hasFocus = async (testSubject: string) => {
|
||||
const targetElement = await testSubjects.find(testSubject);
|
||||
const activeElement = await find.activeElement();
|
||||
return (await targetElement._webElement.getId()) === (await activeElement._webElement.getId());
|
||||
};
|
||||
|
||||
describe('View case', () => {
|
||||
describe('page', () => {
|
||||
createOneCaseBeforeDeleteAllAfter(getPageObject, getService);
|
||||
|
@ -122,6 +128,11 @@ export default ({ getPageObject, getService }: FtrProviderContext) => {
|
|||
expect(await desc.getVisibleText()).equal('Description with space');
|
||||
});
|
||||
|
||||
it('comment area does not have focus on page load', async () => {
|
||||
browser.refresh();
|
||||
expect(await hasFocus('euiMarkdownEditorTextArea')).to.be(false);
|
||||
});
|
||||
|
||||
it('adds a comment to a case', async () => {
|
||||
const commentArea = await find.byCssSelector(
|
||||
'[data-test-subj="add-comment"] textarea.euiMarkdownEditorTextArea'
|
||||
|
@ -135,9 +146,22 @@ export default ({ getPageObject, getService }: FtrProviderContext) => {
|
|||
const newComment = await find.byCssSelector(
|
||||
'[data-test-subj*="comment-create-action"] [data-test-subj="scrollable-markdown"]'
|
||||
);
|
||||
|
||||
expect(await newComment.getVisibleText()).equal('Test comment from automation');
|
||||
});
|
||||
|
||||
it('quotes a comment on a case', async () => {
|
||||
const commentArea = await find.byCssSelector(
|
||||
'[data-test-subj="add-comment"] textarea.euiMarkdownEditorTextArea'
|
||||
);
|
||||
|
||||
await testSubjects.click('property-actions-user-action-ellipses');
|
||||
await testSubjects.click('property-actions-user-action-quote');
|
||||
|
||||
expect(await commentArea.getVisibleText()).equal('> Test comment from automation ');
|
||||
expect(await hasFocus('euiMarkdownEditorTextArea')).to.be(true);
|
||||
});
|
||||
|
||||
it('adds a category to a case', async () => {
|
||||
const category = uuidv4();
|
||||
await testSubjects.click('category-edit-button');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue