Skip to content

Commit

Permalink
Merge pull request #176 from tarkalabs/sheshu/feature/tui_menu_item
Browse files Browse the repository at this point in the history
TUI Menu item component created
  • Loading branch information
rajajawahar authored Jan 30, 2024
2 parents 5ecf643 + 1bd55be commit 6ea90a3
Show file tree
Hide file tree
Showing 24 changed files with 374 additions and 6 deletions.
2 changes: 1 addition & 1 deletion tarkaui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ publishing {
run {
groupId = "com.tarkalabs"
artifactId = getLibraryArtifactId()
version = "1.0.2"
version = "1.0.3"
artifact("$buildDir/outputs/aar/${getLibraryArtifactId()}-release.aar")
}
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.tarkalabs.uicomponents

import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.ui.Modifier
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import com.tarkalabs.tarkaicons.AddCircle24
import com.tarkalabs.tarkaicons.TarkaIcons.Regular
import com.tarkalabs.uicomponents.components.TUIMenuItem
import com.tarkalabs.uicomponents.components.TUIMenuItemTags
import org.junit.Rule
import org.junit.Test
import org.mockito.kotlin.mock
import org.mockito.kotlin.verify

class TUIMenuItemTest {

@get:Rule val composeTestRule = createComposeRule()
val tags = TUIMenuItemTags()

@Test fun menu_Item_Displayed() {
composeTestRule.setContent {
TUIMenuItem(
label = "Label",
onMenuItemClick = {},
isSelected = true,
modifier = Modifier.fillMaxWidth(),
leadingIcon = Regular.AddCircle24,
trailingIcon = Regular.AddCircle24,
tags = tags
)
}
composeTestRule.onNodeWithTag(tags.parentTag,useUnmergedTree = true).assertIsDisplayed()
composeTestRule.onNodeWithTag(tags.leadingContentTag,useUnmergedTree = true).assertIsDisplayed()
composeTestRule.onNodeWithTag(tags.trailingContentTag,useUnmergedTree = true).assertIsDisplayed()
composeTestRule.onNodeWithText("Label",useUnmergedTree = true).assertIsDisplayed()
}

@Test fun button_Click_Triggered() {
val onMenuItemClick: () -> Unit = mock()

composeTestRule.setContent {
TUIMenuItem(
label = "Label",
onMenuItemClick = onMenuItemClick,
isSelected = true,
modifier = Modifier.fillMaxWidth(),
leadingIcon = Regular.AddCircle24,
trailingIcon = Regular.AddCircle24,
tags = tags
)
}
composeTestRule.onNodeWithTag(tags.parentTag,useUnmergedTree = true).performClick()

verify(onMenuItemClick).invoke()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ class TUIMultiLevelSelectorHeaderTest {
TUIMultiLevelSelectorHeader(
modifier = Modifier.fillMaxWidth(),
isSelected = true,
leadingIcon = Filled.ApprovalsApp24.copy(contentDescription = "leadingIcon"),
trailingIcon = Filled.ApprovalsApp24.copy(contentDescription = "trailingIcon"),
title = "Hello There",
tags = tags
) {}
Expand All @@ -48,8 +46,6 @@ class TUIMultiLevelSelectorHeaderTest {
TUIMultiLevelSelectorHeader(
modifier = Modifier.fillMaxWidth(),
isSelected = true,
leadingIcon = Filled.ApprovalsApp24,
trailingIcon = Filled.ApprovalsApp24,
title = "Hello There",
tags = tags,
onClick = onClick
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package com.tarkalabs.uicomponents.screenshots

import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.ui.Modifier
import com.tarkalabs.tarkaicons.Checkmark24
import com.tarkalabs.tarkaicons.Circle24
import com.tarkalabs.tarkaicons.TarkaIcons.Regular
import com.tarkalabs.uicomponents.components.TUIMenuItem
import com.tarkalabs.uicomponents.components.TUIMenuItemIconStyle
import com.tarkalabs.uicomponents.components.TUIMenuItemIconStyle.SUCCESS
import com.tarkalabs.uicomponents.components.TUIMenuItemTags
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized

@RunWith(Parameterized::class)
class TUIMenuItemScreenShotTest(
private val leadingIconStyle: TUIMenuItemIconStyle,
private val isSelected: Boolean,
private val darkTheme: Boolean,
private val testName: String,
) : ComposeScreenshotComparator() {

companion object {

@JvmStatic
@Parameterized.Parameters
fun data(): Collection<Array<Any?>> {
val leadingIconStyleValues = listOf(TUIMenuItemIconStyle.NORMAL, SUCCESS)
val isSelectedValues = listOf(true, false)
val darkThemeValues = listOf(true, false)

val testData = ArrayList<Array<Any?>>()

for (style in leadingIconStyleValues) {
for (selectedValue in isSelectedValues) {
for (darkThemeValue in darkThemeValues) {
val testName =
"LeadingIconStyle_${style}_isSelected_${selectedValue}_darkTheme_${darkThemeValue}"
testData.add(
arrayOf(
style, selectedValue, darkThemeValue, testName
)
)
}
}
}
return testData
}
}

@Test
fun testTuiMenuItem() {
compareScreenshotFor(darkTheme, testName) {
TUIMenuItem(
modifier = Modifier,
label = "Label",
isSelected = isSelected,
onMenuItemClick = { /*TODO*/ },
leadingIconStyle = leadingIconStyle,
leadingIcon = if (leadingIconStyle == SUCCESS) Regular.Checkmark24 else null
)
}
}

@Test
fun testTuiMenuItem_Failure_With_Leading_Icon_Cirlce() {
compareScreenshotFor(
darkTheme,
"Custom_LeadingIconStyle_Failure_isSelected_false_darkTheme_${darkTheme}"
) {
TUIMenuItem(
modifier = Modifier.fillMaxWidth(),
label = "Label",
isSelected = false,
leadingIcon = Regular.Circle24,
trailingIcon = Regular.Circle24,
onMenuItemClick = {},
tags = TUIMenuItemTags(parentTag = "hello")
)
}
}
}
Loading

0 comments on commit 6ea90a3

Please sign in to comment.