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
-39
View File
@@ -7,45 +7,6 @@ import (
)
func TestNavTreeRoot(t *testing.T) {
t.Run("Should remove empty admin and server admin sections", func(t *testing.T) {
treeRoot := NavTreeRoot{
Children: []*NavLink{
{Id: NavIDCfg},
{Id: NavIDAdmin},
},
}
treeRoot.RemoveEmptySectionsAndApplyNewInformationArchitecture()
require.Equal(t, 0, len(treeRoot.Children))
})
t.Run("Should create 3 new sections in the Admin node", func(t *testing.T) {
treeRoot := NavTreeRoot{
Children: []*NavLink{
{Id: NavIDCfg},
{Id: NavIDAdmin, Children: []*NavLink{{Id: "upgrading"}, {Id: "plugins"}, {Id: "teams"}}},
},
}
treeRoot.RemoveEmptySectionsAndApplyNewInformationArchitecture()
require.Equal(t, "Administration", treeRoot.Children[0].Text)
})
t.Run("Should move reports into Dashboards", func(t *testing.T) {
treeRoot := NavTreeRoot{
Children: []*NavLink{
{Id: NavIDDashboards},
{Id: NavIDReporting},
},
}
treeRoot.RemoveEmptySectionsAndApplyNewInformationArchitecture()
require.Equal(t, NavIDReporting, treeRoot.Children[0].Children[0].Id)
})
t.Run("Sorting by index", func(t *testing.T) {
treeRoot := NavTreeRoot{
Children: []*NavLink{