Skip to content

Commit

Permalink
feat: implement authId tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andresilveirah committed May 31, 2024
1 parent 47c4a07 commit ef2fe3c
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 9 deletions.
27 changes: 22 additions & 5 deletions e2e/full.test.ts
Original file line number Diff line number Diff line change
@@ -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));
Expand Down Expand Up @@ -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();
Expand All @@ -105,11 +105,28 @@ describe('SourcepointSDK', () => {
});

it('Rejecting All, works', async () => {
await launchApp();
await app.rejectAll(); // GDPR
await app.rejectAll(); // USNAT
await app.forSDKToBeFinished();
await assertUUIDsDontChangeAfterReloadingMessages();
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();
});
});
});
});
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
Expand Down Expand Up @@ -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",
Expand Down
18 changes: 18 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: "*"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit ef2fe3c

Please sign in to comment.