Skip to content

Commit

Permalink
[MOB-9505] rename merge parameter (#450)
Browse files Browse the repository at this point in the history
* [MOB-9505] rename merge parameter

* fix ci failure and resolved comment

* fix: ci failure and merged AUT_main changes
  • Loading branch information
darshan-iterable authored Sep 17, 2024
1 parent 8f6e6a7 commit c9a304a
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 73 deletions.
62 changes: 32 additions & 30 deletions src/anonymousUserTracking/tests/userMergeScenarios.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ describe('UserMergeScenariosTests', () => {
});

describe('UserMergeScenariosTests with setUserID', () => {
it('criteria not met with merge false with setUserId', async () => {
it('criteria not met with disableEventReplay true with setUserId', async () => {
const { setUserID, logout } = initializeWithConfig({
authToken: '123',
configOptions: { enableAnonTracking: true }
Expand All @@ -142,7 +142,7 @@ describe('UserMergeScenariosTests', () => {
SHARED_PREFS_EVENT_LIST_KEY,
expect.any(String)
);
await setUserID('testuser123', false);
await setUserID('testuser123', true);
const response = await getInAppMessages({
count: 10,
packageName: 'my-lil-website'
Expand All @@ -160,7 +160,7 @@ describe('UserMergeScenariosTests', () => {
expect(mergePostRequestData).toBeUndefined(); // ensure that merge API Do NOT get called
});

it('criteria not met with merge true with setUserId', async () => {
it('criteria not met with disableEventReplay false with setUserId', async () => {
const { setUserID, logout } = initializeWithConfig({
authToken: '123',
configOptions: { enableAnonTracking: true }
Expand All @@ -175,7 +175,7 @@ describe('UserMergeScenariosTests', () => {
SHARED_PREFS_EVENT_LIST_KEY,
expect.any(String)
);
await setUserID('testuser123', true);
await setUserID('testuser123', false);
const response = await getInAppMessages({
count: 10,
packageName: 'my-lil-website'
Expand All @@ -193,7 +193,7 @@ describe('UserMergeScenariosTests', () => {
expect(mergePostRequestData).toBeUndefined(); // ensure that merge API Do NOT get called
});

it('criteria not met with merge default value with setUserId', async () => {
it('criteria not met with disableEventReplay default value with setUserId', async () => {
const { setUserID, logout } = initializeWithConfig({
authToken: '123',
configOptions: { enableAnonTracking: true }
Expand Down Expand Up @@ -226,7 +226,7 @@ describe('UserMergeScenariosTests', () => {
expect(mergePostRequestData).toBeUndefined(); // ensure that merge API Do NOT get called
});

it('criteria is met with merge false with setUserId', async () => {
it('criteria is met with disableEventReplay true with setUserId', async () => {
(localStorage.getItem as jest.Mock).mockImplementation((key) => {
if (key === SHARED_PREFS_EVENT_LIST_KEY) {
return JSON.stringify([eventDataMatched]);
Expand All @@ -247,7 +247,7 @@ describe('UserMergeScenariosTests', () => {
} catch (e) {
console.log('');
}
await setUserID('testuser123', false);
await setUserID('testuser123', true);
expect(localStorageMock.removeItem).toHaveBeenCalledWith(
SHARED_PREF_ANON_USER_ID
);
Expand All @@ -262,7 +262,7 @@ describe('UserMergeScenariosTests', () => {
expect(mergePostRequestData).toBeUndefined(); // ensure that merge API Do NOT get called
});

it('criteria is met with merge true with setUserId', async () => {
it('criteria is met with disableEventReplay false with setUserId', async () => {
(localStorage.getItem as jest.Mock).mockImplementation((key) => {
if (key === SHARED_PREFS_EVENT_LIST_KEY) {
return JSON.stringify([eventDataMatched]);
Expand All @@ -288,7 +288,7 @@ describe('UserMergeScenariosTests', () => {
count: 10,
packageName: 'my-lil-website'
});
await setUserID('testuser123', true);
await setUserID('testuser123', false);
expect(localStorageMock.removeItem).toHaveBeenCalledWith(
SHARED_PREF_ANON_USER_ID
);
Expand All @@ -302,7 +302,7 @@ describe('UserMergeScenariosTests', () => {
jest.runAllTimers();
});

it('criteria is met with merge default with setUserId', async () => {
it('criteria is met with disableEventReplay default with setUserId', async () => {
(localStorage.getItem as jest.Mock).mockImplementation((key) => {
if (key === SHARED_PREFS_EVENT_LIST_KEY) {
return JSON.stringify([eventDataMatched]);
Expand Down Expand Up @@ -343,7 +343,7 @@ describe('UserMergeScenariosTests', () => {
jest.runAllTimers();
});

it('current user identified with setUserId merge false', async () => {
it('current user identified with setUserId disableEventReplay true', async () => {
const { setUserID, logout } = initializeWithConfig({
authToken: '123',
configOptions: { enableAnonTracking: true }
Expand All @@ -363,7 +363,7 @@ describe('UserMergeScenariosTests', () => {
expect(localStorageMock.setItem).not.toHaveBeenCalledWith(
SHARED_PREF_ANON_USER_ID
);
await setUserID('testuseranotheruser', false);
await setUserID('testuseranotheruser', true);
const secondResponse = await getInAppMessages({
count: 10,
packageName: 'my-lil-website'
Expand All @@ -374,7 +374,8 @@ describe('UserMergeScenariosTests', () => {
);
expect(mergePostRequestData).toBeUndefined(); // ensure that merge API Do NOT get called
});
it('current user identified with setUserId merge true', async () => {

it('current user identified with setUserId disableEventReplay false', async () => {
const { setUserID, logout } = initializeWithConfig({
authToken: '123',
configOptions: { enableAnonTracking: true }
Expand All @@ -389,7 +390,7 @@ describe('UserMergeScenariosTests', () => {
expect(localStorageMock.setItem).not.toHaveBeenCalledWith(
SHARED_PREF_ANON_USER_ID
);
await setUserID('testuseranotheruser', true);
await setUserID('testuseranotheruser', false);
const secondResponse = await getInAppMessages({
count: 10,
packageName: 'my-lil-website'
Expand All @@ -400,7 +401,8 @@ describe('UserMergeScenariosTests', () => {
);
expect(mergePostRequestData).toBeDefined(); // ensure that merge API gets called
});
it('current user identified with setUserId merge default', async () => {

it('current user identified with setUserId disableEventReplay default', async () => {
const { setUserID, logout } = initializeWithConfig({
authToken: '123',
configOptions: { enableAnonTracking: true }
Expand All @@ -424,12 +426,12 @@ describe('UserMergeScenariosTests', () => {
const mergePostRequestData = mockRequest.history.post.find(
(req) => req.url === ENDPOINT_MERGE_USER
);
expect(mergePostRequestData).toBeUndefined(); // ensure that merge API Do NOT get called
expect(mergePostRequestData).toBeDefined(); // ensure that merge API gets called
});
});

describe('UserMergeScenariosTests with setEmail', () => {
it('criteria not met with merge false with setEmail', async () => {
it('criteria not met with disableEventReplay true with setEmail', async () => {
const { setEmail, logout } = initializeWithConfig({
authToken: '123',
configOptions: { enableAnonTracking: true }
Expand All @@ -444,7 +446,7 @@ describe('UserMergeScenariosTests', () => {
SHARED_PREFS_EVENT_LIST_KEY,
expect.any(String)
);
await setEmail('[email protected]', false);
await setEmail('[email protected]', true);
const response = await getInAppMessages({
count: 10,
packageName: 'my-lil-website'
Expand All @@ -462,7 +464,7 @@ describe('UserMergeScenariosTests', () => {
expect(mergePostRequestData).toBeUndefined(); // ensure that merge API Do NOT get called
});

it('criteria not met with merge true with setEmail', async () => {
it('criteria not met with disableEventReplay false with setEmail', async () => {
const { setEmail, logout } = initializeWithConfig({
authToken: '123',
configOptions: { enableAnonTracking: true }
Expand All @@ -477,7 +479,7 @@ describe('UserMergeScenariosTests', () => {
SHARED_PREFS_EVENT_LIST_KEY,
expect.any(String)
);
await setEmail('[email protected]', true);
await setEmail('[email protected]', false);
const response = await getInAppMessages({
count: 10,
packageName: 'my-lil-website'
Expand All @@ -495,7 +497,7 @@ describe('UserMergeScenariosTests', () => {
expect(mergePostRequestData).toBeUndefined(); // ensure that merge API Do NOT get called
});

it('criteria not met with merge default value with setEmail', async () => {
it('criteria not met with disableEventReplay default value with setEmail', async () => {
const { setEmail, logout } = initializeWithConfig({
authToken: '123',
configOptions: { enableAnonTracking: true }
Expand Down Expand Up @@ -528,7 +530,7 @@ describe('UserMergeScenariosTests', () => {
expect(mergePostRequestData).toBeUndefined(); // ensure that merge API Do NOT get called
});

it('criteria is met with merge true with setEmail', async () => {
it('criteria is met with disableEventReplay false with setEmail', async () => {
(localStorage.getItem as jest.Mock).mockImplementation((key) => {
if (key === SHARED_PREFS_EVENT_LIST_KEY) {
return JSON.stringify([eventDataMatched]);
Expand All @@ -553,7 +555,7 @@ describe('UserMergeScenariosTests', () => {
count: 10,
packageName: 'my-lil-website'
});
await setEmail('[email protected]', true);
await setEmail('[email protected]', false);
expect(localStorageMock.removeItem).toHaveBeenCalledWith(
SHARED_PREF_ANON_USER_ID
);
Expand All @@ -567,7 +569,7 @@ describe('UserMergeScenariosTests', () => {
jest.runAllTimers();
});

it('criteria is met with merge default with setEmail', async () => {
it('criteria is met with disableEventReplay default with setEmail', async () => {
(localStorage.getItem as jest.Mock).mockImplementation((key) => {
if (key === SHARED_PREFS_EVENT_LIST_KEY) {
return JSON.stringify([eventDataMatched]);
Expand Down Expand Up @@ -608,7 +610,7 @@ describe('UserMergeScenariosTests', () => {
jest.runAllTimers();
});

it('current user identified with setEmail with merge false', async () => {
it('current user identified with setEmail with disableEventReplay true', async () => {
const { setEmail, logout } = initializeWithConfig({
authToken: '123',
configOptions: { enableAnonTracking: true }
Expand All @@ -628,7 +630,7 @@ describe('UserMergeScenariosTests', () => {
expect(localStorageMock.setItem).not.toHaveBeenCalledWith(
SHARED_PREF_ANON_USER_ID
);
await setEmail('[email protected]', false);
await setEmail('[email protected]', true);
const secondResponse = await getInAppMessages({
count: 10,
packageName: 'my-lil-website'
Expand All @@ -642,7 +644,7 @@ describe('UserMergeScenariosTests', () => {
expect(mergePostRequestData).toBeUndefined(); // ensure that merge API Do NOT get called
});

it('current user identified with setEmail merge true', async () => {
it('current user identified with setEmail disableEventReplay false', async () => {
const { setEmail, logout } = initializeWithConfig({
authToken: '123',
configOptions: { enableAnonTracking: true }
Expand All @@ -662,7 +664,7 @@ describe('UserMergeScenariosTests', () => {
expect(localStorageMock.setItem).not.toHaveBeenCalledWith(
SHARED_PREF_ANON_USER_ID
);
await setEmail('[email protected]', true);
await setEmail('[email protected]', false);
const secondResponse = await getInAppMessages({
count: 10,
packageName: 'my-lil-website'
Expand All @@ -676,7 +678,7 @@ describe('UserMergeScenariosTests', () => {
expect(mergePostRequestData).toBeDefined(); // ensure that merge API gets called
});

it('current user identified with setEmail merge default', async () => {
it('current user identified with setEmail disableEventReplay default', async () => {
const { setEmail, logout } = initializeWithConfig({
authToken: '123',
configOptions: { enableAnonTracking: true }
Expand Down Expand Up @@ -707,7 +709,7 @@ describe('UserMergeScenariosTests', () => {
const mergePostRequestData = mockRequest.history.post.find(
(req) => req.url === ENDPOINT_MERGE_USER
);
expect(mergePostRequestData).toBeUndefined(); // ensure that merge API Do NOT get called
expect(mergePostRequestData).toBeDefined(); // ensure that merge API gets called
});
});
});
Loading

0 comments on commit c9a304a

Please sign in to comment.