feat: hydrate board label chip colors from API
This commit is contained in:
@@ -25,6 +25,7 @@ import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.viewpager2.widget.ViewPager2
|
||||
import com.google.android.material.color.MaterialColors
|
||||
import com.google.android.material.chip.Chip
|
||||
import java.text.DateFormat
|
||||
import java.util.ArrayDeque
|
||||
import java.util.Date
|
||||
@@ -148,6 +149,22 @@ class BoardDetailFlowTest {
|
||||
onView(withId(R.id.cardDueDateText)).check(matches(withCurrentTextColor(expectedColor ?: Color.BLACK)))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun invalidTagColorFallsBackToOnSurfaceColor() {
|
||||
defaultDataSource.currentDetail = detailWithInvalidTagColor()
|
||||
val scenario = launchBoardDetail()
|
||||
|
||||
var expectedColor: Int? = null
|
||||
scenario.onActivity { activity ->
|
||||
expectedColor = MaterialColors.getColor(
|
||||
activity.findViewById(android.R.id.content),
|
||||
com.google.android.material.R.attr.colorOnSurface,
|
||||
)
|
||||
}
|
||||
|
||||
onView(withText("Backend")).check(matches(withChipStrokeColor(expectedColor ?: Color.DKGRAY)))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun dueDateUsesSystemLocaleFormatting() {
|
||||
Locale.setDefault(Locale.FRANCE)
|
||||
@@ -571,6 +588,21 @@ class BoardDetailFlowTest {
|
||||
}
|
||||
}
|
||||
|
||||
private fun withChipStrokeColor(expectedColor: Int): Matcher<View> {
|
||||
return object : TypeSafeMatcher<View>() {
|
||||
override fun describeTo(description: Description) {
|
||||
description.appendText("with chip stroke color: $expectedColor")
|
||||
}
|
||||
|
||||
override fun matchesSafely(item: View): Boolean {
|
||||
if (item !is Chip) {
|
||||
return false
|
||||
}
|
||||
return item.chipStrokeColor?.defaultColor == expectedColor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun awaitCondition(timeoutMs: Long = 4_000L, condition: () -> Boolean) {
|
||||
val instrumentation = androidx.test.platform.app.InstrumentationRegistry.getInstrumentation()
|
||||
val start = System.currentTimeMillis()
|
||||
@@ -757,6 +789,25 @@ class BoardDetailFlowTest {
|
||||
)
|
||||
}
|
||||
|
||||
fun detailWithInvalidTagColor(): BoardDetail {
|
||||
return detailOneList().copy(
|
||||
lists = listOf(
|
||||
BoardListDetail(
|
||||
id = "list-1",
|
||||
title = "To Do",
|
||||
cards = listOf(
|
||||
BoardCardSummary(
|
||||
id = "card-1",
|
||||
title = "Card 1",
|
||||
tags = listOf(BoardTagSummary("tag-1", "Backend", "bad-color")),
|
||||
dueAtEpochMillis = null,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
fun detailWithCardTitle(title: String): BoardDetail {
|
||||
return detailOneList().copy(
|
||||
lists = listOf(
|
||||
|
||||
Reference in New Issue
Block a user