mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Cases] Fix description flaky tests (#174903)
## Summary Fixes: https://github.com/elastic/kibana/issues/174323, https://github.com/elastic/kibana/issues/174322, https://github.com/elastic/kibana/issues/174321, https://github.com/elastic/kibana/issues/164049, https://github.com/elastic/kibana/issues/164048, https://github.com/elastic/kibana/issues/164045 ### Checklist Delete any items that are not applicable to this PR. - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios ### For maintainers - [x] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
This commit is contained in:
parent
fcf59b6480
commit
6aa5ae8949
1 changed files with 29 additions and 48 deletions
|
@ -13,7 +13,7 @@ import { basicCase } from '../../containers/mock';
|
|||
|
||||
import { Description } from '.';
|
||||
import type { AppMockRenderer } from '../../common/mock';
|
||||
import { createAppMockRenderer, noUpdateCasesPermissions, TestProviders } from '../../common/mock';
|
||||
import { createAppMockRenderer, noUpdateCasesPermissions } from '../../common/mock';
|
||||
import { MAX_DESCRIPTION_LENGTH } from '../../../common/constants';
|
||||
|
||||
jest.mock('../../common/lib/kibana');
|
||||
|
@ -27,13 +27,7 @@ const defaultProps = {
|
|||
isLoadingDescription: false,
|
||||
};
|
||||
|
||||
// FLAKY: https://github.com/elastic/kibana/issues/174321
|
||||
// FLAKY: https://github.com/elastic/kibana/issues/174322
|
||||
// FLAKY: https://github.com/elastic/kibana/issues/174323
|
||||
// FLAKY: https://github.com/elastic/kibana/issues/164045
|
||||
// FLAKY: https://github.com/elastic/kibana/issues/164048
|
||||
// FLAKY: https://github.com/elastic/kibana/issues/164049
|
||||
describe.skip('Description', () => {
|
||||
describe('Description', () => {
|
||||
const onUpdateField = jest.fn();
|
||||
let appMockRender: AppMockRenderer;
|
||||
|
||||
|
@ -45,48 +39,42 @@ describe.skip('Description', () => {
|
|||
it('renders description correctly', async () => {
|
||||
appMockRender.render(<Description {...defaultProps} onUpdateField={onUpdateField} />);
|
||||
|
||||
expect(screen.getByTestId('description')).toBeInTheDocument();
|
||||
expect(screen.getByText('Security banana Issue')).toBeInTheDocument();
|
||||
expect(await screen.findByTestId('description')).toBeInTheDocument();
|
||||
expect(await screen.findByText('Security banana Issue')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('hides and shows the description correctly when collapse button clicked', async () => {
|
||||
const res = appMockRender.render(
|
||||
<Description {...defaultProps} onUpdateField={onUpdateField} />
|
||||
);
|
||||
appMockRender.render(<Description {...defaultProps} onUpdateField={onUpdateField} />);
|
||||
|
||||
userEvent.click(res.getByTestId('description-collapse-icon'));
|
||||
userEvent.click(await screen.findByTestId('description-collapse-icon'));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.queryByText('Security banana Issue')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
userEvent.click(res.getByTestId('description-collapse-icon'));
|
||||
userEvent.click(await screen.findByTestId('description-collapse-icon'));
|
||||
|
||||
expect(await screen.findByText('Security banana Issue')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows textarea on edit click', async () => {
|
||||
const res = appMockRender.render(
|
||||
<Description {...defaultProps} onUpdateField={onUpdateField} />
|
||||
);
|
||||
appMockRender.render(<Description {...defaultProps} onUpdateField={onUpdateField} />);
|
||||
|
||||
userEvent.click(res.getByTestId('description-edit-icon'));
|
||||
userEvent.click(await screen.findByTestId('description-edit-icon'));
|
||||
|
||||
expect(await screen.findByTestId('euiMarkdownEditorTextArea')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('edits the description correctly when saved', async () => {
|
||||
const editedDescription = 'New updated description';
|
||||
const res = appMockRender.render(
|
||||
<Description {...defaultProps} onUpdateField={onUpdateField} />
|
||||
);
|
||||
appMockRender.render(<Description {...defaultProps} onUpdateField={onUpdateField} />);
|
||||
|
||||
userEvent.click(res.getByTestId('description-edit-icon'));
|
||||
userEvent.click(await screen.findByTestId('description-edit-icon'));
|
||||
|
||||
userEvent.clear(screen.getByTestId('euiMarkdownEditorTextArea'));
|
||||
userEvent.paste(screen.getByTestId('euiMarkdownEditorTextArea'), editedDescription);
|
||||
userEvent.clear(await screen.findByTestId('euiMarkdownEditorTextArea'));
|
||||
userEvent.paste(await screen.findByTestId('euiMarkdownEditorTextArea'), editedDescription);
|
||||
|
||||
userEvent.click(screen.getByTestId('editable-save-markdown'));
|
||||
userEvent.click(await screen.findByTestId('editable-save-markdown'));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(onUpdateField).toHaveBeenCalledWith({
|
||||
|
@ -98,37 +86,33 @@ describe.skip('Description', () => {
|
|||
|
||||
it('keeps the old description correctly when canceled', async () => {
|
||||
const editedDescription = 'New updated description';
|
||||
const res = appMockRender.render(
|
||||
<Description {...defaultProps} onUpdateField={onUpdateField} />
|
||||
);
|
||||
appMockRender.render(<Description {...defaultProps} onUpdateField={onUpdateField} />);
|
||||
|
||||
userEvent.click(res.getByTestId('description-edit-icon'));
|
||||
userEvent.click(await screen.findByTestId('description-edit-icon'));
|
||||
|
||||
userEvent.clear(screen.getByTestId('euiMarkdownEditorTextArea'));
|
||||
userEvent.paste(screen.getByTestId('euiMarkdownEditorTextArea'), editedDescription);
|
||||
userEvent.clear(await screen.findByTestId('euiMarkdownEditorTextArea'));
|
||||
userEvent.paste(await screen.findByTestId('euiMarkdownEditorTextArea'), editedDescription);
|
||||
|
||||
expect(screen.getByText(editedDescription)).toBeInTheDocument();
|
||||
expect(await screen.findByText(editedDescription)).toBeInTheDocument();
|
||||
|
||||
userEvent.click(screen.getByTestId('editable-cancel-markdown'));
|
||||
userEvent.click(await screen.findByTestId('editable-cancel-markdown'));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(onUpdateField).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
expect(screen.getByText('Security banana Issue')).toBeInTheDocument();
|
||||
expect(await screen.findByText('Security banana Issue')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows an error when description is too long', async () => {
|
||||
const longDescription = 'a'.repeat(MAX_DESCRIPTION_LENGTH + 1);
|
||||
|
||||
const res = appMockRender.render(
|
||||
<Description {...defaultProps} onUpdateField={onUpdateField} />
|
||||
);
|
||||
appMockRender.render(<Description {...defaultProps} onUpdateField={onUpdateField} />);
|
||||
|
||||
userEvent.click(res.getByTestId('description-edit-icon'));
|
||||
userEvent.click(await screen.findByTestId('description-edit-icon'));
|
||||
|
||||
userEvent.clear(screen.getByTestId('euiMarkdownEditorTextArea'));
|
||||
userEvent.paste(screen.getByTestId('euiMarkdownEditorTextArea'), longDescription);
|
||||
userEvent.clear(await screen.findByTestId('euiMarkdownEditorTextArea'));
|
||||
userEvent.paste(await screen.findByTestId('euiMarkdownEditorTextArea'), longDescription);
|
||||
|
||||
expect(
|
||||
await screen.findByText(
|
||||
|
@ -139,14 +123,11 @@ describe.skip('Description', () => {
|
|||
expect(await screen.findByTestId('editable-save-markdown')).toHaveAttribute('disabled');
|
||||
});
|
||||
|
||||
it('should hide the edit button when the user does not have update permissions', () => {
|
||||
appMockRender.render(
|
||||
<TestProviders permissions={noUpdateCasesPermissions()}>
|
||||
<Description {...defaultProps} onUpdateField={onUpdateField} />
|
||||
</TestProviders>
|
||||
);
|
||||
it('should hide the edit button when the user does not have update permissions', async () => {
|
||||
appMockRender = createAppMockRenderer({ permissions: noUpdateCasesPermissions() });
|
||||
appMockRender.render(<Description {...defaultProps} onUpdateField={onUpdateField} />);
|
||||
|
||||
expect(screen.getByText('Security banana Issue')).toBeInTheDocument();
|
||||
expect(await screen.findByText('Security banana Issue')).toBeInTheDocument();
|
||||
expect(screen.queryByTestId('description-edit-icon')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue