Merge pull request #7545 from overleaf/td-split-test-data-sentry
Record split-test state in Sentry metadata from web clients GitOrigin-RevId: 66dd195c546bd9fb0aedac52844200846c5012ca
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
const UserHelper = require('./helpers/UserHelper')
|
||||
const Settings = require('@overleaf/settings')
|
||||
const { expect } = require('chai')
|
||||
const SplitTestManager = require('../../../app/src/Features/SplitTests/SplitTestManager')
|
||||
|
||||
// While the split test is in progress this must be appended to URLs during tests
|
||||
const SPLIT_TEST_QUERY = '?primary-email-check=active'
|
||||
@@ -8,6 +9,22 @@ 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 () {
|
||||
await SplitTestManager.createSplitTest('primary-email-check', {
|
||||
active: true,
|
||||
analyticsEnabled: true,
|
||||
phase: 'release',
|
||||
variants: [
|
||||
{
|
||||
name: 'active',
|
||||
rolloutPercent: 0,
|
||||
},
|
||||
],
|
||||
})
|
||||
})
|
||||
|
||||
beforeEach(async function () {
|
||||
userHelper = await UserHelper.createUser()
|
||||
userHelper = await UserHelper.loginUser(
|
||||
|
||||
@@ -126,10 +126,8 @@ describe('ProjectController', function () {
|
||||
this.SplitTestHandler = {
|
||||
promises: {
|
||||
getAssignment: sinon.stub().resolves({ variant: 'default' }),
|
||||
assignInLocalsContext: sinon.stub().resolves({ variant: 'default' }),
|
||||
},
|
||||
getAssignment: sinon.stub().yields(null, { variant: 'default' }),
|
||||
assignInLocalsContext: sinon.stub().yields(null, { variant: 'default' }),
|
||||
}
|
||||
|
||||
this.ProjectController = SandboxedModule.require(MODULE_PATH, {
|
||||
@@ -1413,7 +1411,7 @@ describe('ProjectController', function () {
|
||||
done()
|
||||
}
|
||||
this.SplitTestHandler.getAssignment
|
||||
.withArgs(this.req, 'pdf-detach')
|
||||
.withArgs(this.req, this.res, 'pdf-detach')
|
||||
.yields(null, { variant: 'enabled' })
|
||||
this.req.query.pdf_detach = 'false'
|
||||
this.ProjectController.loadEditor(this.req, this.res)
|
||||
@@ -1436,7 +1434,7 @@ describe('ProjectController', function () {
|
||||
done()
|
||||
}
|
||||
this.SplitTestHandler.getAssignment
|
||||
.withArgs(this.req, 'pdf-detach')
|
||||
.withArgs(this.req, this.res, 'pdf-detach')
|
||||
.yields(null, { variant: 'enabled' })
|
||||
this.ProjectController.loadEditor(this.req, this.res)
|
||||
})
|
||||
|
||||
@@ -14,7 +14,7 @@ describe('SplitTestMiddleware', function () {
|
||||
requires: {
|
||||
'./SplitTestHandler': (this.SplitTestHandler = {
|
||||
promises: {
|
||||
assignInLocalsContext: sinon.stub().resolves(),
|
||||
getAssignment: sinon.stub().resolves(),
|
||||
},
|
||||
}),
|
||||
},
|
||||
@@ -26,12 +26,12 @@ describe('SplitTestMiddleware', function () {
|
||||
})
|
||||
|
||||
it('assign multiple split test variants in locals', async function () {
|
||||
this.SplitTestHandler.promises.assignInLocalsContext
|
||||
this.SplitTestHandler.promises.getAssignment
|
||||
.withArgs(this.req, 'ui-overhaul')
|
||||
.resolves({
|
||||
variant: 'default',
|
||||
})
|
||||
this.SplitTestHandler.promises.assignInLocalsContext
|
||||
this.SplitTestHandler.promises.getAssignment
|
||||
.withArgs(this.req, 'other-test')
|
||||
.resolves({
|
||||
variant: 'foobar',
|
||||
@@ -44,13 +44,13 @@ describe('SplitTestMiddleware', function () {
|
||||
await middleware(this.req, this.res, this.next)
|
||||
|
||||
sinon.assert.calledWith(
|
||||
this.SplitTestHandler.promises.assignInLocalsContext,
|
||||
this.SplitTestHandler.promises.getAssignment,
|
||||
this.req,
|
||||
this.res,
|
||||
'ui-overhaul'
|
||||
)
|
||||
sinon.assert.calledWith(
|
||||
this.SplitTestHandler.promises.assignInLocalsContext,
|
||||
this.SplitTestHandler.promises.getAssignment,
|
||||
this.req,
|
||||
this.res,
|
||||
'other-test'
|
||||
@@ -63,12 +63,12 @@ describe('SplitTestMiddleware', function () {
|
||||
|
||||
await middleware(this.req, this.res, this.next)
|
||||
|
||||
sinon.assert.notCalled(this.SplitTestHandler.promises.assignInLocalsContext)
|
||||
sinon.assert.notCalled(this.SplitTestHandler.promises.getAssignment)
|
||||
sinon.assert.calledOnce(this.next)
|
||||
})
|
||||
|
||||
it('exception thrown by assignment does not fail the request', async function () {
|
||||
this.SplitTestHandler.promises.assignInLocalsContext
|
||||
this.SplitTestHandler.promises.getAssignment
|
||||
.withArgs(this.req, this.res, 'some-test')
|
||||
.throws(new Error('failure'))
|
||||
|
||||
@@ -79,7 +79,7 @@ describe('SplitTestMiddleware', function () {
|
||||
await middleware(this.req, this.res, this.next)
|
||||
|
||||
sinon.assert.calledWith(
|
||||
this.SplitTestHandler.promises.assignInLocalsContext,
|
||||
this.SplitTestHandler.promises.getAssignment,
|
||||
this.req,
|
||||
this.res,
|
||||
'some-test'
|
||||
|
||||
Reference in New Issue
Block a user