mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: fix flakey frontend test (#48071)
* remove unnecessary rerender * removed unused act import
This commit is contained in:
parent
94d2155f44
commit
9595b56f0d
@ -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…
Reference in New Issue
Block a user