Merge pull request #10793 from overleaf/mj-split-test-cleanup

Split test clean-up

GitOrigin-RevId: 7dd6178487022cbefcbc85797dacc3f3fbfa17e2
This commit is contained in:
Mathias Jakobsen
2022-12-21 09:04:04 +00:00
committed by Copybot
parent f6c1e2738d
commit 38cc3394e3
27 changed files with 53 additions and 622 deletions
@@ -1,36 +1,15 @@
const UserHelper = require('./helpers/UserHelper')
const Settings = require('@overleaf/settings')
const { expect } = require('chai')
const SplitTestManager = require('../../../app/src/Features/SplitTests/SplitTestManager')
const Features = require('../../../app/src/infrastructure/Features')
// While the split test is in progress this must be appended to URLs during tests
const SPLIT_TEST_QUERY = '?primary-email-check=active'
describe('PrimaryEmailCheck', function () {
let userHelper
// Create the primary-email-check split test because this is now required for the query string override to work. See
// https://github.com/overleaf/internal/pull/7545#discussion_r848575736
before(async function () {
if (!Features.hasFeature('saas')) {
this.skip()
}
await SplitTestManager.createSplitTest({
name: 'primary-email-check',
configuration: {
active: true,
analyticsEnabled: true,
phase: 'release',
variants: [
{
name: 'active',
rolloutPercent: 0,
},
],
},
})
})
beforeEach(async function () {
@@ -43,13 +22,13 @@ describe('PrimaryEmailCheck', function () {
describe('redirections', function () {
describe('when the user has signed up recently', function () {
it("shouldn't be redirected from project list to the primary email check page", async function () {
const response = await userHelper.fetch('/project' + SPLIT_TEST_QUERY)
const response = await userHelper.fetch('/project')
expect(response.status).to.equal(200)
})
it('should be redirected from the primary email check page to the project list', async function () {
const response = await userHelper.fetch(
'/user/emails/primary-email-check' + SPLIT_TEST_QUERY
'/user/emails/primary-email-check'
)
expect(response.status).to.equal(302)
expect(response.headers.get('location')).to.equal(
@@ -67,13 +46,13 @@ describe('PrimaryEmailCheck', function () {
})
it("shouldn't be redirected from project list to the primary email check page", async function () {
const response = await userHelper.fetch('/project' + SPLIT_TEST_QUERY)
const response = await userHelper.fetch('/project')
expect(response.status).to.equal(200)
})
it('should be redirected from the primary email check page to the project list', async function () {
const response = await userHelper.fetch(
'/user/emails/primary-email-check' + SPLIT_TEST_QUERY
'/user/emails/primary-email-check'
)
expect(response.status).to.equal(302)
expect(response.headers.get('location')).to.equal(
@@ -98,13 +77,13 @@ describe('PrimaryEmailCheck', function () {
})
it("shouldn't be redirected from project list to the primary email check page", async function () {
const response = await userHelper.fetch('/project' + SPLIT_TEST_QUERY)
const response = await userHelper.fetch('/project')
expect(response.status).to.equal(200)
})
it('should be redirected from the primary email check page to the project list', async function () {
const response = await userHelper.fetch(
'/user/emails/primary-email-check' + SPLIT_TEST_QUERY
'/user/emails/primary-email-check'
)
expect(response.status).to.equal(302)
expect(response.headers.get('location')).to.equal(
@@ -122,7 +101,7 @@ describe('PrimaryEmailCheck', function () {
})
it('should be redirected from project list to the primary email check page', async function () {
const response = await userHelper.fetch('/project' + SPLIT_TEST_QUERY)
const response = await userHelper.fetch('/project')
expect(response.status).to.equal(302)
expect(response.headers.get('location')).to.equal(
UserHelper.url('/user/emails/primary-email-check').toString()
@@ -149,7 +128,7 @@ describe('PrimaryEmailCheck', function () {
})
checkResponse = await userHelper.fetch(
'/user/emails/primary-email-check' + SPLIT_TEST_QUERY,
'/user/emails/primary-email-check',
{ method: 'POST' }
)
})
@@ -162,7 +141,7 @@ describe('PrimaryEmailCheck', function () {
})
it("shouldn't be redirected from project list to the primary email check page any longer", async function () {
const response = await userHelper.fetch('/project' + SPLIT_TEST_QUERY)
const response = await userHelper.fetch('/project')
expect(response.status).to.equal(200)
})
@@ -73,6 +73,7 @@ describe('Sessions', function () {
// set up second session for this user
this.user2 = new User()
this.user2.email = this.user1.email
this.user2.emails = this.user1.emails
this.user2.password = this.user1.password
})
@@ -197,9 +198,11 @@ describe('Sessions', function () {
// set up second session for this user
this.user2 = new User()
this.user2.email = this.user1.email
this.user2.emails = this.user1.emails
this.user2.password = this.user1.password
this.user3 = new User()
this.user3.email = this.user1.email
this.user3.emails = this.user1.emails
this.user3.password = this.user1.password
})
@@ -321,9 +324,11 @@ describe('Sessions', function () {
// set up second session for this user
this.user2 = new User()
this.user2.email = this.user1.email
this.user2.emails = this.user1.emails
this.user2.password = this.user1.password
this.user3 = new User()
this.user3.email = this.user1.email
this.user3.emails = this.user1.emails
this.user3.password = this.user1.password
async.series([this.user2.login.bind(this.user2)], done)
})
@@ -19,6 +19,7 @@ class User {
{
email: options.email || `acceptance-test-${count}@example.com`,
createdAt: new Date(),
confirmedAt: options.confirmedAt,
},
]
this.email = this.emails[0].email
@@ -105,6 +105,9 @@ export function EditorProviders({
metadataManager,
}
// Add details for useUserContext
window.metaAttributesCache.set('ol-user', { ...user, features })
return (
<SplitTestProvider>
<IdeProvider ide={window._ide}>
@@ -71,6 +71,9 @@ describe('ProjectController', function () {
this.EditorController = { renameProject: sinon.stub() }
this.InactiveProjectManager = { reactivateProjectIfRequired: sinon.stub() }
this.ProjectUpdateHandler = { markAsOpened: sinon.stub() }
this.UserPrimaryEmailCheckHandler = {
requiresPrimaryEmailCheck: sinon.stub().returns(false),
}
this.ProjectGetter = {
findAllUsersProjects: sinon.stub(),
getProject: sinon.stub(),
@@ -193,6 +196,8 @@ describe('ProjectController', function () {
},
'../Institutions/InstitutionsFeatures': this.InstitutionsFeatures,
'../Survey/SurveyHandler': this.SurveyHandler,
'../User/UserPrimaryEmailCheckHandler':
this.UserPrimaryEmailCheckHandler,
'./ProjectAuditLogHandler': this.ProjectAuditLogHandler,
},
})
@@ -275,7 +275,7 @@ describe('SubscriptionController', function () {
describe('with a valid plan code', function () {
it('should render the new subscription page', function (done) {
this.res.render = (page, opts) => {
page.should.equal('subscriptions/new')
page.should.equal('subscriptions/new-updated')
done()
}
this.SubscriptionController.paymentPage(this.req, this.res)