From 407e10abca9b69e22981aa62d0906a0e09ee5aeb Mon Sep 17 00:00:00 2001 From: Declan Lynch Date: Thu, 12 Oct 2023 17:08:20 -0400 Subject: [PATCH] Added a test for MenuViewModel.SoftwareSystemsNodes --- .../generatr/site/model/MenuViewModelTest.kt | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/test/kotlin/nl/avisi/structurizr/site/generatr/site/model/MenuViewModelTest.kt b/src/test/kotlin/nl/avisi/structurizr/site/generatr/site/model/MenuViewModelTest.kt index adc62157..094dde89 100644 --- a/src/test/kotlin/nl/avisi/structurizr/site/generatr/site/model/MenuViewModelTest.kt +++ b/src/test/kotlin/nl/avisi/structurizr/site/generatr/site/model/MenuViewModelTest.kt @@ -136,6 +136,27 @@ class MenuViewModelTest : ViewModelTest() { } } + @Test + fun `show nested groups in software systems list`() { + val generatorContext = generatorContext(branches = listOf("main", "branch-2"), currentBranch = "main") + generatorContext.workspace.views.configuration.addProperty("generatr.site.nestGroups","true") + generatorContext.workspace.model.addSoftwareSystem("System 1").group = "Group 1" + generatorContext.workspace.model.addSoftwareSystem("System 2").group = "Group 1" + generatorContext.workspace.model.addSoftwareSystem("System 3").group = "Group 2" + generatorContext.workspace.model.addSoftwareSystem("System 4").group = "Group 1/Group 3" + + MenuViewModel(generatorContext, createPageViewModel(generatorContext, url = HomePageViewModel.url())) + .let { + assertThat(it.softwareSystemNodes().children).hasSize(2) + assertThat(it.softwareSystemNodes().children[0].name).isEqualTo("Group 1") + assertThat(it.softwareSystemNodes().children[0].children).hasSize(3) + assertThat(it.softwareSystemNodes().children[0].children[0].name).isEqualTo("Group 3") + assertThat(it.softwareSystemNodes().children[0].children[0].children[0].name).isEqualTo("System 4") + } + + + } + private fun createPageViewModel(generatorContext: GeneratorContext, url: String = "/master/page"): PageViewModel { return object : PageViewModel(generatorContext) { override val url = url