-
Notifications
You must be signed in to change notification settings - Fork 5
feat: testing tool #49
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
Open
grablack
wants to merge
61
commits into
develop
Choose a base branch
from
feature-testing-tool
base: develop
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.
Open
Changes from all commits
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
1be050d
check for message
grablack 1e1f3bf
update local.xml
grablack dbd7520
add more tests
grablack a85f84a
basic activity
grablack 23a0a3b
repeatable functions
grablack 06d359f
updates
grablack b269fbf
check modal condition
grablack 604526a
rename functions
grablack e2e647f
seperate files
grablack 637a8de
github action espresso
grablack cfa3416
use reponse to execute test
grablack 8ee7a0b
fix error
grablack ae002f4
error logging
grablack 07f5f4d
echo urls
grablack 11a38fa
make test apk
grablack 0df6be1
1 build step
grablack f7ebeec
try splitting
grablack b28138f
provide path
grablack f8ee839
update device
grablack c511f70
use demo tests
grablack 200f2d8
change apk
grablack 762878e
make build a single line
grablack a309fca
use debug
grablack 7ccb2e8
fix path
grablack 950b627
changes to timing
grablack e4c7e1f
try longer wait
grablack 1e72734
fun to wait
grablack 88ed428
restore showwebview before merge
grablack 9f1dc00
Merge branch 'develop' into feature-testing-tool
grablack 29b2937
use other new wait
grablack f6de342
seperate functions
grablack 7e6f3be
set environment
grablack dbad550
moved
grablack eff4d19
comments for modal clicks
grablack 12687ea
test jetpack modal
grablack e4e06e6
wait longer
grablack 627683e
exclude new tests
grablack b5444da
change exclude
grablack f90e46a
update exclude
grablack 5f5e36d
add exclude to gradle
grablack d615737
move
grablack 25cb1f5
remove gradle change
grablack 30f9e35
path to all
grablack ddfa874
remove espresso test
grablack 8dd405f
comment out failing tests
grablack 90b5373
add back testImplementation
grablack c1cd27e
exclude
grablack 34b357a
Merge branch 'develop' into feature-testing-tool
grablack 6fead6a
fix: update cache action to v3 for improved performance
grablack 31dbd9a
fix: correct Sonatype Nexus username and password secrets in release …
grablack 3d9068c
feat: add Sonatype snapshot repository configuration for publishing
grablack 0b03dc6
fix: add conditional logic for snapshot and release publishing in act…
grablack 330e52c
fix: exclude duplicate sources in androidSourcesJar task
grablack 4e346de
fix: update Sonatype snapshot repository URL for consistency
grablack 4282199
fix: update snapshot publishing logic and apply nexus plugin conditio…
grablack e3cb551
fix: streamline publishing process by removing nexus plugin and using…
grablack 92e227f
fix: update repository configuration to use Sonatype OSS for publishing
grablack c7933b3
fix: enhance publishing logic to handle snapshots and releases separa…
grablack 189e992
fix: update publishing logic to handle snapshots and releases separately
grablack 9fc79bc
fix: update authentication method to use token-based approach for Son…
grablack 9d63156
fix: update authentication method to use username/password for Sonaty…
grablack 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
This file contains hidden or 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 hidden or 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,92 @@ | ||
name: Espresso Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- feature-testing-tool | ||
pull_request: | ||
branches: | ||
- feature-testing-tool | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'zulu' | ||
java-version: '17' | ||
|
||
- name: Cache Gradle packages | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.gradle/caches | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | ||
restore-keys: | | ||
${{ runner.os }}-gradle- | ||
|
||
- name: Add Client ID | ||
env: | ||
CLIENT_ID: ${{ secrets.CLIENT_ID }} | ||
run: ./gradlew updateLocalsXmlFile | ||
|
||
- name: Build APKs | ||
run: | | ||
./gradlew :demo:assembleDebug :demo:assembleAndroidTest | ||
|
||
- name: Upload App to BrowserStack | ||
env: | ||
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }} | ||
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} | ||
run: | | ||
APP_APK_PATH=./demo/build/outputs/apk/debug/demo-debug.apk | ||
TEST_APK_PATH=./demo/build/outputs/apk/androidTest/debug/demo-debug-androidTest.apk | ||
|
||
echo "App APK path: $APP_APK_PATH" | ||
echo "Test APK path: $TEST_APK_PATH" | ||
|
||
if [[ -z "$APP_APK_PATH" || -z "$TEST_APK_PATH" ]]; then | ||
echo "Error: APK file not found." | ||
exit 1 | ||
fi | ||
|
||
# Upload app APK and capture response | ||
APP_UPLOAD_RESPONSE=$(curl -s -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" \ | ||
-X POST "https://api-cloud.browserstack.com/app-automate/espresso/v2/app" \ | ||
-F "file=@$APP_APK_PATH") | ||
|
||
echo "App upload response: $APP_UPLOAD_RESPONSE" | ||
|
||
APP_URL=$(echo $APP_UPLOAD_RESPONSE | jq -r '.app_url') | ||
|
||
if [[ -z "$APP_URL" ]]; then | ||
echo "Error: App URL not found in response." | ||
exit 1 | ||
fi | ||
|
||
# Upload test suite APK and capture response | ||
TEST_SUITE_UPLOAD_RESPONSE=$(curl -s -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" \ | ||
-X POST "https://api-cloud.browserstack.com/app-automate/espresso/v2/test-suite" \ | ||
-F "file=@$TEST_APK_PATH") | ||
|
||
echo "Test suite upload response: $TEST_SUITE_UPLOAD_RESPONSE" | ||
|
||
TEST_SUITE_URL=$(echo $TEST_SUITE_UPLOAD_RESPONSE | jq -r '.test_suite_url') | ||
|
||
if [[ -z "$TEST_SUITE_URL" ]]; then | ||
echo "Error: Test suite URL not found in response." | ||
exit 1 | ||
fi | ||
|
||
# Use the app_url and test_suite_url in another cURL request | ||
FINAL_RESPONSE=$(curl -s -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" \ | ||
-X POST "https://api-cloud.browserstack.com/app-automate/espresso/v2/build" \ | ||
-d "{\"app\": \"$APP_URL\", \"testSuite\": \"$TEST_SUITE_URL\", \"devices\": [\"Samsung Galaxy S23-13.0\"], \"project\": \"Paypal_Messages_Android\"}" \ | ||
-H "Content-Type: application/json") | ||
|
||
echo "Final response: $FINAL_RESPONSE" |
This file contains hidden or 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 hidden or 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 hidden or 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
58 changes: 58 additions & 0 deletions
58
demo/src/androidTest/java/com/paypal/messagesdemo/InlineXmlTest.kt
This file contains hidden or 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,58 @@ | ||
package com.paypal.messagesdemo | ||
|
||
import android.view.Gravity | ||
import androidx.core.content.ContextCompat | ||
import androidx.test.espresso.Espresso | ||
import androidx.test.espresso.Espresso.onView | ||
import androidx.test.espresso.assertion.ViewAssertions.matches | ||
import androidx.test.espresso.matcher.ViewMatchers.withId | ||
import androidx.test.ext.junit.rules.ActivityScenarioRule | ||
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner | ||
import com.paypal.messages.R | ||
import com.paypal.messages.config.message.style.PayPalMessageColor | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4ClassRunner::class) | ||
public class InlineXmlTest { | ||
var expectedColor: Int? = null | ||
|
||
@get:Rule | ||
val activityScenarioRule = ActivityScenarioRule(BasicXmlActivity::class.java) | ||
|
||
@Test | ||
fun testGenericMessage() { | ||
waitForApp(500) | ||
|
||
// Check if SecondActivity is displayed by verifying a TextView in SecondActivity | ||
checkMessage("%paypal_logo% Buy now, pay later. Learn more") | ||
onView(withId(R.id.content)).check(matches(GravityMatcher.withGravity(Gravity.LEFT))) | ||
|
||
// Get the actual color value from the resource ID | ||
activityScenarioRule.scenario.onActivity { activity -> | ||
expectedColor = ContextCompat.getColor(activity, PayPalMessageColor.BLACK.colorResId) | ||
} | ||
|
||
// Use the custom matcher to check the text color of the TextView | ||
onView(withId(R.id.content)) | ||
.check(matches(ColorMatcher.withTextColor(expectedColor!!))) | ||
} | ||
|
||
@Test | ||
fun testGenericModalCloseWithBackButton() { | ||
waitForApp(500) | ||
checkMessage("%paypal_logo% Buy now, pay later. Learn more") | ||
|
||
clickMessage() | ||
waitForApp(1000) | ||
modalContent("Get more info") | ||
|
||
Espresso.pressBack() | ||
waitForApp(500) | ||
checkMessage("%paypal_logo% Buy now, pay later. Learn more") | ||
clickMessage() | ||
waitForApp(1000) | ||
modalContent("Get more info") | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
demo/src/androidTest/java/com/paypal/messagesdemo/JetPackTest.kt
This file contains hidden or 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,55 @@ | ||
package com.paypal.messagesdemo | ||
|
||
// @RunWith(AndroidJUnit4ClassRunner::class) | ||
// public class JetPackTest { | ||
// var expectedColor: Int? = null | ||
// | ||
// @Rule | ||
// @JvmField | ||
// val activityScenarioRule = ActivityScenarioRule<JetpackActivity>( | ||
// Intent(ApplicationProvider.getApplicationContext(), JetpackActivity::class.java).apply { | ||
// putExtra("TEST_ENV", "LIVE") | ||
// }, | ||
// ) | ||
// | ||
// fun submit() { | ||
// onView(withId(Demo.id.submit)).perform(scrollTo()) | ||
// onView(withId(Demo.id.submit)).perform(click()) | ||
// waitForApp(500) | ||
// } | ||
// | ||
// @Test | ||
// fun testGenericMessage() { | ||
// // Perform a delay | ||
// waitForApp(1000) | ||
// | ||
// // Check if SecondActivity is displayed by verifying a TextView in SecondActivity | ||
// checkMessage("%paypal_logo% Buy now, pay later. Learn more") | ||
// onView(withId(R.id.content)).check(matches(GravityMatcher.withGravity(Gravity.LEFT))) | ||
// | ||
// // Get the actual color value from the resource ID | ||
// activityScenarioRule.scenario.onActivity { activity -> | ||
// expectedColor = ContextCompat.getColor(activity, PayPalMessageColor.BLACK.colorResId) | ||
// } | ||
// | ||
// // Use the custom matcher to check the text color of the TextView | ||
// onView(withId(R.id.content)) | ||
// .check(matches(ColorMatcher.withTextColor(expectedColor!!))) | ||
// } | ||
// | ||
// @Test | ||
// fun testGenericMessageAndModal() { | ||
// waitForApp(2000) | ||
// | ||
// // Check if SecondActivity is displayed by verifying a TextView in SecondActivity | ||
// checkMessage("%paypal_logo% Buy now, pay later. Learn more") | ||
// clickMessage() | ||
// | ||
// onView(withId(R.id.ModalWebView)).check( | ||
// matches(ViewMatchers.isDisplayed()), | ||
// ) | ||
// | ||
// modalContent("Pay Later options") | ||
// waitForApp(2000) | ||
// } | ||
// } |
Oops, something went wrong.
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.
Hi @grablack, I noticed that all of the code in
JetPackTest.kt
is currently commented out.Is this intentional? If it's meant for future work, it might be cleaner to:
@Test
method marked@Ignore
and aTODO
note explaining what will be added in the next PR, orThis keeps the repo clean and avoids confusion for others pulling the branch 🙂
Let me know if I can help clarify!