diff --git a/e2e/full.test.ts b/e2e/full.test.ts index fc542d7..4e5d384 100644 --- a/e2e/full.test.ts +++ b/e2e/full.test.ts @@ -1,4 +1,7 @@ import { web, element, by, expect, waitFor, device } from 'detox'; +import { v4 as uuid } from 'uuid'; + +import type { LaunchArgs } from '../example/src/LaunchArgs'; export const sleep = async (milliseconds: number) => new Promise((resolve) => setTimeout(resolve, milliseconds)); @@ -84,18 +87,15 @@ const assertUUIDsDontChangeAfterReloadingMessages = async () => { await expect(app.usnatUUIDLabel).toHaveText(usnatUUIDBeforeReloading); }; -const launchApp = async (launchArgs = {}) => +const launchApp = async (launchArgs: LaunchArgs = {}) => device.launchApp({ newInstance: true, launchArgs: { clearData: true, ...launchArgs }, }); -beforeEach(async () => { - await launchApp(); -}); - describe('SourcepointSDK', () => { it('Accepting All, works', async () => { + await launchApp(); await app.acceptAll(); // GDPR await app.acceptAll(); // USNAT await app.forSDKToBeFinished(); @@ -105,6 +105,7 @@ describe('SourcepointSDK', () => { }); it('Rejecting All, works', async () => { + await launchApp(); await app.rejectAll(); // GDPR await app.rejectAll(); // USNAT await app.forSDKToBeFinished(); @@ -112,4 +113,20 @@ describe('SourcepointSDK', () => { await expect(app.gdprConsentStatusLabel).toHaveText('rejectedAll'); await expect(app.usnatConsentStatusLabel).toHaveText('rejectedAll'); }); + + describe('authenticated consent', () => { + describe('when authId is new', () => { + it('calling loadMessages shows a message', async () => { + await launchApp({ authId: `rn-e2e-test-${uuid()}` }); + await app.forSDKToBePresenting(); + }); + }); + + describe('when authId has consented before', () => { + it('calling loadMessages does not show a message', async () => { + await launchApp({ authId: 'rn-automated-test-accept-all' }); + await app.forSDKToBeFinished(); + }); + }); + }); }); diff --git a/package.json b/package.json index 814a34f..061341d 100644 --- a/package.json +++ b/package.json @@ -70,6 +70,7 @@ "@release-it/conventional-changelog": "^5.0.0", "@types/jest": "^29.5.5", "@types/react": "^18.2.44", + "@types/uuid": "^9.0.8", "commitlint": "^17.0.2", "del-cli": "^5.1.0", "detox": "^20.20.3", @@ -84,7 +85,8 @@ "react-native-builder-bob": "^0.23.2", "release-it": "^15.0.0", "turbo": "^1.13.3", - "typescript": "^5.2.2" + "typescript": "^5.2.2", + "uuid": "^9.0.1" }, "resolutions": { "@types/react": "^18.2.44" @@ -143,14 +145,17 @@ "trailingComma": "es5", "useTabs": false } - ] + ], + "react-hooks/exhaustive-deps": "warn" } }, "eslintIgnore": [ "node_modules/", "lib/", - "example/android/app/build", - "example/ios/Pods" + "android/build/", + "example/android/app/build/", + "example/ios/Pods/", + "example/ios/build/" ], "prettier": { "quoteProps": "consistent", diff --git a/yarn.lock b/yarn.lock index 3e91f6d..ef20d26 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3180,6 +3180,7 @@ __metadata: "@release-it/conventional-changelog": ^5.0.0 "@types/jest": ^29.5.5 "@types/react": ^18.2.44 + "@types/uuid": ^9.0.8 commitlint: ^17.0.2 del-cli: ^5.1.0 detox: ^20.20.3 @@ -3195,6 +3196,7 @@ __metadata: release-it: ^15.0.0 turbo: ^1.13.3 typescript: ^5.2.2 + uuid: ^9.0.1 peerDependencies: react: "*" react-native: "*" @@ -3437,6 +3439,13 @@ __metadata: languageName: node linkType: hard +"@types/uuid@npm:^9.0.8": + version: 9.0.8 + resolution: "@types/uuid@npm:9.0.8" + checksum: b8c60b7ba8250356b5088302583d1704a4e1a13558d143c549c408bf8920535602ffc12394ede77f8a8083511b023704bc66d1345792714002bfa261b17c5275 + languageName: node + linkType: hard + "@types/yargs-parser@npm:*": version: 21.0.3 resolution: "@types/yargs-parser@npm:21.0.3" @@ -13801,6 +13810,15 @@ __metadata: languageName: node linkType: hard +"uuid@npm:^9.0.1": + version: 9.0.1 + resolution: "uuid@npm:9.0.1" + bin: + uuid: dist/bin/uuid + checksum: 39931f6da74e307f51c0fb463dc2462807531dc80760a9bff1e35af4316131b4fc3203d16da60ae33f07fdca5b56f3f1dd662da0c99fea9aaeab2004780cc5f4 + languageName: node + linkType: hard + "v8-compile-cache-lib@npm:^3.0.1": version: 3.0.1 resolution: "v8-compile-cache-lib@npm:3.0.1"