message: write test for capturing rank prop
diff: */
  import React from 'react';
  -import { renderInTestApp } from '@backstage/test-utils';
  +import {
  + MockAnalyticsApi,
  + renderInTestApp,
  + TestApiProvider,
  +} from '@backstage/test-utils';
  +import userEvent from '@testing-library/user-event';
  import { screen } from '@testing-library/react';
  import { StackOverflowSearchResultListItem } from './StackOverflowSearchResultListItem';
  +import { analyticsApiRef } from '@backstage/core-plugin-api';
  describe('<StackOverflowSearchResultListItem/>', () => {
  it('should render without exploding', async () => {
  @@ -40,4 +46,36 @@ describe('<StackOverflowSearchResultListItem/>', () => {
  screen.getByText(/Customizing Spotify backstage UI/i).closest('a'),
  ).toHaveAttribute('href', 'https://stackoverflow.com/questions/7');
  });
  +
  + it('should capture analytics for rank', async () => {
  + const analyticsSpy = new MockAnalyticsApi();
  +
  + await renderInTestApp(
  + <TestApiProvider apis={[[analyticsApiRef, analyticsSpy]]}>
  + <StackOverflowSearchResultListItem
  + result={{
  + title: 'Customizing Spotify backstage UI',
  + text: 'Name of Author',
  + location: 'https://stackoverflow.com/questions/7',
  + answers: 0,
  + tags: ['backstage'],
  + }}
  + rank={1}
  + />
  + ,
  + </TestApiProvider>,
  + );
  +
  + await userEvent.click(
  + screen.getByText(/Customizing Spotify backstage UI/i),
  + );
  +
  + expect(analyticsSpy.getEvents()[0]).toMatchObject({
  + action: 'discover',
  + attributes: { to: 'https://stackoverflow.com/questions/7' },
  + context: { extension: 'App', pluginId: 'root', routeRef: 'unknown' },
  + subject: 'Customizing Spotify backstage UI',
  + value: 1,
  + });
  + });
  });
  