Skip to content

Commit

Permalink
[EuiLink] Update test icon assertion to account for the fact the icon…
Browse files Browse the repository at this point in the history
… no longer has text

- text is now entirely SR only
  • Loading branch information
cee-chen committed Oct 9, 2024
1 parent 3bf6b59 commit a03923d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import React from 'react';

import { DEFAULT_DASHBOARD_DRILLDOWN_OPTIONS } from '@kbn/presentation-util-plugin/public';
import { createEvent, fireEvent, render, screen, within } from '@testing-library/react';
import { createEvent, fireEvent, render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import { LINKS_VERTICAL_LAYOUT } from '../../../common/content_management';
Expand Down Expand Up @@ -75,7 +75,7 @@ describe('Dashboard link component', () => {
expect(link).toHaveTextContent('Dashboard 1');

// does not render external link icon
const externalIcon = within(link).queryByText('External link');
const externalIcon = link.querySelector('[data-euiicon-type="popout"]');
expect(externalIcon).toBeNull();

// calls `navigate` on click
Expand Down Expand Up @@ -122,8 +122,8 @@ describe('Dashboard link component', () => {
const link = screen.getByTestId('dashboardLink--foo');
expect(link).toBeInTheDocument();
// external link icon is rendered
const externalIcon = within(link).getByText('External link');
expect(externalIcon?.getAttribute('data-euiicon-type')).toBe('popout');
const externalIcon = link.querySelector('[data-euiicon-type="popout"]');
expect(externalIcon).toBeInTheDocument();

// calls `window.open`
await userEvent.click(link);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import React from 'react';

import userEvent from '@testing-library/user-event';
import { createEvent, fireEvent, render, screen, within } from '@testing-library/react';
import { createEvent, fireEvent, render, screen } from '@testing-library/react';
import { LINKS_VERTICAL_LAYOUT } from '../../../common/content_management';
import { ExternalLinkComponent } from './external_link_component';
import { coreServices } from '../../services/kibana_services';
Expand Down Expand Up @@ -39,8 +39,8 @@ describe('external link component', () => {

const link = await screen.findByTestId('externalLink--foo');
expect(link).toBeInTheDocument();
const externalIcon = within(link).getByText('External link');
expect(externalIcon.getAttribute('data-euiicon-type')).toBe('popout');
const externalIcon = link.querySelector('[data-euiicon-type="popout"]');
expect(externalIcon).toBeInTheDocument();
await userEvent.click(link);
expect(window.open).toHaveBeenCalledWith('https://example.com', '_blank');
});
Expand All @@ -52,8 +52,8 @@ describe('external link component', () => {
};
render(<ExternalLinkComponent link={linkInfo} layout={LINKS_VERTICAL_LAYOUT} />);
const link = await screen.findByTestId('externalLink--foo');
const externalIcon = within(link).getByText('External link');
expect(externalIcon?.getAttribute('data-euiicon-type')).toBe('popout');
const externalIcon = link.querySelector('[data-euiicon-type="popout"]');
expect(externalIcon).toBeInTheDocument();
});

test('modified click does not trigger event.preventDefault', async () => {
Expand Down

0 comments on commit a03923d

Please sign in to comment.