mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
import { config } from '@grafana/runtime';
|
|
|
|
import { updateScopes } from './utils/actions';
|
|
import { expectDashboardReload, expectNotDashboardReload } from './utils/assertions';
|
|
import { getDatasource, getInstanceSettings, getMock } from './utils/mocks';
|
|
import { renderDashboard, resetScenes } from './utils/render';
|
|
|
|
jest.mock('@grafana/runtime', () => ({
|
|
__esModule: true,
|
|
...jest.requireActual('@grafana/runtime'),
|
|
useChromeHeaderHeight: jest.fn(),
|
|
getBackendSrv: () => ({ get: getMock }),
|
|
getDataSourceSrv: () => ({ get: getDatasource, getInstanceSettings }),
|
|
usePluginLinkExtensions: jest.fn().mockReturnValue({ extensions: [] }),
|
|
}));
|
|
|
|
describe('Dashboard reload', () => {
|
|
beforeAll(() => {
|
|
config.featureToggles.scopeFilters = true;
|
|
config.featureToggles.groupByVariable = true;
|
|
});
|
|
|
|
afterEach(async () => {
|
|
await resetScenes();
|
|
});
|
|
|
|
it('Does not reload the dashboard without UID', async () => {
|
|
renderDashboard({ uid: undefined }, { reloadOnScopesChange: true });
|
|
await updateScopes(['grafana']);
|
|
expectNotDashboardReload();
|
|
});
|
|
|
|
it('Reloads the dashboard with UID', async () => {
|
|
renderDashboard({}, { reloadOnScopesChange: true });
|
|
await updateScopes(['grafana']);
|
|
expectDashboardReload();
|
|
});
|
|
});
|