Skip to content

Commit 2c18a80

Browse files
Merge branch 'develop' into feat/swaps
2 parents 46f0731 + c28fcb9 commit 2c18a80

File tree

57 files changed

+1607
-116
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1607
-116
lines changed

.github/workflows/e2e.yml

Lines changed: 73 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,86 @@
1-
name: e2e
1+
name: E2E Tests
2+
23
on:
34
workflow_dispatch:
4-
pull_request:
5-
branches:
6-
- main
5+
workflow_call:
6+
inputs:
7+
branch:
8+
description: 'The branch to use'
9+
default: 'main'
10+
required: false
11+
type: string
12+
base-url:
13+
description: 'The AppKit App url'
14+
default: 'http://localhost:8081/'
15+
required: false
16+
type: string
17+
wallet-url:
18+
description: 'The wallet url'
19+
default: 'https://react-wallet.walletconnect.com/'
20+
required: false
21+
type: string
22+
skip_setup:
23+
description: 'Skip setup steps if already done'
24+
type: boolean
25+
default: false
26+
secrets:
27+
CLOUD_PROJECT_ID:
28+
required: true
729

830
jobs:
9-
maestro-cloud:
31+
e2e_tests:
32+
name: 'Playwright Tests'
1033
runs-on: ubuntu-latest
11-
defaults:
12-
run:
13-
working-directory: apps/native-cli
14-
outputs:
15-
app: app/build/outputs/apk/release
1634
steps:
17-
- name: Checkout
18-
uses: actions/checkout@v3
19-
20-
- name: Install Java 11
21-
uses: actions/setup-java@v3
35+
- name: checkout
36+
if: ${{ !inputs.skip_setup }}
37+
uses: actions/checkout@v4
2238
with:
23-
java-version: 11
24-
distribution: 'temurin'
25-
cache: gradle
26-
27-
- run: touch .env && echo "PROJECT_ID=${{ secrets.CLOUD_PROJECT_ID }}" >> .env
39+
repository: reown-com/appkit-react-native
40+
ref: ${{ inputs.branch }}
2841

2942
- name: Setup
43+
if: ${{ !inputs.skip_setup }}
3044
uses: ./.github/actions/setup
3145

32-
- run: yarn android:build
46+
- name: Build SDK
47+
if: ${{ !inputs.skip_setup }}
48+
run: |
49+
echo "Building SDK..."
50+
yarn build
51+
52+
- name: Create ENV file in apps/native
53+
working-directory: ./apps/native/
54+
run: echo "EXPO_PUBLIC_PROJECT_ID=${{ secrets.CLOUD_PROJECT_ID }}" >> .env
55+
56+
- name: Install Playwright Browsers
57+
working-directory: ./apps/native/
58+
run: yarn playwright install chromium
59+
60+
## Uncomment to build the web and add ./apps/native/dist to upload the artifact
61+
# - name: Build web app
62+
# working-directory: ./apps/native/
63+
# run: |
64+
# echo "Building web app..."
65+
# yarn build:web
66+
67+
- name: Run Playwright tests
68+
working-directory: ./apps/native/
69+
env:
70+
BASE_URL: ${{ inputs.base-url }}
71+
WALLET_URL: ${{ inputs.wallet-url }}
72+
73+
## Uncomment to see better logs in the terminal
74+
# DEBUG: pw:api
75+
run: |
76+
echo "Running tests against $BASE_URL"
77+
yarn playwright:test
3378
34-
- uses: mobile-dev-inc/action-maestro-cloud@v1
79+
- uses: actions/upload-artifact@v4
80+
if: failure()
3581
with:
36-
api-key: ${{ secrets.MAESTRO_CLOUD_API_KEY }}
37-
app-file: apps/native-cli/android/app/build/outputs/apk/release/app-release.apk
38-
android-api-level: 31
82+
name: playwright-report
83+
path: |
84+
./apps/native/playwright-report/
85+
./apps/native/test-results/
86+
retention-days: 7

.github/workflows/verify.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ jobs:
2222
- name: Build
2323
run: yarn build
2424

25-
- name: Test
25+
- name: Package Tests
2626
run: yarn test

.maestro/w3m-connect-flow.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ appId: com.walletconnect.web3modal.rnclisdk
99
- tapOn: 'Connect'
1010

1111
- tapOn:
12-
id: 'button-all-wallets'
12+
id: 'all-wallets'
1313

1414
- tapOn:
1515
id: 'button-qr-code'
@@ -18,7 +18,7 @@ appId: com.walletconnect.web3modal.rnclisdk
1818
id: 'qr-code'
1919

2020
- tapOn:
21-
id: 'button-copy-uri'
21+
id: 'copy-link'
2222

2323
- openLink:
2424
link: https://react-wallet.walletconnect.com/walletconnect
@@ -54,10 +54,10 @@ appId: com.walletconnect.web3modal.rnclisdk
5454
- back
5555

5656
- tapOn:
57-
id: 'button-account'
57+
id: 'account-button'
5858

5959
- tapOn:
60-
id: 'button-network'
60+
id: 'w3m-account-select-network'
6161

6262
- tapOn:
6363
text: 'Polygon'
@@ -68,7 +68,7 @@ appId: com.walletconnect.web3modal.rnclisdk
6868
text: 'Polygon'
6969

7070
- tapOn:
71-
id: 'button-disconnect'
71+
id: 'disconnect-button'
7272

7373
- assertVisible:
74-
id: 'button-connect'
74+
id: 'connect-button'

.maestro/w3m-ui-flow.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ appId: com.walletconnect.web3modal.rnclisdk
1919
id: 'button-back'
2020

2121
- tapOn:
22-
id: 'button-all-wallets'
22+
id: 'all-wallets'
2323

2424
- tapOn:
2525
id: 'button-qr-code'
@@ -31,7 +31,7 @@ appId: com.walletconnect.web3modal.rnclisdk
3131
id: 'button-back'
3232

3333
- tapOn:
34-
id: 'input-search'
34+
id: 'search-wallet-input'
3535

3636
# Get a wallet that doesn't come in the first page
3737
- inputText: 'Abra Wallet'
@@ -57,7 +57,7 @@ appId: com.walletconnect.web3modal.rnclisdk
5757
text: 'Open'
5858

5959
- tapOn:
60-
id: 'button-close'
60+
id: 'header-close'
6161

6262
- assertNotVisible:
6363
text: 'Abra Wallet'

apps/native/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ web-build/
1414
.DS_Store
1515

1616
.env
17+
/test-results/
18+
/playwright-report/
19+
/blob-report/
20+
/playwright/.cache/

apps/native/App.tsx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import { StyleSheet, View, useColorScheme } from 'react-native';
1+
import { Platform, SafeAreaView, StyleSheet, useColorScheme } from 'react-native';
22
import { StatusBar } from 'expo-status-bar';
33
import * as Clipboard from 'expo-clipboard';
44
import '@walletconnect/react-native-compat';
55
import { WagmiProvider } from 'wagmi';
66
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
7+
import Toast from 'react-native-toast-message';
78

89
import {
910
AppKit,
@@ -22,6 +23,8 @@ import { AccountView } from './src/views/AccountView';
2223
import { ActionsView } from './src/views/ActionsView';
2324
import { getCustomWallets } from './src/utils/misc';
2425
import { chains } from './src/utils/WagmiUtils';
26+
import { OpenButton } from './src/components/OpenButton';
27+
import { DisconnectButton } from './src/components/DisconnectButton';
2528

2629
const projectId = process.env.EXPO_PUBLIC_PROJECT_ID ?? '';
2730

@@ -45,11 +48,17 @@ const clipboardClient = {
4548

4649
const auth = authConnector({ projectId, metadata });
4750

51+
const extraConnectors = Platform.select({
52+
ios: [auth],
53+
android: [auth],
54+
default: []
55+
});
56+
4857
const wagmiConfig = defaultWagmiConfig({
4958
chains,
5059
projectId,
5160
metadata,
52-
extraConnectors: [auth]
61+
extraConnectors
5362
});
5463

5564
const queryClient = new QueryClient();
@@ -78,7 +87,7 @@ export default function Native() {
7887
return (
7988
<WagmiProvider config={wagmiConfig}>
8089
<QueryClientProvider client={queryClient}>
81-
<View style={[styles.container, isDarkMode && styles.dark]}>
90+
<SafeAreaView style={[styles.container, isDarkMode && styles.dark]}>
8291
<StatusBar style="auto" />
8392
<Text variant="medium-title-600" style={styles.title}>
8493
AppKit for React Native
@@ -91,10 +100,13 @@ export default function Native() {
91100
balance="show"
92101
/>
93102
<NetworkButton />
94-
<AccountView />
95103
<ActionsView />
104+
<AccountView />
105+
<OpenButton />
106+
<DisconnectButton />
96107
<AppKit />
97-
</View>
108+
</SafeAreaView>
109+
<Toast />
98110
</QueryClientProvider>
99111
</WagmiProvider>
100112
);

apps/native/app.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,12 @@
7474
}
7575
},
7676
"web": {
77-
"favicon": "./assets/favicon.png"
77+
"favicon": "./assets/favicon.png",
78+
"output": "single",
79+
"bundler": "metro"
80+
},
81+
"experiments": {
82+
"baseUrl": "."
7883
},
7984
"extra": {
8085
"eas": {

apps/native/package.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
"dev:android": "expo start --android",
1313
"eas:build": "eas build --platform all",
1414
"eas:build:local": "eas build --local --platform all",
15-
"eas:update": "eas update --branch preview"
15+
"eas:update": "eas update --branch preview",
16+
"playwright:test": "playwright test",
17+
"playwright:install": "playwright install chromium",
18+
"deploy": "gh-pages --nojekyll -d dist",
19+
"build:web": "expo export -p web"
1620
},
1721
"dependencies": {
1822
"@expo/metro-runtime": "~3.2.3",
@@ -35,6 +39,7 @@
3539
"react-native-get-random-values": "~1.11.0",
3640
"react-native-modal": "13.0.1",
3741
"react-native-svg": "15.2.0",
42+
"react-native-toast-message": "2.2.1",
3843
"react-native-web": "~0.19.10",
3944
"react-native-webview": "13.8.6",
4045
"uuid": "3.4.0",
@@ -43,9 +48,13 @@
4348
},
4449
"devDependencies": {
4550
"@babel/core": "^7.24.0",
51+
"@playwright/test": "^1.49.1",
52+
"@types/gh-pages": "^6",
53+
"@types/node": "^22.10.1",
4654
"@types/react": "~18.2.79",
4755
"@types/react-native": "0.72.2",
4856
"babel-plugin-module-resolver": "^5.0.0",
57+
"gh-pages": "^6.2.0",
4958
"typescript": "~5.3.3"
5059
}
5160
}

apps/native/playwright.config.ts

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import { defineConfig, devices } from '@playwright/test';
2+
3+
/**
4+
* Read environment variables from file.
5+
* https://github.com/motdotla/dotenv
6+
*/
7+
// import dotenv from 'dotenv';
8+
// import path from 'path';
9+
// dotenv.config({ path: path.resolve(__dirname, '.env') });
10+
11+
/**
12+
* See https://playwright.dev/docs/test-configuration.
13+
*/
14+
export default defineConfig({
15+
testDir: './tests',
16+
fullyParallel: true,
17+
/* Fail the build on CI if you accidentally left test.only in the source code. */
18+
forbidOnly: !!process.env.CI,
19+
20+
/* Retry on CI only */
21+
retries: process.env.CI ? 2 : 0,
22+
23+
/* Opt out of parallel tests on CI. */
24+
workers: process.env.CI ? 1 : undefined,
25+
26+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
27+
reporter: [['html'], ['list']],
28+
29+
use: {
30+
baseURL: process.env.BASE_URL || 'http://localhost:8081',
31+
32+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
33+
trace: 'on-first-retry',
34+
35+
/* Take a screenshot when the test fails */
36+
screenshot: 'only-on-failure',
37+
38+
permissions: ['clipboard-read', 'clipboard-write'],
39+
navigationTimeout: 30000,
40+
actionTimeout: 30000,
41+
video: 'retain-on-failure'
42+
},
43+
44+
/* Configure projects for major browsers */
45+
projects: [
46+
{
47+
name: 'chromium',
48+
use: { ...devices['Desktop Chrome'], channel: 'chromium' }
49+
}
50+
],
51+
52+
/* Run your local dev server before starting the tests */
53+
webServer: {
54+
command: 'yarn web',
55+
url: 'http://localhost:8081',
56+
reuseExistingServer: !process.env.CI,
57+
timeout: 30000
58+
59+
/* Uncomment to see better logs in the terminal */
60+
// stdout: 'pipe',
61+
// stderr: 'pipe'
62+
},
63+
64+
globalTimeout: 600000,
65+
expect: {
66+
timeout: 10000
67+
}
68+
});
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { StyleSheet } from 'react-native';
2+
import { Button } from '@reown/appkit-ui-react-native';
3+
import { useAccount, useDisconnect } from 'wagmi';
4+
5+
export function DisconnectButton() {
6+
const { isConnected } = useAccount();
7+
const { disconnect } = useDisconnect();
8+
9+
return isConnected ? (
10+
<Button testID="disconnect-hook-button" style={styles.button} onPress={() => disconnect()}>
11+
Disconnect hook
12+
</Button>
13+
) : null;
14+
}
15+
16+
const styles = StyleSheet.create({
17+
button: {
18+
height: 40,
19+
marginVertical: 8
20+
}
21+
});

0 commit comments

Comments
 (0)