iamsanjay commented on code in PR #3656: URL: https://github.com/apache/solr/pull/3656#discussion_r2347950017
########## solr/ui/src/commonTest/kotlin/org/apache/solr/ui/views/configsets/ConfigsetsContentTest.kt: ########## @@ -0,0 +1,122 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.solr.ui.views.configsets + +import androidx.compose.ui.test.ExperimentalTestApi +import androidx.compose.ui.test.onNodeWithTag +import androidx.compose.ui.test.performClick +import androidx.compose.ui.test.runComposeUiTest +import com.arkivanov.decompose.Child +import com.arkivanov.decompose.router.slot.ChildSlot +import com.arkivanov.decompose.value.MutableValue +import com.arkivanov.decompose.value.Value +import kotlin.test.Ignore +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow +import org.apache.solr.ui.components.configsets.ConfigsetsComponent +import org.apache.solr.ui.components.configsets.ConfigsetsComponent.Model +import org.apache.solr.ui.components.configsets.data.Configset +import org.apache.solr.ui.components.configsets.overview.ConfigsetsOverviewComponent +import org.apache.solr.ui.components.navigation.TabNavigationComponent.Configuration +import org.apache.solr.ui.views.navigation.configsets.ConfigsetsTab + +@OptIn(ExperimentalTestApi::class) +class ConfigsetsContentTest { + + @Test + fun `GIVEN no configsets WHEN dropdown clicked THEN not expanded`() = runComposeUiTest { + val component = TestConfigsetsComponent() + + setContent { ConfigsetsContent(component = component) } + + // Field click shouldn’t open the menu (anchor is disabled in our impl) + onNodeWithTag(testTag = "configsets_dropdown").performClick() + assertFalse(actual = component.expanded) Review Comment: So I was thinking instead of testing component property as you mentioned last time should we again assert UI property only. For instance, If we add testTag to ExposedDropdownMenuBox as well, ``` onNodeWithTag(testTag = "configsets-exposed-dropdown").assertIsEnabled(); ``` ########## solr/ui/src/commonMain/kotlin/org/apache/solr/ui/views/configsets/ConfigsetsContent.kt: ########## @@ -0,0 +1,100 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.solr.ui.views.configsets + +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.ExperimentalLayoutApi +import androidx.compose.foundation.layout.FlowRow +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.collectAsState +import androidx.compose.runtime.getValue +import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.testTag +import androidx.compose.ui.unit.dp +import com.arkivanov.decompose.extensions.compose.subscribeAsState +import org.apache.solr.ui.components.configsets.ConfigsetsComponent +import org.apache.solr.ui.components.configsets.ConfigsetsComponent.Child +import org.apache.solr.ui.generated.resources.Res +import org.apache.solr.ui.generated.resources.configsets_index_query +import org.apache.solr.ui.generated.resources.configsets_request_handlers +import org.apache.solr.ui.generated.resources.configsets_search_components +import org.apache.solr.ui.generated.resources.configsets_update_configuration +import org.apache.solr.ui.generated.resources.files +import org.apache.solr.ui.generated.resources.overview +import org.apache.solr.ui.generated.resources.schema +import org.apache.solr.ui.views.navigation.NavigationTabs +import org.apache.solr.ui.views.navigation.configsets.ConfigsetsTab + +@OptIn(ExperimentalLayoutApi::class) +@Composable +fun ConfigsetsContent( + component: ConfigsetsComponent, + modifier: Modifier = Modifier, +) = FlowRow( + modifier = modifier, + horizontalArrangement = Arrangement.spacedBy(16.dp), + verticalArrangement = Arrangement.spacedBy(16.dp), +) { + val model by component.model.collectAsState() + val slot by component.tabSlot.subscribeAsState() + val currentChild = slot.child + + Column(Modifier.fillMaxSize()) { + NavigationTabs( + component = component, + entries = ConfigsetsTab.entries, + mapper = ::tabLabelRes, + ) + ConfigsetsDropdown( + modifier = Modifier.testTag("configsets_dropdown"), + selectedConfigSet = model.selectedConfigset, + selectConfigset = { s: String -> component.onSelectConfigset(s) }, + availableConfigsets = model.configsets, + expanded = model.expanded, + setMenuExpanded = component::setMenuExpanded, + ) + + Box( + Modifier + .fillMaxSize() + .padding(16.dp), + ) { + println(currentChild) Review Comment: We can remove this. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
