Skip to content

Commit

Permalink
[ResponseOps][Cases] Fixed link flaky tests (#200732)
Browse files Browse the repository at this point in the history
Closes #196189
Closes #193209

## Summary

These are simple components and the `<TestProviders>` were not necessary
in the tests. Removing them made the tests faster locally so that might
help.
  • Loading branch information
adcoelho authored Nov 20, 2024
1 parent 68909a8 commit be8f93d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
30 changes: 11 additions & 19 deletions x-pack/plugins/cases/public/components/links/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import userEvent from '@testing-library/user-event';

import type { ConfigureCaseButtonProps, CaseDetailsLinkProps } from '.';
import { ConfigureCaseButton, CaseDetailsLink } from '.';
import { TestProviders } from '../../common/mock';
import { useCaseViewNavigation } from '../../common/navigation/hooks';

jest.mock('../../common/navigation/hooks');

// FLAKY: https://github.com/elastic/kibana/issues/196189
describe.skip('Configuration button', () => {
const useCaseViewNavigationMock = useCaseViewNavigation as jest.Mock;

describe('Configuration button', () => {
const props: ConfigureCaseButtonProps = {
label: 'My label',
msgTooltip: <></>,
Expand All @@ -26,11 +26,7 @@ describe.skip('Configuration button', () => {
};

it('renders without the tooltip', async () => {
render(
<TestProviders>
<ConfigureCaseButton {...props} />
</TestProviders>
);
render(<ConfigureCaseButton {...props} />);

const configureButton = await screen.findByTestId('configure-case-button');

Expand All @@ -39,8 +35,7 @@ describe.skip('Configuration button', () => {
expect(configureButton).toHaveAttribute('aria-label', 'My label');
});

// Flaky: https://github.com/elastic/kibana/issues/193209
it.skip('renders the tooltip correctly when hovering the button', async () => {
it('renders the tooltip correctly when hovering the button', async () => {
jest.useFakeTimers();

const user = userEvent.setup({
Expand All @@ -49,14 +44,12 @@ describe.skip('Configuration button', () => {
});

render(
<TestProviders>
<ConfigureCaseButton
{...props}
showToolTip={true}
titleTooltip={'My title'}
msgTooltip={<>{'My message tooltip'}</>}
/>
</TestProviders>
<ConfigureCaseButton
{...props}
showToolTip={true}
titleTooltip={'My title'}
msgTooltip={<>{'My message tooltip'}</>}
/>
);

await user.hover(await screen.findByTestId('configure-case-button'));
Expand All @@ -70,7 +63,6 @@ describe.skip('Configuration button', () => {
});

describe('CaseDetailsLink', () => {
const useCaseViewNavigationMock = useCaseViewNavigation as jest.Mock;
const getCaseViewUrl = jest.fn().mockReturnValue('/cases/test');
const navigateToCaseView = jest.fn();

Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/cases/public/components/links/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import type { EuiButtonProps, EuiLinkProps, PropsForAnchor, PropsForButton } from '@elastic/eui';
import { EuiButton, EuiLink, EuiToolTip, EuiButtonEmpty } from '@elastic/eui';
import React, { useCallback, useMemo } from 'react';
import { useCaseViewNavigation, useConfigureCasesNavigation } from '../../common/navigation';
import { useCaseViewNavigation, useConfigureCasesNavigation } from '../../common/navigation/hooks';
import * as i18n from './translations';

export interface CasesNavigation<T = React.MouseEvent | MouseEvent | null, K = null> {
Expand Down

0 comments on commit be8f93d

Please sign in to comment.