mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 01:53:33 -06:00
* Change nav structure when topnav is enable to do initial tests with new information architecture * Support for nested sections * Updated * sentance case * Progress on plugin challange * Rewrite to functional component * Progress * Updates * Progress * Progress on things * missing file * Fixing issue with runtime, need to use setter way to set component exposed via runtime * Move PageLayoutType to grafana/data * Fixing breadcrumb issue, adding more tests * reverted backend change * fix recursive issue with cleanup
53 lines
1.4 KiB
TypeScript
53 lines
1.4 KiB
TypeScript
import { Location as HistoryLocation } from 'history';
|
|
|
|
import { config } from '@grafana/runtime';
|
|
|
|
import { buildPluginSectionNav } from './utils';
|
|
|
|
describe('buildPluginSectionNav', () => {
|
|
const pluginNav = { main: { text: 'Plugin nav' }, node: { text: 'Plugin nav' } };
|
|
const appsSection = {
|
|
text: 'apps',
|
|
id: 'apps',
|
|
children: [
|
|
{
|
|
text: 'App1',
|
|
children: [
|
|
{
|
|
text: 'page1',
|
|
url: '/a/plugin1/page1',
|
|
},
|
|
{
|
|
text: 'page2',
|
|
url: '/a/plugin1/page2',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
};
|
|
const navIndex = { apps: appsSection };
|
|
|
|
it('Should return pluginNav if topnav is disabled', () => {
|
|
config.featureToggles.topnav = false;
|
|
const result = buildPluginSectionNav({} as HistoryLocation, pluginNav, {});
|
|
expect(result).toBe(pluginNav);
|
|
});
|
|
|
|
it('Should return return section nav if topnav is enabled', () => {
|
|
config.featureToggles.topnav = true;
|
|
const result = buildPluginSectionNav({} as HistoryLocation, pluginNav, navIndex);
|
|
expect(result?.main.text).toBe('apps');
|
|
});
|
|
|
|
it('Should set active page', () => {
|
|
config.featureToggles.topnav = true;
|
|
const result = buildPluginSectionNav(
|
|
{ pathname: '/a/plugin1/page2', search: '' } as HistoryLocation,
|
|
null,
|
|
navIndex
|
|
);
|
|
expect(result?.main.children![0].children![1].active).toBe(true);
|
|
expect(result?.node.text).toBe('page2');
|
|
});
|
|
});
|