Skip to content

CW 882: Integrate Seed Verification Flow To Integration Tests #1966

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
wants to merge 51 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
25a8393
fix: Generic fixes
Blazebrain Dec 20, 2024
e3c4f7a
Merge branch 'main' of https://github.com/cake-tech/cake_wallet
Blazebrain Jan 13, 2025
1335627
fix: Modify hasSufficientFundsForRent to work for spl transactions
Blazebrain Jan 14, 2025
ecc0156
feat: Integrate seed verification into integration tests
Blazebrain Jan 16, 2025
f5cc30b
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
Blazebrain Jan 16, 2025
50c82e0
fix: Adjust workflow file
Blazebrain Jan 16, 2025
ff3606a
chore: Remove previous working directory
Blazebrain Jan 16, 2025
4707dc8
fix: Revert change
Blazebrain Jan 16, 2025
164ae7e
chore: Remove step to setup kvm, already existing in new setup
Blazebrain Jan 16, 2025
45aed18
chore: Remove a couple of steps from workflow
Blazebrain Jan 16, 2025
3ca0334
chore: Try switching test commands
Blazebrain Jan 16, 2025
5060cbe
fix: Switch back to flutter drive
Blazebrain Jan 16, 2025
85f8ebb
fix: Flutter error when running tests with Flutter drive
Blazebrain Jan 16, 2025
ee067cc
Merge branch 'main' into Integrate-Seed-Verification-Flow-To-Integrat…
OmarHatem28 Jan 17, 2025
b0602f8
feat: Add screenshots to individual test pages and modify integration…
Blazebrain Jan 17, 2025
3216a87
Merge branch 'Integrate-Seed-Verification-Flow-To-Integration-Tests' …
Blazebrain Jan 17, 2025
17285bd
feat: Implement transaction success info robot and fix issue with sen…
Blazebrain Jan 17, 2025
640766d
fix: Improve integration testing for exchange flow and clean up logic…
Blazebrain Jan 20, 2025
b83cf66
fix: Handle duplicate words for seeds and test restore through seeds
Blazebrain Jan 20, 2025
35d5a10
fix: Optimize implementation for transactions history test
Blazebrain Jan 22, 2025
2e8038b
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
Blazebrain Feb 11, 2025
f640062
Skip seed verification when in debug and when not in CI flow
Blazebrain Feb 11, 2025
adc9f3f
chore: Remove print statements and add TODOs
Blazebrain Feb 11, 2025
33d0033
fix: Upgrade version for upload action
Blazebrain Feb 11, 2025
1ebc087
fix: Add missing secrets to testing workflow file
Blazebrain Feb 11, 2025
4c9e37c
fix tests not working in latest main [skip slack]
MrCyjaneK Feb 3, 2025
5bfa166
add zano seed [skip slack] [run tests]
MrCyjaneK Feb 3, 2025
dda2927
disable exchange_flow_test.dart [run tests] [skip slack]
MrCyjaneK Feb 3, 2025
1396e97
Run tests on linux always (since nobody ever used [run tests])
MrCyjaneK Feb 12, 2025
6881707
fix tests after ui updates
MrCyjaneK Feb 12, 2025
0d2b0a3
[skip slack] tests update
MrCyjaneK Feb 12, 2025
1f60c4e
Merge pull request #1999 from cake-tech/cyjan-fix-tests
Blazebrain Mar 12, 2025
cd0d049
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
Blazebrain Mar 12, 2025
bbe72f4
Merge branch 'Integrate-Seed-Verification-Flow-To-Integration-Tests' …
Blazebrain Mar 12, 2025
b9d6d6d
Fixing tests WIP
Blazebrain Mar 13, 2025
0f7c4ee
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
Blazebrain Mar 20, 2025
d6c7beb
Fix create wallet integraiton test flow
Blazebrain Mar 21, 2025
74fc9d7
Update and fix Exchange flow test flow
Blazebrain Mar 21, 2025
1711bb1
Switch printV to printToConsole
Blazebrain Mar 24, 2025
aad7320
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
Blazebrain Mar 24, 2025
e285236
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
Blazebrain Apr 7, 2025
c24d531
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
Blazebrain Apr 8, 2025
3eea48d
Adjustments to the the flows on Send and Exchange
Blazebrain Apr 9, 2025
9faec1c
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
Blazebrain Apr 9, 2025
c2e77c0
feat: Modify Exchange and send tests to fit new flow
Blazebrain Apr 9, 2025
26506a9
fix:
Blazebrain Apr 9, 2025
629cdf0
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
Blazebrain Apr 24, 2025
5ff769e
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
OmarHatem28 Apr 26, 2025
9e3d64e
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
Blazebrain Apr 29, 2025
55d32ab
Merge branch 'Integrate-Seed-Verification-Flow-To-Integration-Tests' …
Blazebrain Apr 29, 2025
717bb0c
fix(integration-tests): Fix issues relating to send flow integration …
Blazebrain Apr 29, 2025
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
559 changes: 275 additions & 284 deletions .github/workflows/automated_integration_test.yml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions .github/workflows/pr_test_build_android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ jobs:
echo "const tronTestWalletSeeds = '${{ secrets.TRON_TEST_WALLET_SEEDS }}';" >> lib/.secrets.g.dart
echo "const nanoTestWalletSeeds = '${{ secrets.NANO_TEST_WALLET_SEEDS }}';" >> lib/.secrets.g.dart
echo "const wowneroTestWalletSeeds = '${{ secrets.WOWNERO_TEST_WALLET_SEEDS }}';" >> lib/.secrets.g.dart
echo "const zanoTestWalletSeeds = '${{ secrets.ZANO_TEST_WALLET_SEEDS }}';" >> lib/.secrets.g.dart
echo "const moneroTestWalletReceiveAddress = '${{ secrets.MONERO_TEST_WALLET_RECEIVE_ADDRESS }}';" >> lib/.secrets.g.dart
echo "const bitcoinTestWalletReceiveAddress = '${{ secrets.BITCOIN_TEST_WALLET_RECEIVE_ADDRESS }}';" >> lib/.secrets.g.dart
echo "const ethereumTestWalletReceiveAddress = '${{ secrets.ETHEREUM_TEST_WALLET_RECEIVE_ADDRESS }}';" >> lib/.secrets.g.dart
Expand Down
26 changes: 15 additions & 11 deletions .github/workflows/pr_test_build_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ jobs:
echo "const tronTestWalletSeeds = '${{ secrets.TRON_TEST_WALLET_SEEDS }}';" >> lib/.secrets.g.dart
echo "const nanoTestWalletSeeds = '${{ secrets.NANO_TEST_WALLET_SEEDS }}';" >> lib/.secrets.g.dart
echo "const wowneroTestWalletSeeds = '${{ secrets.WOWNERO_TEST_WALLET_SEEDS }}';" >> lib/.secrets.g.dart
echo "const zanoTestWalletSeeds = '${{ secrets.ZANO_TEST_WALLET_SEEDS }}';" >> lib/.secrets.g.dart
echo "const decredTestWalletSeeds = '${{ secrets.DECRED_TEST_WALLET_SEEDS }}';" >> lib/.secrets.g.dart
echo "const moneroTestWalletReceiveAddress = '${{ secrets.MONERO_TEST_WALLET_RECEIVE_ADDRESS }}';" >> lib/.secrets.g.dart
echo "const bitcoinTestWalletReceiveAddress = '${{ secrets.BITCOIN_TEST_WALLET_RECEIVE_ADDRESS }}';" >> lib/.secrets.g.dart
echo "const ethereumTestWalletReceiveAddress = '${{ secrets.ETHEREUM_TEST_WALLET_RECEIVE_ADDRESS }}';" >> lib/.secrets.g.dart
Expand All @@ -162,6 +164,8 @@ jobs:
echo "const tronTestWalletReceiveAddress = '${{ secrets.TRON_TEST_WALLET_RECEIVE_ADDRESS }}';" >> lib/.secrets.g.dart
echo "const nanoTestWalletReceiveAddress = '${{ secrets.NANO_TEST_WALLET_RECEIVE_ADDRESS }}';" >> lib/.secrets.g.dart
echo "const wowneroTestWalletReceiveAddress = '${{ secrets.WOWNERO_TEST_WALLET_RECEIVE_ADDRESS }}';" >> lib/.secrets.g.dart
echo "const zanoTestWalletReceiveAddress = '${{ secrets.ZANO_TEST_WALLET_RECEIVE_ADDRESS }}';" >> lib/.secrets.g.dart
echo "const decredTestWalletReceiveAddress = '${{ secrets.DECRED_TEST_WALLET_RECEIVE_ADDRESS }}';" >> lib/.secrets.g.dart
echo "const moneroTestWalletBlockHeight = '${{ secrets.MONERO_TEST_WALLET_BLOCK_HEIGHT }}';" >> lib/.secrets.g.dart
# end of test secrets
echo "const chainflipApiKey = '${{ secrets.CHAINFLIP_API_KEY }}';" >> lib/.secrets.g.dart
Expand Down Expand Up @@ -240,7 +244,7 @@ jobs:
name: cakewallet_linux

- name: Prepare virtual desktop
if: ${{ contains(env.message, 'run tests') }}
if: ${{ !contains(env.message, 'skip tests') }}
run: |
nohup Xvfb :99 -screen 0 720x1280x16 &
echo DISPLAY=:99 | sudo tee -a $GITHUB_ENV
Expand All @@ -256,28 +260,28 @@ jobs:
# isn't much in those wallets anyway, we still wouldn't like to leak it to anyone who is able to access github.

- name: Test [confirm_seeds_flow_test]
if: ${{ contains(env.message, 'run tests') }}
if: ${{ !contains(env.message, 'skip tests') }}
timeout-minutes: 20
run: |
xmessage -timeout 30 "confirm_seeds_flow_test" &
rm -rf ~/.local/share/com.example.cake_wallet/ ~/Documents/cake_wallet/ ~/cake_wallet
exec timeout --signal=SIGKILL 900 flutter drive --driver=test_driver/integration_test.dart --target=integration_test/test_suites/confirm_seeds_flow_test.dart
- name: Test [create_wallet_flow_test]
if: ${{ contains(env.message, 'run tests') }}
if: ${{ !contains(env.message, 'skip tests') }}
timeout-minutes: 20
run: |
xmessage -timeout 30 "create_wallet_flow_test" &
rm -rf ~/.local/share/com.example.cake_wallet/ ~/Documents/cake_wallet/ ~/cake_wallet
exec timeout --signal=SIGKILL 900 flutter drive --driver=test_driver/integration_test.dart --target=integration_test/test_suites/create_wallet_flow_test.dart
- name: Test [exchange_flow_test]
if: ${{ contains(env.message, 'run tests') }}
timeout-minutes: 20
run: |
xmessage -timeout 30 "exchange_flow_test" &
rm -rf ~/.local/share/com.example.cake_wallet/ ~/Documents/cake_wallet/ ~/cake_wallet
exec timeout --signal=SIGKILL 900 flutter drive --driver=test_driver/integration_test.dart --target=integration_test/test_suites/exchange_flow_test.dart
# - name: Test [exchange_flow_test]
# if: ${{ !contains(env.message, 'skip tests') }}
# timeout-minutes: 20
# run: |
# xmessage -timeout 30 "exchange_flow_test" &
# rm -rf ~/.local/share/com.example.cake_wallet/ ~/Documents/cake_wallet/ ~/cake_wallet
# exec timeout --signal=SIGKILL 900 flutter drive --driver=test_driver/integration_test.dart --target=integration_test/test_suites/exchange_flow_test.dart
- name: Test [restore_wallet_through_seeds_flow_test]
if: ${{ contains(env.message, 'run tests') }}
if: ${{ !contains(env.message, 'skip tests') }}
timeout-minutes: 20
run: |
xmessage -timeout 30 "restore_wallet_through_seeds_flow_test" &
Expand Down
116 changes: 89 additions & 27 deletions integration_test/components/common_test_cases.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';

class CommonTestCases {
WidgetTester tester;
Expand All @@ -15,7 +16,7 @@ class CommonTestCases {
bool shouldPumpAndSettle = true,
int pumpDuration = 100,
}) async {
final widget = find.byKey(ValueKey(key));
final widget = find.byKey(ValueKey(key)).first;
await tester.tap(widget);
shouldPumpAndSettle
? await tester.pumpAndSettle(Duration(milliseconds: pumpDuration))
Expand Down Expand Up @@ -69,7 +70,33 @@ class CommonTestCases {
await tester.pumpAndSettle();
}

Future<void> dragUntilVisible(String childKey, String parentKey) async {
Future<void> startGesture(String key, Offset gestureOffset) async {
await tester.pumpAndSettle();

final hasKey = isKeyPresent(key);

tester.printToConsole("Has gestureKey: $hasKey");

if (!hasKey) return;

final gesture = await tester.startGesture(tester.getCenter(find.byKey(ValueKey(key))));

// Drag to the left
await gesture.moveBy(gestureOffset);

// End the gesture
await gesture.up();

await tester.pump();
}

Future<void> dragUntilVisible(
String childKey,
String parentKey, {
int maxScrolls = 100,
double scrollStep = 50.0,
int maxReverseScrolls = 50,
}) async {
await tester.pumpAndSettle();

final itemFinder = find.byKey(ValueKey(childKey));
Expand All @@ -82,18 +109,6 @@ class CommonTestCases {
return;
}

// We can adjust this as needed
final maxScrolls = 200;

int scrolls = 0;
bool found = false;

// We start by scrolling down
bool scrollDown = true;

// Flag to check if we've already reversed direction
bool reversedDirection = false;

// Find the Scrollable associated with the Parent Ad
final scrollableFinder = find.descendant(
of: listFinder,
Expand All @@ -110,48 +125,90 @@ class CommonTestCases {
// Get the initial scroll position
final scrollableState = tester.state<ScrollableState>(scrollableFinder);
double previousScrollPosition = scrollableState.position.pixels;
bool scrollDown = true;
bool reversedDirection = false;
bool found = false;

int reverseScrollCount = 0;

while (!found && scrolls < maxScrolls) {
for (int scrolls = 0; scrolls < maxScrolls; scrolls++) {
await tester.pumpAndSettle();

// Check if the widget is visible
if (tester.any(itemFinder)) {
found = true;
break;
}

// Log current state for debugging
tester.printToConsole('Scrolling ${scrollDown ? 'down' : 'up'}, attempt $scrolls');

// Perform the drag in the current direction
// Stop if reverse scroll limit is exceeded
if (!scrollDown && reverseScrollCount >= maxReverseScrolls) {
tester.printToConsole('Maximum reverse scrolls reached. Widget not found.');
break;
}

// Perform scrolling in the current direction
await tester.drag(
scrollableFinder,
scrollDown ? const Offset(0, -100) : const Offset(0, 100),
scrollDown ? Offset(0, -scrollStep) : Offset(0, scrollStep),
);
await tester.pumpAndSettle();
scrolls++;

// Update the scroll position after the drag
final currentScrollPosition = scrollableState.position.pixels;

if (currentScrollPosition == previousScrollPosition) {
// Cannot scroll further in this direction
// Cannot scroll further in the current direction
if (reversedDirection) {
// We've already tried both directions
tester.printToConsole('Cannot scroll further in both directions. Widget not found.');
tester.printToConsole('Reached the scroll limit in both directions. Widget not found.');
break;
} else {
// Reverse the scroll direction
// Reverse the scroll direction and reset reverse scroll count
scrollDown = !scrollDown;
reversedDirection = true;
reverseScrollCount = 0;
tester.printToConsole('Reached the end, reversing direction');
}
} else {
// Continue scrolling in the current direction
// Update scroll position and reverse scroll count, incrementing only for reverse scrolling
previousScrollPosition = currentScrollPosition;
if (!scrollDown) reverseScrollCount++;
}

// Check if the widget is now in the widget tree
found = tester.any(itemFinder);
}

if (!found) {
tester.printToConsole('Widget not found after scrolling in both directions.');
return;
tester.printToConsole('Widget not found after $maxScrolls scrolls.');
}
}

Future<void> scrollItemIntoView(
String itemKeyId,
double scrollPixels,
String scrollableFinderKey,
) async {
final Finder itemFinder = find.byKey(ValueKey(itemKeyId));

final scrollableFinder = find.descendant(
of: find.byKey(ValueKey(scrollableFinderKey)),
matching: find.byType(Scrollable),
);

try {
await tester.scrollUntilVisible(
itemFinder,
scrollPixels,
scrollable: scrollableFinder,
);
} catch (e) {
tester.printToConsole('Could not find $itemKeyId');
}

await tester.pumpAndSettle();
}

Future<void> enterText(String text, String editableTextKey) async {
final editableTextWidget = find.byKey(ValueKey((editableTextKey)));

Expand All @@ -171,4 +228,9 @@ class CommonTestCases {

Future<void> defaultSleepTime({int seconds = 2}) async =>
await Future.delayed(Duration(seconds: seconds));

Future<void> takeScreenshots(String screenshotName) async {
// Pausing this for now
// await (tester.binding as IntegrationTestWidgetsFlutterBinding).takeScreenshot(screenshotName);
}
}
5 changes: 3 additions & 2 deletions integration_test/components/common_test_constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ class CommonTestConstants {
static final String exchangeTestAmount = '0.01';
static final WalletType testWalletType = WalletType.solana;
static final String testWalletName = 'Integrated Testing Wallet';
static final CryptoCurrency testReceiveCurrency = CryptoCurrency.usdtSol;
static final CryptoCurrency testDepositCurrency = CryptoCurrency.sol;
static final CryptoCurrency sendTestReceiveCurrency = CryptoCurrency.sol;
static final CryptoCurrency exchangeTestReceiveCurrency = CryptoCurrency.usdtSol;
static final CryptoCurrency exchangeTestDepositCurrency = CryptoCurrency.sol;
static final String testWalletAddress = '5v9gTW1yWPffhnbNKuvtL2frevAf4HpBMw8oYnfqUjhm';
}
Loading
Loading