diff --git a/src/register/RegistrationPage.jsx b/src/register/RegistrationPage.jsx index 3c06bd7910..a7ffbac95e 100644 --- a/src/register/RegistrationPage.jsx +++ b/src/register/RegistrationPage.jsx @@ -69,6 +69,7 @@ class RegistrationPage extends React.Component { }, institutionLogin: false, formValid: false, + startTime: Date.now(), updateFieldErrors: false, updateAlertErrors: false, registrationErrorsUpdated: false, @@ -155,6 +156,7 @@ class RegistrationPage extends React.Component { handleSubmit = (e) => { e.preventDefault(); + const totalRegistrationTime = (Date.now() - this.state.startTime) / 1000; let payload = { name: this.state.name, username: this.state.username, @@ -188,6 +190,7 @@ class RegistrationPage extends React.Component { } }); if (finalValidation) { + payload.totalRegistrationTime = totalRegistrationTime; this.props.registerNewUser(payload); } } diff --git a/src/register/data/actions.js b/src/register/data/actions.js index aef1dc5270..71556a43a7 100644 --- a/src/register/data/actions.js +++ b/src/register/data/actions.js @@ -1,11 +1,9 @@ import { AsyncActionType } from '../../data/utils'; export const REGISTER_NEW_USER = new AsyncActionType('REGISTRATION', 'REGISTER_NEW_USER'); -export const REGISTER_FORM = new AsyncActionType('REGISTRATION', 'GET_FORM_FIELDS'); export const REGISTER_FORM_VALIDATIONS = new AsyncActionType('REGISTRATION', 'GET_FORM_VALIDATIONS'); // Register - export const registerNewUser = registrationInfo => ({ type: REGISTER_NEW_USER.BASE, payload: { registrationInfo }, diff --git a/src/register/tests/RegistrationPage.test.jsx b/src/register/tests/RegistrationPage.test.jsx index 9d8974289e..97bade65ba 100644 --- a/src/register/tests/RegistrationPage.test.jsx +++ b/src/register/tests/RegistrationPage.test.jsx @@ -347,6 +347,8 @@ describe('RegistrationPageTests', () => { }); it('should submit form for valid input', () => { + jest.spyOn(global.Date, 'now').mockImplementation(() => 0); + const formPayload = { name: 'John Doe', username: 'john_doe', @@ -355,6 +357,7 @@ describe('RegistrationPageTests', () => { country: 'Pakistan', gender: 'm', honor_code: true, + totalRegistrationTime: 0, }; store.dispatch = jest.fn(store.dispatch); @@ -363,6 +366,7 @@ describe('RegistrationPageTests', () => { }); it('should submit form with no password when current provider is present', () => { + jest.spyOn(global.Date, 'now').mockImplementation(() => 0); store = mockStore({ ...initialState, commonComponents: { @@ -381,6 +385,7 @@ describe('RegistrationPageTests', () => { country: 'Pakistan', honor_code: true, social_auth_provider: appleProvider.name, + totalRegistrationTime: 0, }; store.dispatch = jest.fn(store.dispatch);