-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WOO POS] UI tests for Simple products banner in Products screen #12428
Draft
AnirudhBhat
wants to merge
17
commits into
trunk
Choose a base branch
from
issue/12377-ui-tests-for-simple-products-banner
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
5788341
Mock blaze GET request so that our UI tests will run fine.
AnirudhBhat 0433bad
Add POSModeScreen
AnirudhBhat 71c04c0
Add function to open POS mode in more menu UI screen
AnirudhBhat 4316da2
Trigger POS event when clicked on payments settings - This is tempora…
AnirudhBhat eded8b3
Add ID to WooPosActivity so that it can be references in the UI screens
AnirudhBhat 1a7a0b7
Add test tag for WooPosBanner so that we can reference this in UI test
AnirudhBhat acf27ac
Add test tag in WooPosProductsScreen
AnirudhBhat c2c6cf0
Add test to verify simple products only banner is displayed when prod…
AnirudhBhat d0ba4b2
Add UI test to verify that simple products banner title is displayed …
AnirudhBhat 644a87f
Add UI test to verify that simple products banner message is displaye…
AnirudhBhat 54b81f4
Add UI test to verify that simple products banner opens simple produc…
AnirudhBhat 7a75fd7
Add UI test to verify that simple products banner is dismissed when c…
AnirudhBhat 0c2e310
Add test tag for Simple products info dialog so that we can reference…
AnirudhBhat 9a5034a
Combine testing simple products banner's message and title into one t…
AnirudhBhat 8a37125
Fix detekt errors
AnirudhBhat 71f491a
Remove unused imports
AnirudhBhat d064a29
Merge branch 'refs/heads/trunk' into issue/12377-ui-tests-for-simple-…
AnirudhBhat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
WooCommerce/src/androidTest/assets/mocks/mappings/woopos/blaze_campaigns.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} | ||
} |
160 changes: 160 additions & 0 deletions
160
WooCommerce/src/androidTest/kotlin/com/woocommerce/android/WooPosBannerTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
@file:Suppress("DEPRECATION") | ||
|
||
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 | ||
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<ComponentActivity>() | ||
|
||
@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<Preferences> | ||
|
||
@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 testWooPosSimpleProductsOnlyBannerIsDisplayedOnProductsScreen() = runTest { | ||
composeTestRule.waitUntil(5000) { | ||
try { | ||
composeTestRule.onNodeWithTag("product_list") | ||
.assertExists() | ||
.assertIsDisplayed() | ||
true | ||
} catch (e: AssertionError) { | ||
e.printStackTrace() | ||
false | ||
} | ||
} | ||
|
||
composeTestRule.onNodeWithTag( | ||
"woo_pos_simple_products_banner" | ||
).assertIsDisplayed() | ||
} | ||
|
||
@Test | ||
fun testWooPosSimpleProductsOnlyBannerTitleAndMessageIsDisplayedOnBanner() = runTest { | ||
composeTestRule.waitUntil(5000) { | ||
try { | ||
composeTestRule.onNodeWithTag("product_list") | ||
.assertExists() | ||
.assertIsDisplayed() | ||
true | ||
} catch (e: AssertionError) { | ||
e.printStackTrace() | ||
false | ||
} | ||
} | ||
|
||
composeTestRule.onNodeWithText( | ||
composeTestRule.activity.getString(R.string.woopos_banner_simple_products_only_title) | ||
).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) | ||
).assertIsDisplayed() | ||
} | ||
|
||
@Test | ||
fun testWooPosSimpleProductsOnlyBannerOpensProductInfoDialogWhenClickedOnLearnMore() = runTest { | ||
composeTestRule.waitUntil(5000) { | ||
try { | ||
composeTestRule.onNodeWithTag("product_list") | ||
.assertExists() | ||
.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) | ||
).performClick() | ||
|
||
composeTestRule.onNodeWithTag("woo_pos_product_info_dialog") | ||
.assertIsDisplayed() | ||
} | ||
|
||
@Test | ||
fun testWooPosSimpleProductsOnlyBannerIsDismissedWhenClosed() = runTest { | ||
composeTestRule.waitUntil(5000) { | ||
try { | ||
composeTestRule.onNodeWithTag("product_list") | ||
.assertExists() | ||
.assertIsDisplayed() | ||
true | ||
} catch (e: AssertionError) { | ||
e.printStackTrace() | ||
false | ||
} | ||
} | ||
|
||
composeTestRule.onNodeWithContentDescription( | ||
composeTestRule.activity.getString(R.string.woopos_banner_simple_products_close_content_description) | ||
).performClick() | ||
|
||
composeTestRule.onNodeWithTag( | ||
"woo_pos_simple_products_banner" | ||
).assertIsNotDisplayed() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
WooCommerce/src/androidTest/kotlin/com/woocommerce/android/e2e/screens/pos/POSModeScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change was made solely to run UI tests and needs to be reverted. The reason for the change is that the store used for UI testing doesn't pass IPP onboarding, which causes the POS setting to not appear in the settings.