From 5788341560697baa341b7d85cb37bf6ecbf2cfbe Mon Sep 17 00:00:00 2001 From: AnirudhBhat Date: Tue, 20 Aug 2024 14:55:44 +0530 Subject: [PATCH 01/16] Mock blaze GET request so that our UI tests will run fine. --- .../mappings/woopos/blaze_campaigns.json | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 WooCommerce/src/androidTest/assets/mocks/mappings/woopos/blaze_campaigns.json diff --git a/WooCommerce/src/androidTest/assets/mocks/mappings/woopos/blaze_campaigns.json b/WooCommerce/src/androidTest/assets/mocks/mappings/woopos/blaze_campaigns.json new file mode 100644 index 00000000000..06f92efbd65 --- /dev/null +++ b/WooCommerce/src/androidTest/assets/mocks/mappings/woopos/blaze_campaigns.json @@ -0,0 +1,30 @@ +{ + "request": { + "method": "GET", + "urlPathPattern": "/rest/v1.1/jetpack-blogs/161477129/rest-api/", + "queryParameters": { + "path": { + "equalTo": "/wc/gla/ads/campaigns/&_method=get" + }, + "json": { + "equalTo": "true" + }, + "locale": { + "matches": "(.*)" + } + } + }, + "response": { + "status": 200, + "jsonBody": { + "total_items": 0, + "campaigns": [], + "total_pages": 0, + "page": 1 + }, + "headers": { + "Content-Type": "application/json", + "Connection": "keep-alive" + } + } +} From 0433badbe5256c6a552a2520589cf5caccb8eec9 Mon Sep 17 00:00:00 2001 From: AnirudhBhat Date: Tue, 20 Aug 2024 14:56:56 +0530 Subject: [PATCH 02/16] Add POSModeScreen --- .../woocommerce/android/e2e/screens/pos/POSModeScreen.kt | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 WooCommerce/src/androidTest/kotlin/com/woocommerce/android/e2e/screens/pos/POSModeScreen.kt diff --git a/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/e2e/screens/pos/POSModeScreen.kt b/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/e2e/screens/pos/POSModeScreen.kt new file mode 100644 index 00000000000..8ae2e2308b1 --- /dev/null +++ b/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/e2e/screens/pos/POSModeScreen.kt @@ -0,0 +1,8 @@ +package com.woocommerce.android.e2e.screens.pos + +import com.woocommerce.android.R +import com.woocommerce.android.e2e.helpers.util.Screen + +class POSModeScreen : Screen(R.id.pos_mode_compose_view) { + +} From 71c04c0b0254f190ecf26656f130998b0d32cb6a Mon Sep 17 00:00:00 2001 From: AnirudhBhat Date: Tue, 20 Aug 2024 14:57:36 +0530 Subject: [PATCH 03/16] Add function to open POS mode in more menu UI screen --- .../android/e2e/screens/moremenu/MoreMenuScreen.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/e2e/screens/moremenu/MoreMenuScreen.kt b/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/e2e/screens/moremenu/MoreMenuScreen.kt index 63bc0e844c0..77f306dbafa 100644 --- a/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/e2e/screens/moremenu/MoreMenuScreen.kt +++ b/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/e2e/screens/moremenu/MoreMenuScreen.kt @@ -10,6 +10,7 @@ import androidx.compose.ui.test.performScrollTo import com.woocommerce.android.R import com.woocommerce.android.e2e.helpers.util.Screen import com.woocommerce.android.e2e.screens.mystore.settings.SettingsScreen +import com.woocommerce.android.e2e.screens.pos.POSModeScreen import com.woocommerce.android.e2e.screens.reviews.ReviewsListScreen class MoreMenuScreen : Screen(R.id.more_menu_compose_view) { @@ -22,6 +23,15 @@ class MoreMenuScreen : Screen(R.id.more_menu_compose_view) { return ReviewsListScreen() } + fun openPOSScreen(composeTestRule: ComposeTestRule): POSModeScreen { + composeTestRule.onNodeWithText( + getTranslatedString(R.string.more_menu_button_payments) + ) + .performScrollTo() + .performClick() + return POSModeScreen() + } + fun openSettings(composeTestRule: ComposeTestRule): SettingsScreen { // Tests are failing randomly here depending on how fast this screen is displayed after tapping on the More button // Adding this retry to wait for the settings icon to be displayed, retrying up to a max time From 4316da24b5ee8842eaa396a7aca7ac6d6c9064e0 Mon Sep 17 00:00:00 2001 From: AnirudhBhat Date: Tue, 20 Aug 2024 14:58:23 +0530 Subject: [PATCH 04/16] Trigger POS event when clicked on payments settings - This is temporary and will be fixed in future iterations to trigger POS event when clicked on POS settings instead of payments menu. --- .../com/woocommerce/android/ui/moremenu/MoreMenuViewModel.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/moremenu/MoreMenuViewModel.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/moremenu/MoreMenuViewModel.kt index 35bfae9885e..c997117de2d 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/moremenu/MoreMenuViewModel.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/moremenu/MoreMenuViewModel.kt @@ -321,7 +321,8 @@ class MoreMenuViewModel @Inject constructor( mapOf(VALUE_MORE_MENU_PAYMENTS_BADGE_VISIBLE to isPaymentBadgeVisible().toString()) ) moreMenuNewFeatureHandler.markPaymentsIconAsClicked() - triggerEvent(MoreMenuEvent.ViewPayments) +// triggerEvent(MoreMenuEvent.ViewPayments) + triggerEvent(MoreMenuEvent.NavigateToWooPosEvent) } private fun onPromoteProductsWithGoogle() { From eded8b32083fe5c13ac2e9ba2dbf186c8f7fad63 Mon Sep 17 00:00:00 2001 From: AnirudhBhat Date: Tue, 20 Aug 2024 14:59:35 +0530 Subject: [PATCH 05/16] Add ID to WooPosActivity so that it can be references in the UI screens --- .../android/ui/woopos/root/WooPosActivity.kt | 10 +++++++++- WooCommerce/src/main/res/values/ids.xml | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/root/WooPosActivity.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/root/WooPosActivity.kt index f3fc2f540f9..93deb4bfc6a 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/root/WooPosActivity.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/root/WooPosActivity.kt @@ -13,6 +13,8 @@ import androidx.compose.runtime.SideEffect import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalView import androidx.compose.ui.unit.dp +import androidx.compose.ui.graphics.toArgb +import androidx.compose.ui.platform.ComposeView import androidx.core.view.WindowCompat import androidx.core.view.WindowInsetsCompat import com.woocommerce.android.ui.woopos.cardreader.WooPosCardReaderFacade @@ -37,7 +39,13 @@ class WooPosActivity : AppCompatActivity() { lifecycle.addObserver(wooPosCardReaderFacade) lifecycle.addObserver(wooPosGetSupportFacade) - setContent { + val composeView = ComposeView(this).apply { + id = com.woocommerce.android.R.id.pos_mode_compose_view + } + + setContentView(composeView) + + composeView.setContent { WooPosTheme { SystemBars() diff --git a/WooCommerce/src/main/res/values/ids.xml b/WooCommerce/src/main/res/values/ids.xml index 6e29705c2cd..19127c588fd 100644 --- a/WooCommerce/src/main/res/values/ids.xml +++ b/WooCommerce/src/main/res/values/ids.xml @@ -3,6 +3,7 @@ + From 1a7a0b7f61d47eaea1a09598225c4b0266643c96 Mon Sep 17 00:00:00 2001 From: AnirudhBhat Date: Tue, 20 Aug 2024 15:01:22 +0530 Subject: [PATCH 06/16] Add test tag for WooPosBanner so that we can reference this in UI test --- .../android/ui/woopos/home/products/WooPosBanner.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/products/WooPosBanner.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/products/WooPosBanner.kt index 6a231555148..cc266d6b62b 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/products/WooPosBanner.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/products/WooPosBanner.kt @@ -17,8 +17,11 @@ import androidx.compose.material.icons.filled.Close import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.testTag import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource +import androidx.compose.ui.semantics.contentDescription +import androidx.compose.ui.semantics.semantics import androidx.compose.ui.text.SpanStyle import androidx.compose.ui.text.buildAnnotatedString import androidx.compose.ui.text.font.FontWeight @@ -48,6 +51,8 @@ fun WooPosBanner( end = 2.dp.toAdaptivePadding(), bottom = 16.dp.toAdaptivePadding() ) + .testTag("woo_pos_simple_products_banner") + ) { Card( shape = RoundedCornerShape(8.dp), From acf27acca632e0c4b832365f29a9e205a6696bc0 Mon Sep 17 00:00:00 2001 From: AnirudhBhat Date: Tue, 20 Aug 2024 17:30:13 +0530 Subject: [PATCH 07/16] Add test tag in WooPosProductsScreen --- .../android/ui/woopos/home/products/WooPosProductsScreen.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/products/WooPosProductsScreen.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/products/WooPosProductsScreen.kt index ca34bf7208a..5ffff112188 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/products/WooPosProductsScreen.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/products/WooPosProductsScreen.kt @@ -48,6 +48,7 @@ import androidx.compose.ui.graphics.painter.ColorPainter import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.testTag import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.vectorResource @@ -248,6 +249,7 @@ private fun ProductsList( ) { val listState = rememberLazyListState() WooPosLazyColumn( + modifier = Modifier.testTag("product_list"), verticalArrangement = Arrangement.spacedBy(8.dp), contentPadding = PaddingValues(2.dp), state = listState, From c2c6cf0d1b467a59d7f4e44448a04cca3d41a2a4 Mon Sep 17 00:00:00 2001 From: AnirudhBhat Date: Tue, 20 Aug 2024 17:30:17 +0530 Subject: [PATCH 08/16] Add test to verify simple products only banner is displayed when products screen is visited --- .../woocommerce/android/WooPosBannerTest.kt | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 WooCommerce/src/androidTest/kotlin/com/woocommerce/android/WooPosBannerTest.kt diff --git a/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/WooPosBannerTest.kt b/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/WooPosBannerTest.kt new file mode 100644 index 00000000000..ab13d40ed47 --- /dev/null +++ b/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/WooPosBannerTest.kt @@ -0,0 +1,85 @@ +@file:Suppress("DEPRECATION") + +package com.woocommerce.android + +import androidx.activity.ComponentActivity +import androidx.compose.ui.test.assertIsDisplayed +import androidx.compose.ui.test.junit4.createAndroidComposeRule +import androidx.compose.ui.test.onNodeWithTag +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.Preferences +import androidx.datastore.preferences.core.edit +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.rule.ActivityTestRule +import com.woocommerce.android.e2e.helpers.InitializationRule +import com.woocommerce.android.e2e.helpers.TestBase +import com.woocommerce.android.e2e.rules.RetryTestRule +import com.woocommerce.android.e2e.screens.TabNavComponent +import com.woocommerce.android.e2e.screens.login.WelcomeScreen +import com.woocommerce.android.ui.login.LoginActivity +import dagger.hilt.android.testing.HiltAndroidRule +import dagger.hilt.android.testing.HiltAndroidTest +import kotlinx.coroutines.test.runTest +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith +import javax.inject.Inject + +@HiltAndroidTest +@RunWith(AndroidJUnit4::class) +class WooPosBannerTest : TestBase() { + @get:Rule(order = 1) + val rule = HiltAndroidRule(this) + + @get:Rule(order = 2) + val composeTestRule = createAndroidComposeRule() + + @get:Rule(order = 3) + val initRule = InitializationRule() + + @get:Rule(order = 4) + var activityRule = ActivityTestRule(LoginActivity::class.java) + + @get:Rule(order = 5) + var retryTestRule = RetryTestRule() + + @Inject + lateinit var dataStore: DataStore + + @Before + fun setUp() = runTest { + rule.inject() + WelcomeScreen + .skipCarouselIfNeeded() + .selectLogin() + .proceedWith(BuildConfig.SCREENSHOTS_URL) + .proceedWith(BuildConfig.SCREENSHOTS_USERNAME) + .proceedWith(BuildConfig.SCREENSHOTS_PASSWORD) + + TabNavComponent() + .gotoMoreMenuScreen() + .openPOSScreen(composeTestRule) + dataStore.edit { it.clear() } + } + + @Test + fun testWooPosBannerIsDisplayedOnProductsScreen() = runTest { + + composeTestRule.waitUntil(5000) { + try { + composeTestRule.onNodeWithTag("product_list") + .assertExists() + .assertIsDisplayed() + true + } catch (e: AssertionError) { + false + } + } + + composeTestRule.onNodeWithTag( + "woo_pos_simple_products_banner" + ).assertIsDisplayed() + } + +} From d0ba4b269b0898f4dc188062e7bff84f25196814 Mon Sep 17 00:00:00 2001 From: AnirudhBhat Date: Wed, 21 Aug 2024 17:20:49 +0530 Subject: [PATCH 09/16] Add UI test to verify that simple products banner title is displayed as expected. --- .../woocommerce/android/WooPosBannerTest.kt | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/WooPosBannerTest.kt b/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/WooPosBannerTest.kt index ab13d40ed47..75ca459bcbd 100644 --- a/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/WooPosBannerTest.kt +++ b/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/WooPosBannerTest.kt @@ -6,6 +6,7 @@ import androidx.activity.ComponentActivity import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.junit4.createAndroidComposeRule import androidx.compose.ui.test.onNodeWithTag +import androidx.compose.ui.test.onNodeWithText import androidx.datastore.core.DataStore import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.edit @@ -64,7 +65,7 @@ class WooPosBannerTest : TestBase() { } @Test - fun testWooPosBannerIsDisplayedOnProductsScreen() = runTest { + fun testWooPosSimpleProductsOnlyBannerIsDisplayedOnProductsScreen() = runTest { composeTestRule.waitUntil(5000) { try { @@ -82,4 +83,23 @@ class WooPosBannerTest : TestBase() { ).assertIsDisplayed() } + @Test + fun testWooPosSimpleProductsOnlyBannerTitleIsDisplayedOnBanner() = runTest { + + composeTestRule.waitUntil(5000) { + try { + composeTestRule.onNodeWithTag("product_list") + .assertExists() + .assertIsDisplayed() + true + } catch (e: AssertionError) { + false + } + } + + composeTestRule.onNodeWithText( + composeTestRule.activity.getString(R.string.woopos_banner_simple_products_only_title) + ).assertIsDisplayed() + } + } From 644a87f9d8b21c35466067c5a21bceb51fa6139f Mon Sep 17 00:00:00 2001 From: AnirudhBhat Date: Wed, 21 Aug 2024 17:21:17 +0530 Subject: [PATCH 10/16] Add UI test to verify that simple products banner message is displayed as expected. --- .../woocommerce/android/WooPosBannerTest.kt | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/WooPosBannerTest.kt b/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/WooPosBannerTest.kt index 75ca459bcbd..a2242ef4e7a 100644 --- a/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/WooPosBannerTest.kt +++ b/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/WooPosBannerTest.kt @@ -102,4 +102,25 @@ class WooPosBannerTest : TestBase() { ).assertIsDisplayed() } + @Test + fun testWooPosSimpleProductsOnlyBannerMessageIsDisplayedOnBanner() = runTest { + + composeTestRule.waitUntil(5000) { + try { + composeTestRule.onNodeWithTag("product_list") + .assertExists() + .assertIsDisplayed() + true + } catch (e: AssertionError) { + false + } + } + + composeTestRule.onNodeWithText( + composeTestRule.activity.getString(R.string.woopos_banner_simple_products_only_message) + + " " + + composeTestRule.activity.getString(R.string.woopos_banner_simple_products_only_message_learn_more) + ).assertIsDisplayed() + } + } From 54b81f44c819c4a4b9659615f5732dd7e03269ef Mon Sep 17 00:00:00 2001 From: AnirudhBhat Date: Wed, 21 Aug 2024 17:21:58 +0530 Subject: [PATCH 11/16] Add UI test to verify that simple products banner opens simple products info dialog when clicked on learn more button. --- .../woocommerce/android/WooPosBannerTest.kt | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/WooPosBannerTest.kt b/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/WooPosBannerTest.kt index a2242ef4e7a..db7f559b015 100644 --- a/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/WooPosBannerTest.kt +++ b/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/WooPosBannerTest.kt @@ -7,6 +7,7 @@ import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.junit4.createAndroidComposeRule import androidx.compose.ui.test.onNodeWithTag import androidx.compose.ui.test.onNodeWithText +import androidx.compose.ui.test.performClick import androidx.datastore.core.DataStore import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.edit @@ -123,4 +124,28 @@ class WooPosBannerTest : TestBase() { ).assertIsDisplayed() } + @Test + fun testWooPosSimpleProductsOnlyBannerOpensProductInfoDialogWhenClickedOnLearnMore() = runTest { + + composeTestRule.waitUntil(5000) { + try { + composeTestRule.onNodeWithTag("product_list") + .assertExists() + .assertIsDisplayed() + true + } catch (e: AssertionError) { + false + } + } + + composeTestRule.onNodeWithText( + composeTestRule.activity.getString(R.string.woopos_banner_simple_products_only_message) + + " " + + composeTestRule.activity.getString(R.string.woopos_banner_simple_products_only_message_learn_more) + ).performClick() + + composeTestRule.onNodeWithTag("woo_pos_product_info_dialog") + .assertIsDisplayed() + } + } From 7a75fd7c4b7f0eb6fe10bd026addcaa2e31211be Mon Sep 17 00:00:00 2001 From: AnirudhBhat Date: Wed, 21 Aug 2024 17:22:54 +0530 Subject: [PATCH 12/16] Add UI test to verify that simple products banner is dismissed when close icon is clicked. --- .../woocommerce/android/WooPosBannerTest.kt | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/WooPosBannerTest.kt b/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/WooPosBannerTest.kt index db7f559b015..360708e2397 100644 --- a/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/WooPosBannerTest.kt +++ b/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/WooPosBannerTest.kt @@ -4,7 +4,9 @@ package com.woocommerce.android import androidx.activity.ComponentActivity import androidx.compose.ui.test.assertIsDisplayed +import androidx.compose.ui.test.assertIsNotDisplayed import androidx.compose.ui.test.junit4.createAndroidComposeRule +import androidx.compose.ui.test.onNodeWithContentDescription import androidx.compose.ui.test.onNodeWithTag import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick @@ -148,4 +150,27 @@ class WooPosBannerTest : TestBase() { .assertIsDisplayed() } + @Test + fun testWooPosSimpleProductsOnlyBannerIsDismissedWhenClosed() = runTest { + + composeTestRule.waitUntil(5000) { + try { + composeTestRule.onNodeWithTag("product_list") + .assertExists() + .assertIsDisplayed() + true + } catch (e: AssertionError) { + false + } + } + + composeTestRule.onNodeWithContentDescription( + composeTestRule.activity.getString(R.string.woopos_banner_simple_products_close_content_description) + ).performClick() + + composeTestRule.onNodeWithTag( + "woo_pos_simple_products_banner" + ).assertIsNotDisplayed() + } + } From 0c2e310bab8c23d523ffeedca8d3b94037f9ac93 Mon Sep 17 00:00:00 2001 From: AnirudhBhat Date: Wed, 21 Aug 2024 18:04:20 +0530 Subject: [PATCH 13/16] Add test tag for Simple products info dialog so that we can reference it in our UI tests --- .../android/ui/woopos/home/WooPosHomeProductInfoDialog.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/WooPosHomeProductInfoDialog.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/WooPosHomeProductInfoDialog.kt index 7e74d2f84d9..8b94df6f0aa 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/WooPosHomeProductInfoDialog.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/WooPosHomeProductInfoDialog.kt @@ -34,6 +34,7 @@ import androidx.compose.runtime.snapshotFlow import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip +import androidx.compose.ui.platform.testTag import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.FontWeight @@ -76,6 +77,7 @@ fun WooPosProductInfoDialog( Box( modifier = Modifier .fillMaxSize() + .testTag("woo_pos_product_info_dialog") .padding( start = 100.dp.toAdaptivePadding(), end = 100.dp.toAdaptivePadding(), From 9a5034ab67826174197b3c049a5176e8804e8775 Mon Sep 17 00:00:00 2001 From: AnirudhBhat Date: Wed, 21 Aug 2024 18:05:16 +0530 Subject: [PATCH 14/16] Combine testing simple products banner's message and title into one test so that the UI tests won't take much time to run --- .../com/woocommerce/android/WooPosBannerTest.kt | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/WooPosBannerTest.kt b/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/WooPosBannerTest.kt index 360708e2397..519c781bd03 100644 --- a/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/WooPosBannerTest.kt +++ b/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/WooPosBannerTest.kt @@ -87,7 +87,7 @@ class WooPosBannerTest : TestBase() { } @Test - fun testWooPosSimpleProductsOnlyBannerTitleIsDisplayedOnBanner() = runTest { + fun testWooPosSimpleProductsOnlyBannerTitleAndMessageIsDisplayedOnBanner() = runTest { composeTestRule.waitUntil(5000) { try { @@ -103,21 +103,6 @@ class WooPosBannerTest : TestBase() { composeTestRule.onNodeWithText( composeTestRule.activity.getString(R.string.woopos_banner_simple_products_only_title) ).assertIsDisplayed() - } - - @Test - fun testWooPosSimpleProductsOnlyBannerMessageIsDisplayedOnBanner() = runTest { - - composeTestRule.waitUntil(5000) { - try { - composeTestRule.onNodeWithTag("product_list") - .assertExists() - .assertIsDisplayed() - true - } catch (e: AssertionError) { - false - } - } composeTestRule.onNodeWithText( composeTestRule.activity.getString(R.string.woopos_banner_simple_products_only_message) From 8a37125fbba2ae252e6cb156d78b48176849310c Mon Sep 17 00:00:00 2001 From: AnirudhBhat Date: Wed, 21 Aug 2024 18:26:24 +0530 Subject: [PATCH 15/16] Fix detekt errors --- .../woocommerce/android/WooPosBannerTest.kt | 29 +++++++++---------- .../android/e2e/screens/pos/POSModeScreen.kt | 4 +-- .../ui/woopos/home/products/WooPosBanner.kt | 1 - .../android/ui/woopos/root/WooPosActivity.kt | 3 +- 4 files changed, 16 insertions(+), 21 deletions(-) diff --git a/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/WooPosBannerTest.kt b/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/WooPosBannerTest.kt index 519c781bd03..00eb75b7949 100644 --- a/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/WooPosBannerTest.kt +++ b/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/WooPosBannerTest.kt @@ -68,8 +68,7 @@ class WooPosBannerTest : TestBase() { } @Test - fun testWooPosSimpleProductsOnlyBannerIsDisplayedOnProductsScreen() = runTest { - + fun testWooPosSimpleProductsOnlyBannerIsDisplayedOnProductsScreen() = runTest { composeTestRule.waitUntil(5000) { try { composeTestRule.onNodeWithTag("product_list") @@ -77,6 +76,7 @@ class WooPosBannerTest : TestBase() { .assertIsDisplayed() true } catch (e: AssertionError) { + e.printStackTrace() false } } @@ -87,8 +87,7 @@ class WooPosBannerTest : TestBase() { } @Test - fun testWooPosSimpleProductsOnlyBannerTitleAndMessageIsDisplayedOnBanner() = runTest { - + fun testWooPosSimpleProductsOnlyBannerTitleAndMessageIsDisplayedOnBanner() = runTest { composeTestRule.waitUntil(5000) { try { composeTestRule.onNodeWithTag("product_list") @@ -96,6 +95,7 @@ class WooPosBannerTest : TestBase() { .assertIsDisplayed() true } catch (e: AssertionError) { + e.printStackTrace() false } } @@ -105,15 +105,14 @@ class WooPosBannerTest : TestBase() { ).assertIsDisplayed() composeTestRule.onNodeWithText( - composeTestRule.activity.getString(R.string.woopos_banner_simple_products_only_message) - + " " - + composeTestRule.activity.getString(R.string.woopos_banner_simple_products_only_message_learn_more) + composeTestRule.activity.getString(R.string.woopos_banner_simple_products_only_message) + + " " + + composeTestRule.activity.getString(R.string.woopos_banner_simple_products_only_message_learn_more) ).assertIsDisplayed() } @Test - fun testWooPosSimpleProductsOnlyBannerOpensProductInfoDialogWhenClickedOnLearnMore() = runTest { - + fun testWooPosSimpleProductsOnlyBannerOpensProductInfoDialogWhenClickedOnLearnMore() = runTest { composeTestRule.waitUntil(5000) { try { composeTestRule.onNodeWithTag("product_list") @@ -121,14 +120,15 @@ class WooPosBannerTest : TestBase() { .assertIsDisplayed() true } catch (e: AssertionError) { + e.printStackTrace() false } } composeTestRule.onNodeWithText( - composeTestRule.activity.getString(R.string.woopos_banner_simple_products_only_message) - + " " - + composeTestRule.activity.getString(R.string.woopos_banner_simple_products_only_message_learn_more) + composeTestRule.activity.getString(R.string.woopos_banner_simple_products_only_message) + + " " + + composeTestRule.activity.getString(R.string.woopos_banner_simple_products_only_message_learn_more) ).performClick() composeTestRule.onNodeWithTag("woo_pos_product_info_dialog") @@ -136,8 +136,7 @@ class WooPosBannerTest : TestBase() { } @Test - fun testWooPosSimpleProductsOnlyBannerIsDismissedWhenClosed() = runTest { - + fun testWooPosSimpleProductsOnlyBannerIsDismissedWhenClosed() = runTest { composeTestRule.waitUntil(5000) { try { composeTestRule.onNodeWithTag("product_list") @@ -145,6 +144,7 @@ class WooPosBannerTest : TestBase() { .assertIsDisplayed() true } catch (e: AssertionError) { + e.printStackTrace() false } } @@ -157,5 +157,4 @@ class WooPosBannerTest : TestBase() { "woo_pos_simple_products_banner" ).assertIsNotDisplayed() } - } diff --git a/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/e2e/screens/pos/POSModeScreen.kt b/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/e2e/screens/pos/POSModeScreen.kt index 8ae2e2308b1..9cc03c8ec25 100644 --- a/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/e2e/screens/pos/POSModeScreen.kt +++ b/WooCommerce/src/androidTest/kotlin/com/woocommerce/android/e2e/screens/pos/POSModeScreen.kt @@ -3,6 +3,4 @@ package com.woocommerce.android.e2e.screens.pos import com.woocommerce.android.R import com.woocommerce.android.e2e.helpers.util.Screen -class POSModeScreen : Screen(R.id.pos_mode_compose_view) { - -} +class POSModeScreen : Screen(R.id.pos_mode_compose_view) diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/products/WooPosBanner.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/products/WooPosBanner.kt index cc266d6b62b..9b9b69d4834 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/products/WooPosBanner.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/products/WooPosBanner.kt @@ -21,7 +21,6 @@ import androidx.compose.ui.platform.testTag import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.semantics.contentDescription -import androidx.compose.ui.semantics.semantics import androidx.compose.ui.text.SpanStyle import androidx.compose.ui.text.buildAnnotatedString import androidx.compose.ui.text.font.FontWeight diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/root/WooPosActivity.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/root/WooPosActivity.kt index 93deb4bfc6a..f65db6d5bb1 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/root/WooPosActivity.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/root/WooPosActivity.kt @@ -11,10 +11,9 @@ import androidx.compose.foundation.layout.padding import androidx.compose.runtime.Composable import androidx.compose.runtime.SideEffect import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.ComposeView import androidx.compose.ui.platform.LocalView import androidx.compose.ui.unit.dp -import androidx.compose.ui.graphics.toArgb -import androidx.compose.ui.platform.ComposeView import androidx.core.view.WindowCompat import androidx.core.view.WindowInsetsCompat import com.woocommerce.android.ui.woopos.cardreader.WooPosCardReaderFacade From 71f491ad82508c0f1608ba996bfaacb5aca798e4 Mon Sep 17 00:00:00 2001 From: AnirudhBhat Date: Wed, 21 Aug 2024 18:27:19 +0530 Subject: [PATCH 16/16] Remove unused imports --- .../woocommerce/android/ui/woopos/home/products/WooPosBanner.kt | 1 - .../com/woocommerce/android/ui/woopos/root/WooPosActivity.kt | 1 - 2 files changed, 2 deletions(-) diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/products/WooPosBanner.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/products/WooPosBanner.kt index 9b9b69d4834..1df2ec29eb5 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/products/WooPosBanner.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/products/WooPosBanner.kt @@ -20,7 +20,6 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.platform.testTag import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource -import androidx.compose.ui.semantics.contentDescription import androidx.compose.ui.text.SpanStyle import androidx.compose.ui.text.buildAnnotatedString import androidx.compose.ui.text.font.FontWeight diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/root/WooPosActivity.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/root/WooPosActivity.kt index f65db6d5bb1..fb1ed7609cd 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/root/WooPosActivity.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/root/WooPosActivity.kt @@ -4,7 +4,6 @@ import android.content.Context import android.content.pm.ActivityInfo import android.os.Bundle import android.util.TypedValue -import androidx.activity.compose.setContent import androidx.appcompat.app.AppCompatActivity import androidx.compose.foundation.layout.navigationBarsPadding import androidx.compose.foundation.layout.padding