8000 Fix e2e ios tests by janicduplessis · Pull Request #6613 · rainbow-me/rainbow · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix e2e ios tests #6613

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

Merged
merged 11 commits into from
May 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/android-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
# the test run. Note that the video is limited to 3 minutes.
DEBUG: false
SHARDS: 1
ANDROID_EMULATOR_API_LEVEL: 30
ANDROID_EMULATOR_PROFILE: pixel_5
ANDROID_EMULATOR_API_LEVEL: 31
ANDROID_EMULATOR_PROFILE: pixel_6
ANDROID_EMULATOR_CORES: 4
ANDROID_EMULATOR_RAM_SIZE: 8192
ARTIFACTS_FOLDER: e2e-artifacts
Expand Down
20 changes: 20 additions & 0 deletions e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,26 @@ It is recommended that those commands are extracted to a flow for reuse. See `e2

### Troubleshooting

#### Cannot find view with a testID on iOS

On iOS `testID` is implemented using `accessibilityIdentifier`. If a parent view is marked as `accessible=true` then it is considered a leaf node and its children `accessibilityIdentifier` won't be visible. Try moving the `testID` up to the accessible view or making the view not accessible if it makes sense in that case. Note that `ButtonPressAnimation` defaults to `accessible=true`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is really nice to document, ty.


For example:

```tsx
<ButtonPressAnimation>
<View testID="test" />
</ButtonPressAnimation>
```

Will not work, instead use:

```tsx
<ButtonPressAnimation testID="test">
<View />
</ButtonPressAnimation>
```

#### Long wait time between actions

Maestro waits for the app to be settled before moving on to the next actions. If it seems to be waiting too much this is most likely caused by looping animations preventing it from settling. If you see any animation, you can use the `IS_TEST` from `@/env` to disable them for e2e tests only.
Expand Down
2 changes: 1 addition & 1 deletion e2e/onboarding/CreateWallet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ tags:
- runFlow: ../utils/Prepare.yaml
- assertVisible:
id: welcome-screen
- tapOn: 'Get a new wallet'
- tapOn: '.*Get a new wallet'
- runFlow: ../utils/MaybeSetupPin.yaml

# Check wallet screen exists and has expected elements
Expand Down
7 changes: 3 additions & 4 deletions e2e/onboarding/WatchedWallet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ tags:
arguments:
isE2ETest: true
- runFlow: ../utils/Prepare.yaml
- tapOn: 'I already have one'

# (Element not found: Text matching regex: Watch an Ethereum Address)
- tapOn: 'Watch a wallet'
- tapOn: '.*I already have one'
- tapOn:
id: watch-address-button
- tapOn: 'Enter an Ethereum address or ENS name'
- inputText: 'rainbowtestwallet.eth'
- tapOn: 'Continue'
Expand Down
47 changes: 47 additions & 0 deletions e2e/screens/MaliciousDappTransactionWarning.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
appId: ${APP_ID}
tags:
- browser
- parallel
---
- launchApp:
clearState: true
clearKeychain: true
arguments:
isE2ETest: true
- runFlow: ../utils/Prepare.yaml
- runFlow: ../utils/ImportWalletWithKey.yaml

# Navigate to browser
- tapOn:
id: 'tab-bar-icon-DappBrowserScreen'
- assertVisible:
id: browser-screen
- runFlow:
when:
# Maestro cannot interact with content in webviews on iOS so run
# the flow only on Android.
platform: Android
commands:
# tap on browser search input
- tapOn: 'Search or enter website'
- inputText: 'https://bx-test-dapp.vercel.app/'
- pressKey: enter
- assertVisible: 'Test Dapp 🌈'
# tap on wallet pfp to open the control panel
- tapOn:
id: account-icon
- tapOn:
id: connect-button
# control panel assertions
- assertVisible:
text: '.*BX Test Dapp.*'
- assertVisible:
text: 'Disconnect'
# tap somewhere arbitrary to close the control panel sheet
- tapOn:
point: 50%,15%
- scroll
- tapOn: 'sign malicious permit'
- extendedWaitUntil:
visible: '.*Suspicious Transaction'
timeout: 30000
51 changes: 0 additions & 51 deletions e2e/screens/MaliciousDappWarning.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions e2e/settings/ManualBackup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ tags:
- tapOn: 'No thanks'
- assertVisible: 'Wallets & Backup'

- assertVisible: 'Enable Cloud Backups'
- assertVisible: '.*Enable Cloud Backups'

# Navigate to manual backup screen
- tapOn: 'Private Key 1'
- tapOn: '.*Private Key 1.*'
- assertVisible: 'Not backed up'
- tapOn:
id: back-up-manually
Expand Down
3 changes: 2 additions & 1 deletion e2e/transactions/SendTransaction.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ tags:
commands:
- swipe:
direction: DOWN
- assertVisible: 'Ethereum'
- assertVisible:
id: 'balance-coin-row-Ethereum'
- tapOn:
id: send-button
- assertVisible:
Expand Down
2 changes: 1 addition & 1 deletion e2e/transactions/SwapTransaction.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ tags:
- inputText: 'DAI'
- tapOn:
id: token-to-buy-dai-1
- assertVisible: 'DAI'
- assertVisible: 'DAI.*'
- assertVisible: 'No Balance'
# Add swap execution and validation.
# Currenlty on detox we don't do either.
2 changes: 2 additions & 0 deletions e2e/utils/MaybeSetupPin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ appId: ${APP_ID}
- tapOn:
text: '1'
repeat: 4
delay: 1000
- tapOn:
text: '1'
repeat: 4
delay: 1000
17 changes: 15 additions & 2 deletions patches/react-native+0.74.3.patch
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,23 @@ index b868ee7..50e3b1c 100644
NSDictionary *dictionary = json;
id value = nil;
diff --git a/node_modules/react-native/React/Views/RCTView.m b/node_modules/react-native/React/Views/RCTView.m
index 3a86581..1bd1458 100644
index 3a86581..d03c066 100644
--- a/node_modules/react-native/React/Views/RCTView.m
+++ b/node_modules/react-native/React/Views/RCTView.m
@@ -820,6 +820,10 @@ - (void)displayLayer:(CALayer *)layer
@@ -236,7 +236,11 @@ - (NSString *)accessibilityLabel
if (label) {
return label;
}
- return RCTRecursiveAccessibilityLabel(self);
+
+ if (self.isAccessibilityElement) {
+ return RCTRecursiveAccessibilityLabel(self);
+ }
+ return nil;
}

- (NSArray<UIAccessibilityCustomAction *> *)accessibilityCustomActions
@@ -820,6 +824,10 @@ - (void)displayLayer:(CALayer *)layer

backgroundColor = [_backgroundColor resolvedColorWithTraitCollection:self.traitCollection].CGColor;

Expand Down
27 changes: 0 additions & 27 deletions scripts/e2e-android-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,6 @@ for DEVICE in $DEVICES; do
fi
done

# Always start Anvil for CI runs
echo "Starting Anvil for tests..."

# Kill any existing Anvil process
ANVIL_PID=$(lsof -t -i:8545 -c anvil 2>/dev/null)
if [ -n "$ANVIL_PID" ]; then
kill $ANVIL_PID
fi
sleep 1

# Start Anvil in the background (show logs in terminal + save to file)
bash ./scripts/anvil.sh --host 0.0.0.0 2>&1 | grep -v "eth_" | tee anvil.log &
ANVIL_PID=$!
echo "Anvil started (PID: $ANVIL_PID)"

# Wait for Anvil to initialize
sleep 5

# Run the tests
./scripts/e2e-android.sh --device $DEVICES_LIST --debug-output $ARTIFACTS_FOLDER --flatten-debug-output $SHARDS_FLAG
TEST_STATUS=$?
Expand All @@ -62,13 +44,4 @@ for DEVICE in $DEVICES; do
fi
done

# Kill the Anvil process
echo "Killing Anvil (PID: $ANVIL_PID)"
kill "$ANVIL_PID" 2>/dev/null || true
# kill any other processes using port 8545
kill $(lsof -t -i:8545) 2>/dev/null || true

# Remove the Anvil log file
rm -rf anvil.log

exit $TEST_STATUS
31 changes: 19 additions & 12 deletions scripts/e2e-android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,24 @@ while [[ $# -gt 0 ]]; do
shift
done

# Check if we're running a transaction test
if [[ $FLOW == *"transaction"* ]]; then
# Check if we're running all tests or a transaction test
if [[ $FLOW == *"transaction"* || $FLOW == "e2e" ]]; then
echo "Transaction test detected."

# Kill any existing Anvil process
echo "Cleaning up any existing Anvil processes..."
ANVIL_PID=$(lsof -t -i:8545 -c anvil 2>/dev/null)
if [ -n "$ANVIL_PID" ]; then
kill $ANVIL_PID
fi
sleep 1

# Start Anvil in the background
echo "Starting Anvil..."
yarn anvil --host 0.0.0.0 &

echo "Waiting 5 seconds for Anvil to start..."

# Start Anvil in the background (show logs in terminal + save to file)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved starting anvil when running all tests here, instead of in the ci script to make it easier to run locally.

bash ./scripts/anvil.sh --host 0.0.0.0 2>&1 | grep -v "eth_" | tee anvil.log &
ANVIL_PID=$!
echo "Anvil started (PID: $ANVIL_PID)"

# Wait for Anvil to initialize
sleep 5
fi

Expand All @@ -49,10 +50,16 @@ maestro $DEVICE -p Android test -e DEV_PKEY="$DEV_PKEY" -e APP_ID="me.rainbow" "
# Store the exit code
EXIT_CODE=$?

# Clean up
ANVIL_PID=$(lsof -t -i:8545 -c anvil 2>/dev/null)
# Kill the Anvil process
if [ -n "$ANVIL_PID" ]; then
kill $ANVIL_PID
echo "Killing Anvil (PID: $ANVIL_PID)"
kill "$ANVIL_PID" 2>/dev/null || true
fi
# kill any other processes using port 8545
kill $(lsof -t -i:8545) 2>/dev/null || true

# Remove the Anvil log file
rm -rf anvil.log

# Exit with the test exit code
exit $EXIT_CODE
24 changes: 2 additions & 22 deletions scripts/e2e-ios-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,9 @@ ARTIFACTS_FOLDER="${ARTIFACTS_FOLDER:-e2e-artifacts}"
# Install the app.
xcrun simctl install $DEVICE_UDID ios/build/Build/Products/Release-iphonesimulator/Rainbow.app

# Start Anvil for CI runs
echo "Starting anvil..."

# Kill any existing Anvil process
ANVIL_PID=$(lsof -t -i:8545 -c anvil 2>/dev/null)
if [ -n "$ANVIL_PID" ]; then
kill $ANVIL_PID
fi
sleep 1

# Start Anvil in the background
bash ./scripts/anvil.sh --host 0.0.0.0 2>&1 | grep -v "eth_" | tee anvil.log &
ANVIL_PID=$!
echo "Anvil started (PID: $ANVIL_PID)"

# Run the tests with proper parameters
echo "Running tests..."
./scripts/e2e-ios.sh --device $DEVICE_UDID --debug-output $ARTIFACTS_FOLDER --flatten-debug-output
TEST_STATUS=$?

# Kill the Anvil process
echo "Killing Anvil (PID: $ANVIL_PID)"
kill "$ANVIL_PID" 2>/dev/null || true
kill $(lsof -t -i:8545) 2>/dev/null || true

# Remove the Anvil log file
rm -rf anvil.log
exit $TEST_STATUS
14 changes: 7 additions & 7 deletions scripts/e2e-ios.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ while [[ $# -gt 0 ]]; do
shift
;;
--device)
DEVICE="$1 $2"
DEVICE="$1 $2"
shift
;;
*)
Expan A43F d All @@ -24,22 +24,22 @@ while [[ $# -gt 0 ]]; do
shift
done

# Check if we're running a transaction test
if [[ $FLOW == *"transaction"* ]]; then
# Check if we're running all tests or a transaction test
if [[ $FLOW == *"transaction"* || $FLOW == "e2e" ]]; then
echo "Transaction test detected."

# Kill any existing Anvil process
echo "Cleaning up any existing Anvil processes..."
ANVIL_PID=$(lsof -t -i:8545 -c anvil 2>/dev/null)
if [ -n "$ANVIL_PID" ]; then
kill $ANVIL_PID
fi
sleep 1

# Start Anvil in the background
echo "Starting Anvil..."
yarn anvil --host 0.0.0.0 &

echo "Waiting 5 seconds for Anvil to start..."
sleep 5
fi
Expand All @@ -58,4 +58,4 @@ if [ -n "$ANVIL_PID" ]; then
fi

# Exit with the test exit code
exit $EXIT_CODE
exit $EXIT_CODE
Loading
Loading
0