Skip to content

Commit 7387ee2

Browse files
committed
refactor(appium): shorten test data keys and values
refactor(appium): shorten test input values refactor(appium): shorten externalId format
1 parent 34c52dd commit 7387ee2

9 files changed

Lines changed: 129 additions & 103 deletions

File tree

‎appium/package.json‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
{
22
"name": "@onesignal/appium-e2e",
3+
"private": true,
4+
"description": "Shared Appium E2E tests for OneSignal SDK wrappers",
5+
"type": "module",
6+
"scripts": {
7+
"format": "vp check --fix",
8+
"test:android": "wdio run wdio.android.conf.ts",
9+
"test:ios": "wdio run wdio.ios.conf.ts"
10+
},
311
"devDependencies": {
412
"@types/node": "^25.6.2",
513
"@wdio/browserstack-service": "^9.27.1",
@@ -13,17 +21,9 @@
1321
"vite-plus": "0.1.22",
1422
"webdriverio": "^9.27.1"
1523
},
16-
"description": "Shared Appium E2E tests for OneSignal SDK wrappers",
1724
"overrides": {
1825
"vite": "npm:@voidzero-dev/vite-plus-core@0.1.22",
1926
"vitest": "npm:@voidzero-dev/vite-plus-test@0.1.22"
2027
},
21-
"packageManager": "bun@1.3.14",
22-
"private": true,
23-
"scripts": {
24-
"format": "vp check --fix",
25-
"test:android": "wdio run wdio.android.conf.ts",
26-
"test:ios": "wdio run wdio.ios.conf.ts"
27-
},
28-
"type": "module"
28+
"packageManager": "bun@1.3.14"
2929
}

‎appium/tests/helpers/app.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,7 @@ async function expandNotificationRow(title: string): Promise<void> {
348348

349349
// Last resort: pinch-open the row near its title.
350350
const row = await $(`${titleXpath}/ancestor::android.widget.FrameLayout[1]`);
351-
const target = (await row.isDisplayed().catch(() => false))
352-
? row
353-
: await $(titleXpath);
351+
const target = (await row.isDisplayed().catch(() => false)) ? row : await $(titleXpath);
354352
if (!(await target.isDisplayed().catch(() => false))) return;
355353
await driver
356354
.execute('mobile: pinchOpenGesture', {

‎appium/tests/helpers/selectors.ts‎

Lines changed: 53 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -25,86 +25,104 @@ export function getPlatform(): Platform {
2525
export function getTestExternalId(): string {
2626
const sdk = getSdkType();
2727
const platform = getPlatform();
28-
if (sdk === platform) return `appium-${sdk}`;
29-
return `appium-${sdk}-${platform}`;
28+
if (sdk === platform) return sdk;
29+
return `${sdk}-${platform}`;
3030
}
3131

32-
const TEST_DATA: Record<string, { sms: string; email: string; customEvent: string }> = {
33-
'appium-flutter-ios': {
32+
export const TEST_DATA: Record<
33+
string,
34+
{ sms: string; email: string; customEvent: string; alias: string }
35+
> = {
36+
'flutter-ios': {
3437
sms: '+12003004000',
35-
email: 'flutter-ios@test.com',
36-
customEvent: 'flutter_ios',
38+
email: 'fl-i@os.co',
39+
customEvent: 'flutter-ios',
40+
alias: 'fl-i',
3741
},
38-
'appium-flutter-android': {
42+
'flutter-android': {
3943
sms: '+12003004001',
40-
email: 'flutter-android@test.com',
44+
email: 'fl-a@os.co',
4145
customEvent: 'flutter_android',
46+
alias: 'fl-a',
4247
},
43-
'appium-react-native-ios': {
48+
'react-native-ios': {
4449
sms: '+12003004002',
45-
email: 'rn-ios@test.com',
50+
email: 'rn-i@os.co',
4651
customEvent: 'rn_ios',
52+
alias: 'rn-i',
4753
},
48-
'appium-react-native-android': {
54+
'react-native-android': {
4955
sms: '+12003004003',
50-
email: 'rn-android@test.com',
56+
email: 'rn-a@os.co',
5157
customEvent: 'rn_android',
58+
alias: 'rn-a',
5259
},
53-
'appium-capacitor-ios': {
60+
'capacitor-ios': {
5461
sms: '+12003004004',
55-
email: 'capacitor-ios@test.com',
62+
email: 'cap-i@os.co',
5663
customEvent: 'capacitor_ios',
64+
alias: 'cap-i',
5765
},
58-
'appium-capacitor-android': {
66+
'capacitor-android': {
5967
sms: '+12003004005',
60-
email: 'capacitor-android@test.com',
68+
email: 'cap-a@os.co',
6169
customEvent: 'capacitor_android',
70+
alias: 'cap-a',
6271
},
63-
'appium-cordova-ios': {
72+
'cordova-ios': {
6473
sms: '+12003004006',
65-
email: 'cordova-ios@test.com',
74+
email: 'co-i@os.co',
6675
customEvent: 'cordova_ios',
76+
alias: 'co-i',
6777
},
68-
'appium-cordova-android': {
78+
'cordova-android': {
6979
sms: '+12003004007',
70-
email: 'cordova-android@test.com',
80+
email: 'co-a@os.co',
7181
customEvent: 'cordova_android',
82+
alias: 'co-a',
7283
},
73-
'appium-unity-ios': {
84+
'unity-ios': {
7485
sms: '+12003004008',
75-
email: 'unity-ios@test.com',
86+
email: 'un-i@os.co',
7687
customEvent: 'unity_ios',
88+
alias: 'un-i',
7789
},
78-
'appium-unity-android': {
90+
'unity-android': {
7991
sms: '+12003004009',
80-
email: 'unity-android@test.com',
92+
email: 'un-a@os.co',
8193
customEvent: 'unity_android',
94+
alias: 'un-a',
8295
},
83-
'appium-dotnet-ios': {
96+
'dotnet-ios': {
8497
sms: '+12003004010',
85-
email: 'dotnet-ios@test.com',
98+
email: 'dn-i@os.co',
8699
customEvent: 'dotnet_ios',
100+
alias: 'dn-i',
87101
},
88-
'appium-dotnet-android': {
102+
'dotnet-android': {
89103
sms: '+12003004011',
90-
email: 'dotnet-android@test.com',
104+
email: 'dn-a@os.co',
91105
customEvent: 'dotnet_android',
106+
alias: 'dn-a',
92107
},
93-
'appium-expo-ios': {
108+
'expo-ios': {
94109
sms: '+12003004012',
95-
email: 'expo-ios@test.com',
110+
email: 'ex-i@os.co',
96111
customEvent: 'expo_ios',
112+
alias: 'ex-i',
97113
},
98-
'appium-expo-android': {
114+
'expo-android': {
99115
sms: '+12003004013',
100-
email: 'expo-android@test.com',
116+
email: 'ex-a@os.co',
101117
customEvent: 'expo_android',
118+
alias: 'ex-a',
102119
},
103-
'appium-ios': { sms: '+12003004014', email: 'ios@test.com', customEvent: 'ios' },
104-
'appium-android': {
120+
ios: { sms: '+12003004014', email: 'ios@os.co', customEvent: 'ios', alias: 'ios' },
121+
android: {
105122
sms: '+12003004015',
106-
email: 'android@test.com',
123+
email: 'and@os.co',
107124
customEvent: 'android',
125+
alias: 'and',
108126
},
109127
};
110128

‎appium/tests/specs/04_alias.spec.ts‎

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,19 @@ import {
66
scrollToEl,
77
waitForAppReady,
88
} from '../helpers/app';
9-
import { byTestId } from '../helpers/selectors.js';
9+
import { byTestId, getTestData, TEST_DATA } from '../helpers/selectors.js';
1010

1111
describe('Aliases', () => {
1212
before(async () => {
13+
// check that all aliases are unique since we want to avoid 409 conflicts
14+
const aliases = Object.values(TEST_DATA)
15+
.map((data) => data.alias)
16+
.concat('iam_type');
17+
const uniqueAliases = [...new Set(aliases)];
18+
if (uniqueAliases.length !== aliases.length) {
19+
throw new Error('Aliases are not unique');
20+
}
21+
1322
await waitForAppReady();
1423
await scrollToEl('aliases_section');
1524
});
@@ -23,40 +32,44 @@ describe('Aliases', () => {
2332
});
2433

2534
it('can add an alias', async () => {
35+
const { alias } = getTestData();
36+
const labelValue = `${alias}1`;
2637
const labelInput = await openModal('add_alias_button', 'alias_label_input');
27-
await labelInput.setValue('test_label');
38+
await labelInput.setValue(labelValue);
2839

40+
const idValue = 'id1';
2941
const idInput = await byTestId('alias_id_input');
30-
await idInput.setValue('test_id');
42+
await idInput.setValue(idValue);
3143

3244
await confirmModal('singlepair_confirm_button');
3345

34-
await expectPairInSection('aliases', 'test_label', 'test_id');
46+
await expectPairInSection('aliases', labelValue, idValue);
3547
});
3648

3749
it('can add multiple aliases', async () => {
50+
const { alias } = getTestData();
3851
const addRowButton = await openModal('add_multiple_aliases_button', 'multipair_add_row_button');
3952
await addRowButton.click();
4053

4154
const label0 = await byTestId('multipair_key_0');
42-
await label0.setValue('test_label_2');
55+
await label0.setValue(`${alias}2`);
4356

4457
const id0 = await byTestId('multipair_value_0');
4558
await id0.waitForDisplayed({ timeout: 5_000 });
46-
await id0.setValue('test_id_2');
59+
await id0.setValue('id2');
4760

4861
const label1 = await byTestId('multipair_key_1');
4962
await label1.waitForDisplayed({ timeout: 5_000 });
50-
await label1.setValue('test_label_3');
63+
await label1.setValue(`${alias}3`);
5164

5265
const id1 = await byTestId('multipair_value_1');
5366
await id1.waitForDisplayed({ timeout: 5_000 });
54-
await id1.setValue('test_id_3');
67+
await id1.setValue('id3');
5568

5669
await confirmModal('multipair_confirm_button');
5770

5871
await scrollToEl('aliases_section', { direction: 'up' });
59-
await expectPairInSection('aliases', 'test_label_2', 'test_id_2');
60-
await expectPairInSection('aliases', 'test_label_3', 'test_id_3');
72+
await expectPairInSection('aliases', `${alias}2`, 'id2');
73+
await expectPairInSection('aliases', `${alias}3`, 'id3');
6174
});
6275
});

‎appium/tests/specs/07_tag.spec.ts‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,55 +25,55 @@ describe('Tags', () => {
2525

2626
it('can add and remove a tag', async () => {
2727
const keyInput = await openModal('add_tag_button', 'tag_key_input');
28-
await keyInput.setValue('test_tag');
28+
await keyInput.setValue('tag0');
2929

3030
const valueInput = await byTestId('tag_value_input');
31-
await valueInput.setValue('test_tag_value');
31+
await valueInput.setValue('val0');
3232

3333
await confirmModal('singlepair_confirm_button');
3434

35-
await expectPairInSection('tags', 'test_tag', 'test_tag_value');
35+
await expectPairInSection('tags', 'tag0', 'val0');
3636

3737
// remove tag
38-
const removeButton = await byTestId(`tags_remove_test_tag`);
38+
const removeButton = await byTestId(`tags_remove_tag0`);
3939
await removeButton.click();
4040

41-
await waitForDisappear('tags_pair_key_test_tag');
41+
await waitForDisappear('tags_pair_key_tag0');
4242
});
4343

4444
it('can add and remove multiple tags', async () => {
4545
const key0 = await openModal('add_multiple_tags_button', 'multipair_key_0');
46-
await key0.setValue('test_tag_2');
46+
await key0.setValue('tag2');
4747

4848
const value0 = await byTestId('multipair_value_0');
49-
await value0.setValue('test_tag_value_2');
49+
await value0.setValue('val2');
5050

5151
const addRowButton = await byTestId('multipair_add_row_button');
5252
await addRowButton.click();
5353

5454
const key1 = await byTestId('multipair_key_1');
5555
await key1.waitForDisplayed({ timeout: 5_000 });
56-
await key1.setValue('test_tag_3');
56+
await key1.setValue('tag3');
5757

5858
const value1 = await byTestId('multipair_value_1');
59-
await value1.setValue('test_tag_value_3');
59+
await value1.setValue('val3');
6060

6161
await confirmModal('multipair_confirm_button');
6262

63-
await expectPairInSection('tags', 'test_tag_2', 'test_tag_value_2');
64-
await expectPairInSection('tags', 'test_tag_3', 'test_tag_value_3');
63+
await expectPairInSection('tags', 'tag2', 'val2');
64+
await expectPairInSection('tags', 'tag3', 'val3');
6565

66-
const tag2Checkbox = await openModal('remove_tags_button', 'remove_checkbox_test_tag_2');
66+
const tag2Checkbox = await openModal('remove_tags_button', 'remove_checkbox_tag2');
6767
await tag2Checkbox.click();
6868

69-
const tag3Checkbox = await byTestId('remove_checkbox_test_tag_3');
69+
const tag3Checkbox = await byTestId('remove_checkbox_tag3');
7070
await tag3Checkbox.click();
7171

7272
await confirmModal('multiselect_confirm_button');
7373

7474
// wait for tags to be removed
7575
await scrollToEl('tags_section', { direction: 'up' });
76-
await waitForDisappear('tags_pair_key_test_tag_2');
77-
await waitForDisappear('tags_pair_key_test_tag_3');
76+
await waitForDisappear('tags_pair_key_tag2');
77+
await waitForDisappear('tags_pair_key_tag3');
7878
});
7979
});

‎appium/tests/specs/08_outcome.spec.ts‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,35 +20,35 @@ describe('Outcomes', () => {
2020
it('can send a normal outcome', async () => {
2121
const normalRadio = await openModal('send_outcome_button', 'outcome_type_normal_radio');
2222
await normalRadio.click();
23-
23+
2424
const nameInput = await byTestId('outcome_name_input');
25-
await nameInput.setValue('test_normal');
25+
await nameInput.setValue('normal');
2626

2727
const sendBtn = await byTestId('outcome_send_button');
2828
await sendBtn.click();
2929

30-
await expectSnackbar('Outcome sent: test_normal');
30+
await expectSnackbar('Outcome sent: normal');
3131
});
3232

3333
it('can send a unique outcome', async () => {
3434
const uniqueRadio = await openModal('send_outcome_button', 'outcome_type_unique_radio');
3535
await uniqueRadio.click();
36-
36+
3737
const nameInput = await byTestId('outcome_name_input');
38-
await nameInput.setValue('test_unique');
38+
await nameInput.setValue('unique');
3939

4040
const sendBtn = await byTestId('outcome_send_button');
4141
await sendBtn.click();
4242

43-
await expectSnackbar('Unique outcome sent: test_unique');
43+
await expectSnackbar('Unique outcome sent: unique');
4444
});
4545

4646
it('can send an outcome with value', async () => {
4747
const withValueRadio = await openModal('send_outcome_button', 'outcome_type_value_radio');
4848
await withValueRadio.click();
4949

5050
const nameInput = await byTestId('outcome_name_input');
51-
await nameInput.setValue('test_valued');
51+
await nameInput.setValue('valued');
5252

5353
const valueInput = await byTestId('outcome_value_input');
5454
await valueInput.waitForDisplayed({ timeout: 5_000 });
@@ -57,6 +57,6 @@ describe('Outcomes', () => {
5757
const sendBtn = await byTestId('outcome_send_button');
5858
await sendBtn.click();
5959

60-
await expectSnackbar('Outcome sent: test_valued = 3.14');
60+
await expectSnackbar('Outcome sent: valued = 3.14');
6161
});
6262
});

0 commit comments

Comments
 (0)