Skip to content

Commit 97245f2

Browse files
committed
chore: apply expo plugin and secrets
1 parent 13835ec commit 97245f2

File tree

7 files changed

+48
-7
lines changed

7 files changed

+48
-7
lines changed

e2e-tests/helpers/driver.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ function getConfig() {
2020

2121
async function createDriver() {
2222
const config = getConfig();
23-
const { isAndroid, androidAppPackage, androidAppActivity, iosBundleId, iosUdid } = config;
23+
const {
24+
isAndroid,
25+
androidAppPackage,
26+
androidAppActivity,
27+
iosBundleId,
28+
iosUdid,
29+
} = config;
2430

2531
const connectionRetryTimeout = isAndroid ? 240000 : 600000;
2632
const connectionRetryCount = isAndroid ? 3 : 5;

e2e-tests/run-appium.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ const { testDropInButtonVisible } = require('./tests/dropin-visible.test');
66
const { driver, config } = await createDriver();
77
const { isAndroid } = config;
88

9-
console.log(`\n==> [Test] Running tests on ${isAndroid ? 'Android' : 'iOS'}...`);
9+
console.log(
10+
`\n==> [Test] Running tests on ${isAndroid ? 'Android' : 'iOS'}...`
11+
);
1012

1113
try {
1214
await testDropInButtonVisible(driver, isAndroid);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
echo "== Add @adyen/react-native plugin to app.json"
6+
7+
# Add the plugin to the plugins array in app.json
8+
if grep -q '"plugins"' app.json; then
9+
# If plugins array exists, add to it
10+
sed -i.bak 's/"plugins": \[/"plugins": [\n "@adyen\/react-native",/' app.json && rm -f app.json.bak
11+
else
12+
# If plugins array doesn't exist, create it
13+
sed -i.bak 's/"expo": {/"expo": {\n "plugins": [\n "@adyen\/react-native"\n ],/' app.json && rm -f app.json.bak
14+
fi

e2e-tests/scripts/inject_secrets.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,20 @@ fi
1010

1111
echo "== Injecting Secrets"
1212

13+
# Determine the secrets file location based on project type
14+
if [ -f "secrets.js" ]; then
15+
SECRETS_FILE="secrets.js"
16+
elif [ -f "app/(tabs)/secrets.js" ]; then
17+
SECRETS_FILE="app/(tabs)/secrets.js"
18+
else
19+
echo "Error: Could not find secrets.js"
20+
exit 1
21+
fi
22+
23+
echo "Injecting secrets into $SECRETS_FILE"
24+
1325
# We use '#' as delimiter, so secrets can safely contain '|'.
1426
# Keys are expected to only contain [a-zA-Z0-9_|], so no extra escaping is needed.
1527
sed -e "s#__CLIENT_KEY__#${ADYEN_CLIENT_KEY}#g" \
1628
-e "s#__PUBLIC_KEY__#${ADYEN_PUBLIC_KEY}#g" \
17-
App.tsx > App.tsx.tmp && mv App.tsx.tmp App.tsx
29+
"$SECRETS_FILE" > "$SECRETS_FILE.tmp" && mv "$SECRETS_FILE.tmp" "$SECRETS_FILE"

e2e-tests/scripts/setup.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,14 @@ cp -r ../e2e-tests/helpers ./
3939
cp -r ../e2e-tests/tests ./
4040
cp ../e2e-tests/scripts/*.sh ./
4141

42-
if ["$platform" == "Expo"]; then
42+
if [ "$platform" == "Expo" ]; then
4343
echo "== Add default index.tsx"
44-
cp ../e2e-tests/template/App.tsx.template app/(tabs)/index.tsx
44+
cp ../e2e-tests/template/App.tsx.template "app/(tabs)/index.tsx"
45+
cp ../e2e-tests/template/secrets.js.template "app/(tabs)/secrets.js"
46+
47+
bash ./add-expo-plugin.sh
4548
else
4649
echo "== Add default App.tsx"
4750
cp ../e2e-tests/template/App.tsx.template App.tsx
51+
cp ../e2e-tests/template/secrets.js.template secrets.js
4852
fi

e2e-tests/template/App.tsx.template

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ import {
1717
useColorScheme,
1818
View,
1919
} from 'react-native';
20+
import { ADYEN_CLIENT_KEY, ADYEN_PUBLIC_KEY } from './secrets';
2021

2122
const configuration: Configuration = {
2223
returnUrl: 'myapp://payment',
2324
environment: 'test',
24-
clientKey: '__CLIENT_KEY__',
25+
clientKey: ADYEN_CLIENT_KEY,
2526
card: {
2627
holderNameRequired: true,
2728
},
@@ -117,7 +118,7 @@ const MyCheckoutView = () => {
117118
onPress={async () => {
118119
let result = await AdyenCSE.encryptBin(
119120
'545454545454',
120-
'__PUBLIC_KEY__'
121+
ADYEN_PUBLIC_KEY
121122
);
122123
console.log(result);
123124
}}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export const ADYEN_CLIENT_KEY = '__CLIENT_KEY__';
2+
export const ADYEN_PUBLIC_KEY = '__PUBLIC_KEY__';

0 commit comments

Comments
 (0)