Skip to content

Commit

Permalink
ci: add E2E RN 0.73 (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
oscb committed Dec 7, 2023
1 parent f91b56d commit dd257e4
Show file tree
Hide file tree
Showing 72 changed files with 15,270 additions and 1 deletion.
2 changes: 2 additions & 0 deletions examples/E2E-73/.bundle/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BUNDLE_PATH: "vendor/bundle"
BUNDLE_FORCE_RUBY_PLATFORM: 1
93 changes: 93 additions & 0 deletions examples/E2E-73/.detoxrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/** @type {Detox.DetoxConfig} */
module.exports = {
testRunner: {
args: {
'$0': 'jest',
config: 'e2e/jest.config.js'
},
jest: {
setupTimeout: 120000
}
},
behavior: {
init: {
reinstallApp: true,
exposeGlobals: false
},
launchApp: "auto",
cleanup: {
shutdownDevice: false
}
},
apps: {
'ios.debug': {
type: 'ios.app',
binaryPath: 'ios/build/Build/Products/Debug-iphonesimulator/AnalyticsReactNativeE2E.app',
build: 'xcodebuild -workspace ios/AnalyticsReactNativeE2E.xcworkspace -scheme AnalyticsReactNativeE2E -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build'
},
'ios.release': {
type: 'ios.app',
binaryPath: 'ios/build/Build/Products/Release-iphonesimulator/AnalyticsReactNativeE2E.app',
build: 'xcodebuild -workspace ios/AnalyticsReactNativeE2E.xcworkspace -scheme AnalyticsReactNativeE2E -configuration Release -sdk iphonesimulator -derivedDataPath ios/build'
},
'android.debug': {
type: 'android.apk',
binaryPath: 'android/app/build/outputs/apk/debug/app-debug.apk',
build: 'cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug',
reversePorts: [
8081
]
},
'android.release': {
type: 'android.apk',
binaryPath: 'android/app/build/outputs/apk/release/app-release.apk',
build: 'cd android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release'
}
},
devices: {
simulator: {
type: 'ios.simulator',
device: {
type: 'iPhone 14'
}
},
attached: {
type: 'android.attached',
device: {
adbName: '.*'
}
},
emulator: {
type: 'android.emulator',
device: {
avdName: 'Pixel_3a_API_32'
}
}
},
configurations: {
'ios.sim.debug': {
device: 'simulator',
app: 'ios.debug'
},
'ios.sim.release': {
device: 'simulator',
app: 'ios.release'
},
'android.att.debug': {
device: 'attached',
app: 'android.debug'
},
'android.att.release': {
device: 'attached',
app: 'android.release'
},
'android.emu.debug': {
device: 'emulator',
app: 'android.debug'
},
'android.emu.release': {
device: 'emulator',
app: 'android.release'
}
}
};
4 changes: 4 additions & 0 deletions examples/E2E-73/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
root: true,
extends: '@react-native',
};
66 changes: 66 additions & 0 deletions examples/E2E-73/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# OSX
#
.DS_Store

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
ios/.xcode.env.local

# Android/IntelliJ
#
build/
.idea
.gradle
local.properties
*.iml
*.hprof
.cxx/
*.keystore
!debug.keystore

# node.js
#
node_modules/
npm-debug.log
yarn-error.log

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/

**/fastlane/report.xml
**/fastlane/Preview.html
**/fastlane/screenshots
**/fastlane/test_output

# Bundle artifact
*.jsbundle

# Ruby / CocoaPods
/ios/Pods/
/vendor/bundle/

# Temporary files created by Metro to check the health of the file watcher
.metro-health-check*

# testing
/coverage
7 changes: 7 additions & 0 deletions examples/E2E-73/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
arrowParens: 'avoid',
bracketSameLine: true,
bracketSpacing: false,
singleQuote: true,
trailingComma: 'all',
};
2 changes: 2 additions & 0 deletions examples/E2E-73/.rtx.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tools]
java = "zulu-17"
1 change: 1 addition & 0 deletions examples/E2E-73/.watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
175 changes: 175 additions & 0 deletions examples/E2E-73/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
import 'react-native-gesture-handler';
import * as React from 'react';
// import RNBootSplash from 'react-native-bootsplash';
import {
NavigationContainer,
NavigationState,
PartialState,
} from '@react-navigation/native';
import {createStackNavigator} from '@react-navigation/stack';
import {
createClient,
AnalyticsProvider,
CountFlushPolicy,
// @ts-ignore unused for e2e tests
// StartupFlushPolicy,
// @ts-ignore unused for e2e tests
// TimerFlushPolicy,
} from '@segment/analytics-react-native';
import Home from './Home';
import SecondPage from './SecondPage';
import Modal from './Modal';
import {useState} from 'react';
import {Logger} from './plugins/Logger';
import {Platform} from 'react-native';

// import {AmplitudeSessionPlugin} from '@segment/analytics-react-native-plugin-amplitude-session';
// import { ConsentManager } from './plugins/ConsentManager';
// import { FirebasePlugin } from '@segment/analytics-react-native-plugin-firebase';
// import { FacebookAppEventsPlugin } from '@segment/analytics-react-native-plugin-facebook-app-events';
// import { IdfaPlugin } from '@segment/analytics-react-native-plugin-idfa';
// import { AdvertisingIdPlugin } from '@segment/analytics-react-native-plugin-advertising-id';
// import { ClevertapPlugin } from '@segment/analytics-react-native-plugin-clevertap';
// import { BrazePlugin } from '@segment/analytics-react-native-plugin-braze';

const segmentClient = createClient({
writeKey: 'yup',
maxBatchSize: 1000,
trackDeepLinks: true,
trackAppLifecycleEvents: true,
autoAddSegmentDestination: true,
collectDeviceId: true,
debug: true,
flushPolicies: [
new CountFlushPolicy(5),
// These are disabled for E2E tests
// new TimerFlushPolicy(1000),
// new StartupFlushPolicy(),
],
proxy: Platform.select({
ios: 'http://localhost:9091/events',
android: 'http://10.0.2.2:9091/events',
}),
cdnProxy: Platform.select({
ios: 'http://localhost:9091/settings',
android: 'http://10.0.2.2:9091/settings',
}),
});

const LoggerPlugin = new Logger();

segmentClient.add({plugin: LoggerPlugin});

// To see an example Consent Manager uncomment the following
// const ConsentManagerPlugin = new ConsentManager();
// segmentClient.add({ plugin: ConsentManagerPlugin });

// To test the Firebase plugin make sure to add your own API_KEY in example/ios/GoogleService-Info.plist
// segmentClient.add({ plugin: new FirebasePlugin() });

// To test the Facebook App Events plugin make sure to add your Facebook App Id to Info.plist
// segmentClient.add({ plugin: new FacebookAppEventsPlugin() });
// const idfaPlugin = new IdfaPlugin();
// segmentClient.add({ plugin: idfaPlugin });

// segmentClient.add({plugin: new AmplitudeSessionPlugin()});

// segmentClient.add({ plugin: new BrazePlugin() });

// segmentClient.add({ plugin: new ClevertapPlugin() });

// segmentClient.add({
// plugin: new AdvertisingIdPlugin(),
// });

const MainStack = createStackNavigator();
const RootStack = createStackNavigator();
function MainStackScreen() {
return (
<MainStack.Navigator
screenOptions={{
headerStyle: {
backgroundColor: '#262e4f',
},
headerTintColor: '#fff',
headerTitleStyle: {
fontWeight: 'bold',
},
}}>
<MainStack.Screen
name="Home"
component={Home}
options={{headerShown: false}}
/>
<MainStack.Screen
name="SecondPage"
component={SecondPage}
options={{title: 'Second Page'}}
/>
</MainStack.Navigator>
);
}

const getActiveRouteName = (
state: NavigationState | PartialState<NavigationState> | undefined,
): string => {
if (!state || typeof state.index !== 'number') {
return 'Unknown';
}

const route = state.routes[state.index];

if (route.state) {
return getActiveRouteName(route.state);
}

return route.name;
};

const App = () => {
// React.useEffect(() => {
// void RNBootSplash.hide();
// }, []);

const [routeName, setRouteName] = useState('Unknown');

return (
<AnalyticsProvider client={segmentClient}>
<NavigationContainer
onStateChange={state => {
const newRouteName = getActiveRouteName(state);

if (routeName !== newRouteName) {
void segmentClient.screen(newRouteName);

setRouteName(newRouteName);
}
}}>
<RootStack.Navigator
screenOptions={{
headerStyle: {
backgroundColor: '#262e4f',
},
headerTintColor: '#fff',
headerTitleStyle: {
fontWeight: 'bold',
},
presentation: 'modal',
}}>
<RootStack.Screen
name="Main"
component={MainStackScreen}
options={{headerShown: false}}
/>
<RootStack.Screen
name="Modal"
component={Modal}
options={{headerBackTitle: 'Go back'}}
/>
</RootStack.Navigator>
</NavigationContainer>
</AnalyticsProvider>
);
};

export default App;
7 changes: 7 additions & 0 deletions examples/E2E-73/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
source 'https://rubygems.org'

# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
ruby ">= 2.6.10"

gem 'cocoapods', '~> 1.13'
gem 'activesupport', '>= 6.1.7.3', '< 7.1.0'
Loading

0 comments on commit dd257e4

Please sign in to comment.