Skip to content

Commit

Permalink
Added Compose UI Tests for home screen. (kasem-sm#139)
Browse files Browse the repository at this point in the history
Co-authored-by: kasem-sm <kasem-sm@github.com>
  • Loading branch information
kasem-sm and kasem-sm authored May 25, 2022
1 parent fee1ed9 commit 3a7a0a3
Show file tree
Hide file tree
Showing 11 changed files with 298 additions and 72 deletions.
40 changes: 20 additions & 20 deletions docs/modules/module_graph
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@ digraph {
":core" [fillcolor="#ffb3ba"];
":database" [fillcolor="#baffc9"];
":features:article:common-article-ui" [fillcolor="#baffc9"];
":features:article:daily-read-worker" [fillcolor="#baffc9"];
":features:article:datasource-api" [fillcolor="#ffb3ba"];
":features:article:datasource-impl" [fillcolor="#ffb3ba"];
":features:article:domain:interactors" [fillcolor="#ffb3ba"];
":features:article:domain:model" [fillcolor="#ffb3ba"];
":features:article:dynamic-links-handler" [fillcolor="#baffc9"];
":features:article:markdown" [fillcolor="#baffc9"];
":features:article:widget" [fillcolor="#baffc9"];
":features:article:worker" [fillcolor="#baffc9"];
":features:authentication:auth-verify-worker" [fillcolor="#baffc9"];
":features:authentication:datasource-api" [fillcolor="#ffb3ba"];
":features:authentication:datasource-impl" [fillcolor="#ffb3ba"];
":features:authentication:domain:interactors" [fillcolor="#ffb3ba"];
":features:authentication:domain:model" [fillcolor="#ffb3ba"];
":features:authentication:worker" [fillcolor="#baffc9"];
":features:topic:datasource-api" [fillcolor="#ffb3ba"];
":features:topic:datasource-impl" [fillcolor="#ffb3ba"];
":features:topic:domain:interactors" [fillcolor="#ffb3ba"];
":features:topic:domain:model" [fillcolor="#ffb3ba"];
":features:topic:worker" [fillcolor="#baffc9"];
":features:topic:subscription-manager-worker" [fillcolor="#baffc9"];
":screen:core" [fillcolor="#baffc9"];
":screen:ui-article-detail" [fillcolor="#baffc9"];
":screen:ui-article-list" [fillcolor="#baffc9"];
Expand Down Expand Up @@ -82,9 +82,9 @@ digraph {
":task-impl" -> ":task-impl"
":task-impl" -> ":core" [style=dotted]
":task-impl" -> ":task-api" [style=dotted]
":task-impl" -> ":features:authentication:worker" [style=dotted]
":task-impl" -> ":features:topic:worker" [style=dotted]
":task-impl" -> ":features:article:worker" [style=dotted]
":task-impl" -> ":features:authentication:auth-verify-worker" [style=dotted]
":task-impl" -> ":features:topic:subscription-manager-worker" [style=dotted]
":task-impl" -> ":features:article:daily-read-worker" [style=dotted]
":screen:core" -> ":screen:core"
":screen:ui-article-detail" -> ":screen:ui-article-detail"
":screen:ui-article-detail" -> ":core" [style=dotted]
Expand Down Expand Up @@ -154,35 +154,35 @@ digraph {
":screen:ui-subscribe-topic" -> ":auth-api" [style=dotted]
":screen:ui-subscribe-topic" -> ":features:topic:domain:interactors" [style=dotted]
":screen:ui-subscribe-topic" -> ":features:topic:domain:model" [style=dotted]
":screen:ui-subscribe-topic" -> ":features:topic:worker" [style=dotted]
":screen:ui-subscribe-topic" -> ":features:topic:subscription-manager-worker" [style=dotted]
":features:article:common-article-ui" -> ":features:article:common-article-ui"
":features:article:common-article-ui" -> ":common-ui" [style=dotted]
":features:article:common-article-ui" -> ":features:article:domain:model" [style=dotted]
":features:article:daily-read-worker" -> ":features:article:daily-read-worker"
":features:article:daily-read-worker" -> ":core" [style=dotted]
":features:article:daily-read-worker" -> ":features:article:datasource-api" [style=dotted]
":features:article:daily-read-worker" -> ":features:article:widget" [style=dotted]
":features:article:daily-read-worker" -> ":features:article:domain:model" [style=dotted]
":features:article:datasource-impl" -> ":core" [style=dotted]
":features:article:datasource-impl" -> ":auth-api" [style=dotted]
":features:article:datasource-impl" -> ":features:article:datasource-api" [style=dotted]
":features:article:dynamic-links-handler" -> ":features:article:dynamic-links-handler"
":features:article:markdown" -> ":features:article:markdown"
":features:article:widget" -> ":features:article:widget"
":features:article:worker" -> ":features:article:worker"
":features:article:worker" -> ":core" [style=dotted]
":features:article:worker" -> ":features:article:datasource-api" [style=dotted]
":features:article:worker" -> ":features:article:widget" [style=dotted]
":features:article:worker" -> ":features:article:domain:model" [style=dotted]
":features:authentication:auth-verify-worker" -> ":features:authentication:auth-verify-worker"
":features:authentication:auth-verify-worker" -> ":core" [style=dotted]
":features:authentication:auth-verify-worker" -> ":auth-api" [style=dotted]
":features:authentication:auth-verify-worker" -> ":features:authentication:datasource-api" [style=dotted]
":features:authentication:datasource-impl" -> ":core" [style=dotted]
":features:authentication:datasource-impl" -> ":auth-api" [style=dotted]
":features:authentication:datasource-impl" -> ":features:authentication:datasource-api" [style=dotted]
":features:authentication:worker" -> ":features:authentication:worker"
":features:authentication:worker" -> ":core" [style=dotted]
":features:authentication:worker" -> ":auth-api" [style=dotted]
":features:authentication:worker" -> ":features:authentication:datasource-api" [style=dotted]
":features:topic:datasource-impl" -> ":core" [style=dotted]
":features:topic:datasource-impl" -> ":auth-api" [style=dotted]
":features:topic:datasource-impl" -> ":features:topic:datasource-api" [style=dotted]
":features:topic:worker" -> ":features:topic:worker"
":features:topic:worker" -> ":core" [style=dotted]
":features:topic:worker" -> ":features:topic:datasource-api" [style=dotted]
":features:topic:worker" -> ":features:topic:domain:model" [style=dotted]
":features:topic:subscription-manager-worker" -> ":features:topic:subscription-manager-worker"
":features:topic:subscription-manager-worker" -> ":core" [style=dotted]
":features:topic:subscription-manager-worker" -> ":features:topic:datasource-api" [style=dotted]
":features:topic:subscription-manager-worker" -> ":features:topic:domain:model" [style=dotted]
":features:article:domain:interactors" -> ":core" [style=dotted]
":features:article:domain:interactors" -> ":features:article:datasource-api" [style=dotted]
":features:article:domain:interactors" -> ":features:article:domain:model" [style=dotted]
Expand Down
Binary file modified docs/modules/module_graph.png
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
Expand Up @@ -27,6 +27,8 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTag
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
Expand All @@ -47,17 +49,18 @@ fun ArticleCard(
onBookmarkClick: (Int) -> Unit
) {
SlimeCard(
modifier = modifier
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 2.dp)
.height(120.dp)
.clip(RoundedCornerShape(12.dp))
.clickWithRipple {
onArticleClick(article.id)
}
.then(modifier)
) {
Row(
modifier = modifier
modifier = Modifier
.wrapContentSize(),
) {
Column(
Expand Down Expand Up @@ -116,7 +119,8 @@ fun ArticleCard(
modifier = Modifier
.clickWithRipple {
onBookmarkClick(article.id)
},
}
.semantics { testTag = if (isBookmarked) "article_isBookmarked" else "article_isNotBookmarked" },
isBookmarked = isBookmarked
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import androidx.annotation.RequiresApi
import androidx.core.app.NotificationCompat
import dagger.hilt.android.qualifiers.ApplicationContext
import javax.inject.Inject
import kasem.sm.article.worker.R
import kasem.sm.article.daily_read_worker.R

class NotificationManager @Inject constructor(
@ApplicationContext private val context: Context
Expand Down
45 changes: 0 additions & 45 deletions screen/ui-auth/src/androidTest/java/kasem/sm/ui_auth/Capture.kt

This file was deleted.

7 changes: 7 additions & 0 deletions screen/ui-home/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ apply {
from("$rootDir/gradle/ui.gradle")
}

android {
defaultConfig {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
}

provideUiTestDeps(this)
dependencies {
implementation(project(":features:article:common-article-ui"))
// Article feature
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (C) 2022, Kasem S.M
* All rights reserved.
*/
package kasem.sm.ui_home

import android.annotation.SuppressLint
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext
import coil.ImageLoader

@SuppressLint("ComposableNaming")
@Composable
fun homeContentForTest(
state: HomeState,
onRefresh: () -> Unit = {},
onQueryChange: (String) -> Unit = {},
onTopicChange: (String) -> Unit = {},
onArticleClick: (Int) -> Unit = {},
navigateToSubscriptionScreen: () -> Unit = {},
onBookmarkClick: (Int) -> Unit = {},
listState: LazyListState = rememberLazyListState(),
) {
HomeContent(
state = state,
imageLoader = ImageLoader(LocalContext.current),
onRefresh = onRefresh,
onQueryChange = onQueryChange,
onTopicChange = onTopicChange,
onArticleClick = onArticleClick,
navigateToSubscriptionScreen = navigateToSubscriptionScreen,
onBookmarkClick = onBookmarkClick,
listState = listState
)
}
Loading

0 comments on commit 3a7a0a3

Please sign in to comment.