Skip to content

Commit ef2fe3c

Browse files
feat: implement authId tests
1 parent 47c4a07 commit ef2fe3c

File tree

3 files changed

+49
-9
lines changed

3 files changed

+49
-9
lines changed

e2e/full.test.ts

+22-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import { web, element, by, expect, waitFor, device } from 'detox';
2+
import { v4 as uuid } from 'uuid';
3+
4+
import type { LaunchArgs } from '../example/src/LaunchArgs';
25

36
export const sleep = async (milliseconds: number) =>
47
new Promise((resolve) => setTimeout(resolve, milliseconds));
@@ -84,18 +87,15 @@ const assertUUIDsDontChangeAfterReloadingMessages = async () => {
8487
await expect(app.usnatUUIDLabel).toHaveText(usnatUUIDBeforeReloading);
8588
};
8689

87-
const launchApp = async (launchArgs = {}) =>
90+
const launchApp = async (launchArgs: LaunchArgs = {}) =>
8891
device.launchApp({
8992
newInstance: true,
9093
launchArgs: { clearData: true, ...launchArgs },
9194
});
9295

93-
beforeEach(async () => {
94-
await launchApp();
95-
});
96-
9796
describe('SourcepointSDK', () => {
9897
it('Accepting All, works', async () => {
98+
await launchApp();
9999
await app.acceptAll(); // GDPR
100100
await app.acceptAll(); // USNAT
101101
await app.forSDKToBeFinished();
@@ -105,11 +105,28 @@ describe('SourcepointSDK', () => {
105105
});
106106

107107
it('Rejecting All, works', async () => {
108+
await launchApp();
108109
await app.rejectAll(); // GDPR
109110
await app.rejectAll(); // USNAT
110111
await app.forSDKToBeFinished();
111112
await assertUUIDsDontChangeAfterReloadingMessages();
112113
await expect(app.gdprConsentStatusLabel).toHaveText('rejectedAll');
113114
await expect(app.usnatConsentStatusLabel).toHaveText('rejectedAll');
114115
});
116+
117+
describe('authenticated consent', () => {
118+
describe('when authId is new', () => {
119+
it('calling loadMessages shows a message', async () => {
120+
await launchApp({ authId: `rn-e2e-test-${uuid()}` });
121+
await app.forSDKToBePresenting();
122+
});
123+
});
124+
125+
describe('when authId has consented before', () => {
126+
it('calling loadMessages does not show a message', async () => {
127+
await launchApp({ authId: 'rn-automated-test-accept-all' });
128+
await app.forSDKToBeFinished();
129+
});
130+
});
131+
});
115132
});

package.json

+9-4
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
"@release-it/conventional-changelog": "^5.0.0",
7171
"@types/jest": "^29.5.5",
7272
"@types/react": "^18.2.44",
73+
"@types/uuid": "^9.0.8",
7374
"commitlint": "^17.0.2",
7475
"del-cli": "^5.1.0",
7576
"detox": "^20.20.3",
@@ -84,7 +85,8 @@
8485
"react-native-builder-bob": "^0.23.2",
8586
"release-it": "^15.0.0",
8687
"turbo": "^1.13.3",
87-
"typescript": "^5.2.2"
88+
"typescript": "^5.2.2",
89+
"uuid": "^9.0.1"
8890
},
8991
"resolutions": {
9092
"@types/react": "^18.2.44"
@@ -143,14 +145,17 @@
143145
"trailingComma": "es5",
144146
"useTabs": false
145147
}
146-
]
148+
],
149+
"react-hooks/exhaustive-deps": "warn"
147150
}
148151
},
149152
"eslintIgnore": [
150153
"node_modules/",
151154
"lib/",
152-
"example/android/app/build",
153-
"example/ios/Pods"
155+
"android/build/",
156+
"example/android/app/build/",
157+
"example/ios/Pods/",
158+
"example/ios/build/"
154159
],
155160
"prettier": {
156161
"quoteProps": "consistent",

yarn.lock

+18
Original file line numberDiff line numberDiff line change
@@ -3180,6 +3180,7 @@ __metadata:
31803180
"@release-it/conventional-changelog": ^5.0.0
31813181
"@types/jest": ^29.5.5
31823182
"@types/react": ^18.2.44
3183+
"@types/uuid": ^9.0.8
31833184
commitlint: ^17.0.2
31843185
del-cli: ^5.1.0
31853186
detox: ^20.20.3
@@ -3195,6 +3196,7 @@ __metadata:
31953196
release-it: ^15.0.0
31963197
turbo: ^1.13.3
31973198
typescript: ^5.2.2
3199+
uuid: ^9.0.1
31983200
peerDependencies:
31993201
react: "*"
32003202
react-native: "*"
@@ -3437,6 +3439,13 @@ __metadata:
34373439
languageName: node
34383440
linkType: hard
34393441

3442+
"@types/uuid@npm:^9.0.8":
3443+
version: 9.0.8
3444+
resolution: "@types/uuid@npm:9.0.8"
3445+
checksum: b8c60b7ba8250356b5088302583d1704a4e1a13558d143c549c408bf8920535602ffc12394ede77f8a8083511b023704bc66d1345792714002bfa261b17c5275
3446+
languageName: node
3447+
linkType: hard
3448+
34403449
"@types/yargs-parser@npm:*":
34413450
version: 21.0.3
34423451
resolution: "@types/yargs-parser@npm:21.0.3"
@@ -13801,6 +13810,15 @@ __metadata:
1380113810
languageName: node
1380213811
linkType: hard
1380313812

13813+
"uuid@npm:^9.0.1":
13814+
version: 9.0.1
13815+
resolution: "uuid@npm:9.0.1"
13816+
bin:
13817+
uuid: dist/bin/uuid
13818+
checksum: 39931f6da74e307f51c0fb463dc2462807531dc80760a9bff1e35af4316131b4fc3203d16da60ae33f07fdca5b56f3f1dd662da0c99fea9aaeab2004780cc5f4
13819+
languageName: node
13820+
linkType: hard
13821+
1380413822
"v8-compile-cache-lib@npm:^3.0.1":
1380513823
version: 3.0.1
1380613824
resolution: "v8-compile-cache-lib@npm:3.0.1"

0 commit comments

Comments
 (0)