Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ To run example app with local `react-native-radar` dependency:
- build native app using expo pre-build and `react-native-plugin` with `npm run install-radar-rebuild`.
- run iOS and android example app with `npx expo run:ios` or `npx expo run:android`.

### Example app tests

If needed, install `maestro` with
```
brew tap mobile-dev-inc/tap
brew install maestro
```

Then, run tests with `maestro test example_tests.yaml`. from `/example/maestro` dir.




## Support

Expand Down
31 changes: 29 additions & 2 deletions example/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState, useEffect } from "react";
import { StyleSheet, Text, View, ScrollView, Platform } from "react-native";
import { StyleSheet, Text, View, ScrollView, Platform, TextInput } from "react-native";
import Radar, { Map, Autocomplete, RadarClientLocationUpdate, RadarLocationUpdate, RadarEventUpdate } from "react-native-radar";
import MapLibreGL from "@maplibre/maplibre-react-native";
import ExampleButton from "./components/exampleButton";
Expand Down Expand Up @@ -32,11 +32,12 @@ Radar.on("log", (result: string) => {
export default function App() {
// add in your test code here!
const [displayText, setDisplayText] = useState("");
const [publishableKey, setPublishableKey] = useState("");

const handlePopulateText = (displayText: string) => {
setDisplayText(displayText);
};
Radar.initialize("prj_test_pk_0000000000000000000000000000000000000000", true);
//Radar.initialize("prj_test_pk_0000000000000000000000000000000000000000", true);

useEffect(() => {
Radar.setLogLevel("debug");
Expand Down Expand Up @@ -77,6 +78,32 @@ export default function App() {
<Text style={styles.displayText}>{displayText}</Text>
</ScrollView>
<ScrollView style={{ height: "75%" }}>
<TextInput
id="publishableKeyInput"
value={publishableKey}
onChangeText={(text) => setPublishableKey(text)}
placeholder="Enter publishable key"
style={{ height: 40, borderColor: 'gray', borderWidth: 1, margin: 10, padding: 5 }}
/>
<ExampleButton
title="initialize"
onPress={() => {
Radar.initialize(publishableKey, true);

}}
/>
<ExampleButton
title="trackOnce"
onPress={() => {
Radar.trackOnce()
.then((result) => {
handlePopulateText("trackOnce:" + stringify(result));
})
.catch((err) => {
handlePopulateText("trackOnce:" + err);
});
}}
/>
<ExampleButton
title="getUser"
onPress={() => {
Expand Down
12 changes: 9 additions & 3 deletions example/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
],
"ios": {
"supportsTablet": true,
"bundleIdentifier": "com.radar.example",
"bundleIdentifier": "com.radar.rnexample"
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#ffffff"
},
"package": "com.radar.example"
"package": "com.radar.rnexample"
},
"web": {
"favicon": "./assets/favicon.png"
Expand Down Expand Up @@ -55,6 +55,12 @@
}
}
]
]
],
"extra": {
"eas": {
"projectId": "caf6acc9-b3c5-4d95-af29-fd017a05abb8"
}
},
"owner": "radarlabs"
}
}
21 changes: 21 additions & 0 deletions example/eas.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"cli": {
"version": ">= 14.0.2",
"appVersionSource": "remote"
},
"build": {
"development": {
"developmentClient": true,
"distribution": "internal"
},
"preview": {
"distribution": "internal"
},
"production": {
"autoIncrement": true
}
},
"submit": {
"production": {}
}
}
19 changes: 19 additions & 0 deletions example/maestro/example_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
appId: com.radar.rnexample
---
- launchApp
- assertVisible: 'getUser'
- tapOn: "Enter publishable key"
- inputText:
text: '${MAESTRO_RADAR_PUBLISHABLE_KEY}'
- hideKeyboard
- tapOn:
text: 'Initialize'
- setLocation:
latitude: 52.3599976
longitude: 4.8830301
- tapOn:
text: 'trackOnce'
- extendedWaitUntil:
visible: '.*SUCCESS.*'
timeout: 10000 # Timeout in milliseconds