Skip to content

Commit 3e7bc62

Browse files
committed
feat: add suite selector to test app
1 parent a939675 commit 3e7bc62

File tree

9 files changed

+40
-23
lines changed

9 files changed

+40
-23
lines changed

test/app/e2e-tests-config.js

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

test/app/e2e/jest.config.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
1-
const { suite } = require('../e2e-tests-config.js');
2-
3-
const suiteFiles = suite === 'preflight' ? [
4-
'preflightTest',
5-
] : [
6-
'call', 'callMessage', 'registration', 'voice',
7-
];
8-
9-
const testMatch = suiteFiles.map((f) => `<rootDir>/e2e/suites/${f}.test.ts`);
10-
111
/** @type {import('@jest/types').Config.InitialOptions} */
122
module.exports = {
133
rootDir: '..',
14-
testMatch,
4+
testMatch: ['<rootDir>/e2e/suites/**/preflightTest.test.ts'],
155
testTimeout: 120000,
166
maxWorkers: 1,
177
globalSetup: 'detox/runners/jest/globalSetup',

test/app/e2e/suites/call.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ describe('call', () => {
2525

2626
beforeEach(async () => {
2727
await device.reloadReactNative();
28+
await element(by.text('CALL SUITE')).tap();
2829
});
2930

3031
if (device.getPlatform() === 'ios') {
@@ -77,7 +78,7 @@ describe('call', () => {
7778
log.includes('constant-audio-output-level');
7879

7980
return qualityWarningsChangedEvent && (constantAudioInputWarning || constantAudioOutputWarning);
80-
}
81+
};
8182

8283
// check the call quality warnings every 5 seconds
8384
// for a total of 30 seconds

test/app/e2e/suites/callMessage.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { bootstrapTwilioClient } from '../common/twilioClient';
66
import { pollValidateLog, getRegExpMatch } from '../common/logParser';
77

88
const DEFAULT_TIMEOUT = 10000;
9-
const RELAY_SERVER_URL = 'http://localhost:4040'
9+
const RELAY_SERVER_URL = 'http://localhost:4040';
1010

1111
describe('call', () => {
1212
let twilioClient: ReturnType<typeof twilio>;
@@ -187,6 +187,7 @@ describe('call', () => {
187187

188188
beforeEach(async () => {
189189
await device.reloadReactNative();
190+
await element(by.text('CALL SUITE')).tap();
190191

191192
if (device.getPlatform() !== 'ios') {
192193
await toggleLogFormat();

test/app/e2e/suites/preflightTest.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ describe('preflightTest', () => {
198198
describe('successful flow', () => {
199199
beforeAll(async () => {
200200
await device.reloadReactNative();
201+
await element(by.text('PREFLIGHT TEST SUITE')).tap();
201202
await element(by.text('TOGGLE LOG FORMAT')).tap();
202203

203204
await element(by.text('START PREFLIGHT')).tap();
@@ -323,6 +324,7 @@ describe('preflightTest', () => {
323324
describe('failure flow', () => {
324325
beforeEach(async () => {
325326
await device.reloadReactNative();
327+
await element(by.text('PREFLIGHT TEST SUITE')).tap();
326328
await element(by.text('TOGGLE LOG FORMAT')).tap();
327329
});
328330

@@ -426,6 +428,7 @@ describe('preflightTest', () => {
426428
describe('stopped preflightTest', () => {
427429
beforeAll(async () => {
428430
await device.reloadReactNative();
431+
await element(by.text('PREFLIGHT TEST SUITE')).tap();
429432
await element(by.text('TOGGLE LOG FORMAT')).tap();
430433

431434
await element(by.text('START PREFLIGHT')).tap();
@@ -502,6 +505,7 @@ describe('preflightTest', () => {
502505
describe('invalid token preflightTest', () => {
503506
beforeAll(async () => {
504507
await device.reloadReactNative();
508+
await element(by.text('PREFLIGHT TEST SUITE')).tap();
505509
await element(by.text('TOGGLE LOG FORMAT')).tap();
506510

507511
await element(by.text('START PREFLIGHT')).tap();
@@ -581,6 +585,7 @@ describe('preflightTest', () => {
581585

582586
beforeAll(async () => {
583587
await device.reloadReactNative();
588+
await element(by.text('PREFLIGHT TEST SUITE')).tap();
584589
await element(by.text('TOGGLE LOG FORMAT')).tap();
585590

586591
startTime = Date.now();

test/app/e2e/suites/registration.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ describe('registration', () => {
1616

1717
beforeEach(async () => {
1818
await device.reloadReactNative();
19+
await element(by.text('CALL SUITE')).tap();
1920
});
2021

2122
it('should start unregistered', async () => {

test/app/e2e/suites/voice.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ describe('voice', () => {
88

99
beforeEach(async () => {
1010
await device.reloadReactNative();
11+
await element(by.text('CALL SUITE')).tap();
1112
});
1213

1314
it('should show a valid SDK version', async () => {

test/app/src/App.tsx

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,34 @@
11
import * as React from 'react';
2-
import { DefaultSuite } from './DefaultSuite';
2+
import { Button, View } from 'react-native';
3+
import { CallSuite } from './CallSuite';
34
import { PreflightTestSuite } from './PreflightTestSuite';
45

5-
const { suite } = require('../e2e-tests-config.js');
6+
const defaultSuite = 'none';
67

78
export default function App() {
8-
switch (suite as string) {
9-
case 'preflightTest':
10-
return <PreflightTestSuite />;
11-
default:
12-
return <DefaultSuite />;
9+
const [selectedSuite, setSelectedSuite] =
10+
React.useState<'call' | 'preflightTest' | 'none'>(defaultSuite);
11+
12+
const suiteSelector = React.useMemo(() => {
13+
return (
14+
<View>
15+
<Button onPress={() => setSelectedSuite('call')} title="Call Suite" />
16+
<Button onPress={() => setSelectedSuite('preflightTest')} title="Preflight Test Suite" />
17+
</View>
18+
);
19+
}, []);
20+
21+
if (selectedSuite === 'none') {
22+
return suiteSelector;
23+
}
24+
25+
if (selectedSuite === 'call') {
26+
return <CallSuite />;
1327
}
28+
29+
if (selectedSuite === 'preflightTest') {
30+
return <PreflightTestSuite />;
31+
}
32+
33+
return null;
1434
}

test/app/src/DefaultSuite.tsx renamed to test/app/src/CallSuite.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ if (!token.length) {
2020
token = generateAccessToken();
2121
}
2222

23-
export function DefaultSuite() {
23+
export function CallSuite() {
2424
const {
2525
registered,
2626
sdkVersion,

0 commit comments

Comments
 (0)