Navigation: refactor RemoveEmptySection... logic into main navtree code (#66878)

refactor RemoveEmptySection logic into main navtree code
This commit is contained in:
Ashley Harrison
2023-04-20 11:10:12 +01:00
committed by GitHub
parent 739c7f1c68
commit 9ff221098d
6 changed files with 73 additions and 190 deletions
@@ -178,19 +178,19 @@ func TestAddAppLinks(t *testing.T) {
// This can be done by using `[navigation.app_sections]` in the INI config
t.Run("Should move apps that have specific nav id configured to correct section", func(t *testing.T) {
service.navigationAppConfig = map[string]NavigationAppConfig{
"test-app1": {SectionID: navtree.NavIDAdmin},
"test-app1": {SectionID: navtree.NavIDCfg},
}
treeRoot := navtree.NavTreeRoot{}
treeRoot.AddSection(&navtree.NavLink{
Id: navtree.NavIDAdmin,
Id: navtree.NavIDCfg,
})
err := service.addAppLinks(&treeRoot, reqCtx)
require.NoError(t, err)
// Check if the plugin gets moved over to the "Admin" section
adminNode := treeRoot.FindById(navtree.NavIDAdmin)
adminNode := treeRoot.FindById(navtree.NavIDCfg)
require.NotNil(t, adminNode)
require.Len(t, adminNode.Children, 1)
require.Equal(t, "plugin-page-test-app1", adminNode.Children[0].Id)