Navigation: refactor RemoveEmptySection... logic into main navtree code (#66878)
refactor RemoveEmptySection logic into main navtree code
This commit is contained in:
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user