Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Remove usages of Persistence First/Last Seen Times #876

Open
wants to merge 2 commits into
base: refactor/SQDSDKS-6347-migrate-persistence-to-store
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion test/src/tests-identity.js
Original file line number Diff line number Diff line change
Expand Up @@ -3110,7 +3110,13 @@ describe('identity', function() {
setCookie(workspaceCookieName, cookies, true);
mParticle.config.useCookieStorage = true;

mParticle.init(apiKey, mParticle.config);

// As part of init, there is a call to Identity.Identify. However, in this test case,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

// we are starting with the assumption that there is a current user, and that user has
// both a sessionId (sid) and lastEventSent (les), which causes that initial identify call
// to be skipped. By manually forcing an identify call below, we can test that
// identify correctly calls setFirstSeenTime to set a value;
mParticle.init(apiKey, mParticle.config);

expect(
mParticle.getInstance()._Store.getFirstSeenTime('current')
Expand Down
14 changes: 7 additions & 7 deletions test/src/tests-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,9 @@ describe('Store', () => {
fst: 100
}

store.setFirstSeenTime('previous-set-mpid', 200);
expect(store.getFirstSeenTime('previous-set-mpid')).to.equal(100);

store.setFirstSeenTime('current-mpid', 10000);
store.setFirstSeenTime('current-mpid', 2);
expect(store.getFirstSeenTime('current-mpid')).to.equal(10000);
Expand All @@ -1059,8 +1062,6 @@ describe('Store', () => {
store.setFirstSeenTime('previous-mpid', 20);
expect(store.getFirstSeenTime('previous-mpid')).to.equal(10);

store.setFirstSeenTime('previous-set-mpid', 200);
expect(store.getFirstSeenTime('previous-set-mpid')).to.equal(100);

});
});
Expand Down Expand Up @@ -1167,7 +1168,7 @@ describe('Store', () => {
expect(fromPersistence[testMPID].lst).to.equal(54321);
});

it('returns current time for the current user', () => {
it('returns current time for the current user as the lastSeenTime', () => {
const userSpy = sinon.stub(
window.mParticle.getInstance().Identity,
'getCurrentUser'
Expand Down Expand Up @@ -1865,20 +1866,19 @@ describe('Store', () => {
sid: 'lst Test',
les: new Date().getTime(),
},
previous: {},
cu: 'current',
previousMPID: {},
cu: 'current-mpid',
});
setCookie(workspaceCookieName, cookies, true);
window.mParticle.config.useCookieStorage = true;

window.mParticle.init(apiKey, window.mParticle.config);
expect(
window.mParticle.getInstance()._Store.getFirstSeenTime('previous')
window.mParticle.getInstance()._Store.getFirstSeenTime('previousMPID')
).to.equal(null);

done();
});

});
});
});
Loading