Skip to content

Commit 39144b5

Browse files
illuminati1911jokerttu
authored andcommitted
test: initial integration testing screen in example app
1 parent fb28908 commit 39144b5

File tree

6 files changed

+410
-30
lines changed

6 files changed

+410
-30
lines changed

example/e2e/navigation.test.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/**
2+
* Copyright 2024 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import {
18+
initializeIntegrationTestsPage,
19+
agreeToTermsAndConditions,
20+
waitForStepNumber,
21+
selectTestByName,
22+
waitForTestToFinish,
23+
} from './shared.js';
24+
import { element, by } from 'detox';
25+
26+
describe('Initialization tests', () => {
27+
beforeEach(async () => {
28+
await initializeIntegrationTestsPage();
29+
});
30+
31+
it('T01 - initialize navigation controller and test terms and conditions (TOS) dialog acceptance', async () => {
32+
await selectTestByName('testNavigationSessionInitialization');
33+
await waitForStepNumber(1);
34+
await agreeToTermsAndConditions();
35+
await waitForTestToFinish();
36+
await expect(element(by.id('test_result_label'))).toHaveText(
37+
'Test result: Success'
38+
);
39+
});
40+
41+
/**
42+
it('T01 - check navigation controller defaults', async () => {
43+
await element(by.text('Tests')).tap();
44+
await element(by.text('testNavigationSessionInitialization')).tap();
45+
// await waitFor(element(by.text('Test status: Step #1')))
46+
// .toBeVisible()
47+
// .withTimeout(10000);
48+
await waitFor(element(by.id('test_status_label')))
49+
.toHaveText('Test status: Step #1')
50+
.withTimeout(10000);
51+
await agreeToTC();
52+
await waitFor(element(by.text('Test status: Success')))
53+
.toBeVisible()
54+
.withTimeout(10000);
55+
});
56+
*/
57+
});

example/e2e/navigation_ui.test.js

Lines changed: 0 additions & 28 deletions
This file was deleted.

example/e2e/shared.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,39 @@ export const initializeNavigationPage = async () => {
3232
await element(by.text('GOT IT')).tap();
3333
}
3434
};
35+
36+
export const agreeToTermsAndConditions = async () => {
37+
if (device.getPlatform() === 'ios') {
38+
await waitFor(element(by.text("YES, I'M IN")))
39+
.toBeVisible()
40+
.withTimeout(10000);
41+
await element(by.text("YES, I'M IN")).tap();
42+
} else if (device.getPlatform() === 'android') {
43+
await waitFor(element(by.text('GOT IT')))
44+
.toBeVisible()
45+
.withTimeout(10000);
46+
await element(by.text('GOT IT')).tap();
47+
}
48+
};
49+
50+
export const waitForStepNumber = async number => {
51+
await waitFor(element(by.id('test_status_label')))
52+
.toHaveText(`Test status: Step #${number}`)
53+
.withTimeout(10000);
54+
};
55+
56+
export const waitForTestToFinish = async () => {
57+
await waitFor(element(by.id('test_status_label')))
58+
.toHaveText(`Test status: Finished`)
59+
.withTimeout(10000);
60+
};
61+
62+
export const initializeIntegrationTestsPage = async () => {
63+
await device.launchApp({ newInstance: true });
64+
await element(by.text('Integration Tests')).tap();
65+
};
66+
67+
export const selectTestByName = async name => {
68+
await element(by.text('Tests')).tap();
69+
await element(by.text(name)).tap();
70+
};

example/src/App.tsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,14 @@ import {
3030
TaskRemovedBehavior,
3131
type TermsAndConditionsDialogOptions,
3232
} from '@googlemaps/react-native-navigation-sdk';
33+
import IntegrationTestsScreen from './screens/IntegrationTestsScreen';
3334

34-
export type ScreenNames = ['Home', 'Navigation', 'Multiple maps'];
35+
export type ScreenNames = [
36+
'Home',
37+
'Navigation',
38+
'Multiple maps',
39+
'Integration tests',
40+
];
3541

3642
export type RootStackParamList = Record<ScreenNames[number], undefined>;
3743
export type StackNavigation = NavigationProp<RootStackParamList>;
@@ -41,7 +47,7 @@ const HomeScreen = () => {
4147
const isFocused = useIsFocused();
4248

4349
return (
44-
<View style={styles.container}>
50+
<View style={[styles.container]}>
4551
<View style={styles.buttonContainer}>
4652
<Button
4753
title="Navigation"
@@ -54,6 +60,12 @@ const HomeScreen = () => {
5460
onPress={() => isFocused && navigate('Multiple maps')}
5561
/>
5662
</View>
63+
<View style={styles.buttonContainer}>
64+
<Button
65+
title="Integration Tests"
66+
onPress={() => isFocused && navigate('Integration tests')}
67+
/>
68+
</View>
5769
</View>
5870
);
5971
};
@@ -81,6 +93,10 @@ export default function App() {
8193
<Stack.Screen name="Home" component={HomeScreen} />
8294
<Stack.Screen name="Navigation" component={NavigationScreen} />
8395
<Stack.Screen name="Multiple maps" component={MultipleMapsScreen} />
96+
<Stack.Screen
97+
name="Integration tests"
98+
component={IntegrationTestsScreen}
99+
/>
84100
</Stack.Navigator>
85101
</NavigationContainer>
86102
</NavigationProvider>

0 commit comments

Comments
 (0)