-
Notifications
You must be signed in to change notification settings - Fork 44
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
base: refactor/SQDSDKS-6347-migrate-persistence-to-store
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
import Constants from '../../src/constants'; | ||
import Utils from './config/utils'; | ||
import sinon from 'sinon'; | ||
import { expect } from 'chai'; | ||
import fetchMock from 'fetch-mock/esm/client'; | ||
import { urls, apiKey, | ||
testMPID, | ||
MPConfig, | ||
workspaceCookieName, | ||
mParticle, | ||
} from './config/constants'; | ||
|
||
const getLocalStorage = Utils.getLocalStorage, | ||
|
@@ -3084,6 +3086,52 @@ describe('identity', function() { | |
done(); | ||
}); | ||
|
||
describe('#identify', function() { | ||
it("should set fst when the user does not change, after an identify request", function(done) { | ||
mParticle._resetForTests(MPConfig); | ||
|
||
const cookies = JSON.stringify({ | ||
gs: { | ||
sid: 'fst Test', | ||
les: new Date().getTime(), | ||
}, | ||
current: {}, | ||
cu: 'current', | ||
}); | ||
|
||
mockServer.respondWith(urls.identify, [ | ||
200, | ||
{}, | ||
JSON.stringify({ mpid: 'current', is_logged_in: false }), | ||
]); | ||
|
||
// We set the cookies because the init process will load cookies into | ||
// our in-memory store, which we will check before and after the identify request | ||
setCookie(workspaceCookieName, cookies, true); | ||
mParticle.config.useCookieStorage = true; | ||
|
||
|
||
// As part of init, there is a call to Identity.Identify. However, in this test case, | ||
// 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') | ||
).to.equal(null); | ||
Comment on lines
+3121
to
+3123
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you try the following? Comment out Does the test in 3115 fail? I think it would. Because normally If the above is in fact the case, we should add a comment above |
||
|
||
mParticle.Identity.identify(); | ||
|
||
expect( | ||
mParticle.getInstance()._Store.getFirstSeenTime('current') | ||
).to.not.equal(null); | ||
|
||
done(); | ||
}); | ||
}); | ||
|
||
describe('identity caching', function() { | ||
afterEach(function() { | ||
sinon.restore(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍