mirror of https://github.com/grafana/grafana
Schema v2: Reason about new dashboard based on UID (#98879)
* Schema v2: Reason about new dashboard based on UID * Fix test * Alerting: respect isNew dashboard for legacy and new arch * Translate untranslated strings * Unify is new checks * PanelInspectDrawer update * typo fix * on close test for panel inspect drawer * Update public/app/features/alerting/unified/PanelAlertTabContent.tsxpull/98263/head^2
parent
0003efa285
commit
8e078315f0
@ -0,0 +1,76 @@ |
||||
import { locationService } from '@grafana/runtime'; |
||||
|
||||
import { DashboardScene, DashboardSceneState } from '../scene/DashboardScene'; |
||||
import { DefaultGridLayoutManager } from '../scene/layout-default/DefaultGridLayoutManager'; |
||||
|
||||
import { onPanelInspectClose } from './PanelInspectDrawer'; |
||||
|
||||
describe('onPanelInspectClose', () => { |
||||
test('when on default home dashboard page', async () => { |
||||
locationService.push('/'); |
||||
|
||||
const { scene } = await buildTestScene({ |
||||
url: '', |
||||
slug: '', |
||||
}); |
||||
|
||||
onPanelInspectClose(scene); |
||||
expect(locationService.getLocation().pathname).toBe('/'); |
||||
}); |
||||
|
||||
test('when on custom home dashboard page with uid defined', async () => { |
||||
locationService.push('/'); |
||||
|
||||
const { scene } = await buildTestScene( |
||||
{ |
||||
url: '', |
||||
slug: '', |
||||
}, |
||||
'home-dash ' |
||||
); |
||||
|
||||
onPanelInspectClose(scene); |
||||
expect(locationService.getLocation().pathname).toBe('/'); |
||||
}); |
||||
|
||||
test('when on new dashboard page', async () => { |
||||
locationService.push('/dashboard/new'); |
||||
const { scene } = await buildTestScene( |
||||
{ |
||||
url: '', |
||||
slug: '', |
||||
}, |
||||
'' |
||||
); |
||||
|
||||
onPanelInspectClose(scene); |
||||
expect(locationService.getLocation().pathname).toBe('/dashboard/new'); |
||||
}); |
||||
|
||||
test('when on a dashboard page', async () => { |
||||
const { scene } = await buildTestScene( |
||||
{ |
||||
slug: 'dash-slug', |
||||
url: '/d/dash-uid/dash-slug', |
||||
}, |
||||
'dash-uid' |
||||
); |
||||
|
||||
onPanelInspectClose(scene); |
||||
expect(locationService.getLocation().pathname).toBe('/d/dash-uid/dash-slug'); |
||||
}); |
||||
}); |
||||
|
||||
async function buildTestScene(metaOverride?: DashboardSceneState['meta'], uid = 'dash-1') { |
||||
const scene = new DashboardScene({ |
||||
title: 'hello', |
||||
uid, |
||||
meta: { |
||||
canEdit: true, |
||||
...metaOverride, |
||||
}, |
||||
body: DefaultGridLayoutManager.fromVizPanels([]), |
||||
}); |
||||
|
||||
return { scene }; |
||||
} |
Loading…
Reference in new issue