Chore: fix flakey frontend test (#48071)

* remove unnecessary rerender

* removed unused act import
pull/47403/head
Ashley Harrison 3 years ago committed by GitHub
parent 94d2155f44
commit 9595b56f0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      public/app/features/variables/inspect/VariablesUnknownTable.test.tsx

@ -1,6 +1,6 @@
import React from 'react';
import * as runtime from '@grafana/runtime';
import { act, render, screen, waitFor } from '@testing-library/react';
import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { VariablesUnknownTable, VariablesUnknownTableProps } from './VariablesUnknownTable';
@ -107,19 +107,12 @@ describe('VariablesUnknownTable', () => {
it('then it should report slow expansion', async () => {
const variable = customBuilder().withId('Renamed Variable').withName('Renamed Variable').build();
const usages = [{ variable, nodes: [], edges: [], showGraph: false }];
const { reportInteractionSpy, rerender } = await getTestContext({}, usages);
const { reportInteractionSpy } = await getTestContext({}, usages);
const dateNowStart = 1000;
const dateNowStop = 2000;
Date.now = jest.fn().mockReturnValueOnce(dateNowStart).mockReturnValue(dateNowStop);
await userEvent.click(screen.getByRole('heading', { name: /renamed or missing variables/i }));
const props: VariablesUnknownTableProps = {
variables: [],
dashboard: null,
};
await act(async () => {
rerender(<VariablesUnknownTable {...props} />);
});
// make sure we report the interaction for slow expansion
await waitFor(() => expect(reportInteractionSpy).toHaveBeenCalledTimes(2));

Loading…
Cancel
Save