Skip to content

Commit 4321687

Browse files
committed
[NT-1691] Adding react-native implementation and detox tests
1 parent 1ef1544 commit 4321687

77 files changed

Lines changed: 17698 additions & 53 deletions

File tree

Some content is hidden

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

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,19 @@ temp
2323
test-results
2424
tmp
2525

26+
# Build artifacts that shouldn't be in src directories
27+
**/src/**/*.js
28+
**/src/**/*.js.map
29+
**/src/**/*.d.ts.map
30+
31+
# But allow config files
32+
!**/*.config.js
33+
!**/babel.config.js
34+
!**/metro.config.js
35+
!**/jest.config.js
36+
!**/webpack.config.js
37+
!**/rollup.config.js
38+
39+
# React Native implementation uses npm (excluded from pnpm workspace)
40+
# Don't ignore package-lock.json in implementations/react-native
41+
!implementations/react-native/package-lock.json

implementations/node/package.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,8 @@
77
"types": "dist/app.d.ts",
88
"scripts": {
99
"clean": "rimraf ./coverage ./playwright-report ./test-results",
10-
"serve": "pnpm serve:mocks && pnpm serve:app",
11-
"serve:app": "pm2 start \"tsx --env-file=.env ./src/app.ts\"",
12-
"serve:mocks": "pm2 start \"pnpm --filter mocks mocks:serve\"",
13-
"serve:stop": "pm2 stop all && pm2 delete all",
14-
"test:e2e": "pnpm serve && playwright test; E2E_RESULT=$?; pnpm serve:stop; exit $E2E_RESULT",
10+
"serve": "tsx --env-file=.env ./src/app.ts",
11+
"test:e2e": "playwright test",
1512
"test:e2e:codegen": "playwright codegen",
1613
"test:e2e:report": "playwright show-report",
1714
"test:e2e:ui": "playwright test --ui",
@@ -31,7 +28,6 @@
3128
"@types/supertest": "6.0.3",
3229
"@vitest/coverage-v8": "catalog:",
3330
"dotenv": "catalog:",
34-
"pm2": "catalog:",
3531
"rimraf": "catalog:",
3632
"supertest": "7.1.3",
3733
"tsx": "catalog:",

implementations/node/playwright.config.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ export default defineConfig({
7272
],
7373

7474
/* Run your local dev server before starting the tests */
75-
// webServer: {
76-
// command: 'pnpm --filter e2e mocks:serve',
77-
// url: 'http://localhost',
78-
// reuseExistingServer: !isCI,
79-
// },
75+
webServer: {
76+
command: 'pnpm --filter "@implementation/node" serve',
77+
url: 'http://localhost:3000',
78+
reuseExistingServer: !isCI,
79+
},
8080
})

implementations/node/tsconfig.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
"noEmit": false,
88
"outDir": "./dist",
99
"paths": {
10-
"@contentful/optimization-api-client": ["../../platforms/javascript/api-client/src/index.ts"],
11-
"@contentful/optimization-api-schemas": [
12-
"../../platforms/javascript/api-schemas/src/index.ts"
13-
],
1410
"@contentful/optimization-core": ["../../platforms/javascript/core/src/index.ts"],
1511
"@contentful/optimization-node": ["../../platforms/javascript/node/src/index.ts"]
1612
},

implementations/node/vitest.config.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
import { resolve } from 'node:path'
1+
import path from 'node:path'
22
import { defineConfig } from 'vitest/config'
33

44
export default defineConfig({
55
resolve: {
66
alias: {
7-
'@contentful/optimization-api-client': resolve(
7+
'@contentful/optimization-core': path.resolve(
88
__dirname,
9-
'../../platforms/javascript/api-client/src/',
9+
'../../platforms/javascript/core/src/',
1010
),
11-
'@contentful/optimization-api-schemas': resolve(
11+
'@contentful/optimization-node': path.resolve(
1212
__dirname,
13-
'../../platforms/javascript/api-schemas/src/',
13+
'../../platforms/javascript/node/src/',
1414
),
15-
'@contentful/optimization-core': resolve(__dirname, '../../platforms/javascript/core/src/'),
16-
'@contentful/optimization-node': resolve(__dirname, '../../platforms/javascript/node/src/'),
1715
},
1816
},
1917
test: {
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BUNDLE_PATH: "vendor/bundle"
2+
BUNDLE_FORCE_RUBY_PLATFORM: 1
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/** @type {Detox.DetoxConfig} */
2+
module.exports = {
3+
testRunner: {
4+
args: {
5+
$0: 'jest',
6+
config: 'e2e/jest.config.js',
7+
},
8+
jest: {
9+
setupTimeout: 120000,
10+
},
11+
},
12+
apps: {
13+
'ios.debug': {
14+
type: 'ios.app',
15+
binaryPath:
16+
'ios/build/Build/Products/Debug-iphonesimulator/ReactNativeApp.app',
17+
build:
18+
'xcodebuild -workspace ios/ReactNativeApp.xcworkspace -scheme ReactNativeApp -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build',
19+
},
20+
'ios.release': {
21+
type: 'ios.app',
22+
binaryPath:
23+
'ios/build/Build/Products/Release-iphonesimulator/ReactNativeApp.app',
24+
build:
25+
'xcodebuild -workspace ios/ReactNativeApp.xcworkspace -scheme ReactNativeApp -configuration Release -sdk iphonesimulator -derivedDataPath ios/build',
26+
},
27+
'android.debug': {
28+
type: 'android.apk',
29+
binaryPath: 'android/app/build/outputs/apk/debug/app-debug.apk',
30+
build:
31+
'cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug',
32+
reversePorts: [8081],
33+
},
34+
'android.release': {
35+
type: 'android.apk',
36+
binaryPath: 'android/app/build/outputs/apk/release/app-release.apk',
37+
build:
38+
'cd android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release',
39+
},
40+
},
41+
devices: {
42+
simulator: {
43+
type: 'ios.simulator',
44+
device: {
45+
type: 'iPhone 15 Pro',
46+
},
47+
},
48+
emulator: {
49+
type: 'android.emulator',
50+
device: {
51+
avdName: 'Pixel_7_API_34',
52+
},
53+
},
54+
},
55+
configurations: {
56+
'ios.sim.debug': {
57+
device: 'simulator',
58+
app: 'ios.debug',
59+
},
60+
'ios.sim.release': {
61+
device: 'simulator',
62+
app: 'ios.release',
63+
},
64+
'android.emu.debug': {
65+
device: 'emulator',
66+
app: 'android.debug',
67+
},
68+
'android.emu.release': {
69+
device: 'emulator',
70+
app: 'android.release',
71+
},
72+
},
73+
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
root: true,
3+
extends: '@react-native',
4+
};
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# OSX
2+
#
3+
.DS_Store
4+
5+
# Xcode
6+
#
7+
build/
8+
*.pbxuser
9+
!default.pbxuser
10+
*.mode1v3
11+
!default.mode1v3
12+
*.mode2v3
13+
!default.mode2v3
14+
*.perspectivev3
15+
!default.perspectivev3
16+
xcuserdata
17+
*.xccheckout
18+
*.moved-aside
19+
DerivedData
20+
*.hmap
21+
*.ipa
22+
*.xcuserstate
23+
**/.xcode.env.local
24+
25+
# Android/IntelliJ
26+
#
27+
build/
28+
.idea
29+
.gradle
30+
local.properties
31+
*.iml
32+
*.hprof
33+
.cxx/
34+
*.keystore
35+
!debug.keystore
36+
37+
# node.js
38+
#
39+
node_modules/
40+
npm-debug.log
41+
yarn-error.log
42+
43+
# fastlane
44+
#
45+
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
46+
# screenshots whenever they are needed.
47+
# For more information about the recommended setup visit:
48+
# https://docs.fastlane.tools/best-practices/source-control/
49+
50+
**/fastlane/report.xml
51+
**/fastlane/Preview.html
52+
**/fastlane/screenshots
53+
**/fastlane/test_output
54+
55+
# Bundle artifact
56+
*.jsbundle
57+
58+
# Ruby / CocoaPods
59+
**/Pods/
60+
/vendor/bundle/
61+
62+
# Temporary files created by Metro to check the health of the file watcher
63+
.metro-health-check*
64+
65+
# testing
66+
/coverage
67+
68+
# Yarn
69+
.yarn/*
70+
!.yarn/patches
71+
!.yarn/plugins
72+
!.yarn/releases
73+
!.yarn/sdks
74+
!.yarn/versions
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
arrowParens: 'avoid',
3+
bracketSameLine: true,
4+
bracketSpacing: false,
5+
singleQuote: true,
6+
trailingComma: 'all',
7+
};

0 commit comments

Comments
 (0)