diff --git a/services/web/test/UnitTests/coffee/Authentication/AuthenticationControllerTests.coffee b/services/web/test/UnitTests/coffee/Authentication/AuthenticationControllerTests.coffee index 4e9b248f25..86c5e5840f 100644 --- a/services/web/test/UnitTests/coffee/Authentication/AuthenticationControllerTests.coffee +++ b/services/web/test/UnitTests/coffee/Authentication/AuthenticationControllerTests.coffee @@ -19,6 +19,7 @@ describe "AuthenticationController", -> "../../infrastructure/Metrics": @Metrics = { inc: sinon.stub() } "../Security/LoginRateLimiter": @LoginRateLimiter = { processLoginRequest:sinon.stub(), recordSuccessfulLogin:sinon.stub() } "../User/UserHandler": @UserHandler = {setupLoginData:sinon.stub()} + "../Analytics/AnalyticsManager": @AnalyticsManager = { recordEvent: sinon.stub() } "logger-sharelatex": @logger = { log: sinon.stub(), error: sinon.stub() } "settings-sharelatex": {} "../User/UserSessionsManager": @UserSessionsManager = @@ -100,6 +101,11 @@ describe "AuthenticationController", -> .calledWith(email: @email.toLowerCase(), user_id: @user._id.toString(), "successful log in") .should.equal true + it "should track the login event", -> + @AnalyticsManager.recordEvent + .calledWith(@user._id, "user-logged-in") + .should.equal true + describe 'when the user is not authenticated', -> beforeEach -> diff --git a/services/web/test/UnitTests/coffee/User/UserRegistrationHandlerTests.coffee b/services/web/test/UnitTests/coffee/User/UserRegistrationHandlerTests.coffee index ec220e27f8..d0b96da2de 100644 --- a/services/web/test/UnitTests/coffee/User/UserRegistrationHandlerTests.coffee +++ b/services/web/test/UnitTests/coffee/User/UserRegistrationHandlerTests.coffee @@ -33,6 +33,7 @@ describe "UserRegistrationHandler", -> "crypto": @crypto = {} "../Email/EmailHandler": @EmailHandler "../Security/OneTimeTokenHandler": @OneTimeTokenHandler + "../Analytics/AnalyticsManager": @AnalyticsManager = { recordEvent: sinon.stub() } "settings-sharelatex": @settings = {siteUrl: "http://sl.example.com"} @passingRequest = {email:"something@email.com", password:"123"} @@ -132,6 +133,13 @@ describe "UserRegistrationHandler", -> @NewsLetterManager.subscribe.calledWith(@user).should.equal true done() + it "should track the registration event", (done)-> + @handler.registerNewUser @passingRequest, (err)=> + @AnalyticsManager.recordEvent + .calledWith(@user._id, "user-registered") + .should.equal true + done() + it "should call the ReferalAllocator", (done)-> done()