[web] Add split test for testing editor switch naming (#12596)

Co-authored-by: Ieva Vaiginyte <95856891+ievaoverleaf@users.noreply.github.com>
GitOrigin-RevId: dafe07bda841dad962ebf2894718750fafe86373
This commit is contained in:
Mathias Jakobsen
2023-04-17 16:06:09 +01:00
committed by Copybot
parent 77c2db38fc
commit c8f7bc54bc
3 changed files with 82 additions and 17 deletions
@@ -46,6 +46,8 @@ const SurveyHandler = require('../Survey/SurveyHandler')
const ProjectAuditLogHandler = require('./ProjectAuditLogHandler')
const PublicAccessLevels = require('../Authorization/PublicAccessLevels')
const VISUAL_EDITOR_NAMING_SPLIT_TEST_MIN_SIGNUP_DATE = new Date('2023-04-17')
/**
* @typedef {import("./types").GetProjectsRequest} GetProjectsRequest
* @typedef {import("./types").GetProjectsResponse} GetProjectsResponse
@@ -903,21 +905,60 @@ const ProjectController = {
}
)
},
legacySourceEditorAssignment(cb) {
SplitTestHandler.getAssignment(
req,
res,
'source-editor-legacy',
(error, assignment) => {
// do not fail editor load if assignment fails
if (error) {
cb(null, { variant: 'default' })
} else {
cb(null, assignment)
}
participatingInVisualEditorNamingTest: [
'user',
(results, cb) => {
const isNewUser =
results.user.signUpDate >=
VISUAL_EDITOR_NAMING_SPLIT_TEST_MIN_SIGNUP_DATE
cb(null, isNewUser)
},
],
visualEditorNameAssignment: [
'participatingInVisualEditorNamingTest',
(results, cb) => {
if (!results.participatingInVisualEditorNamingTest) {
cb(null, { variant: 'default' })
} else {
SplitTestHandler.getAssignment(
req,
res,
'visual-editor-name',
(error, assignment) => {
if (error) {
cb(null, { variant: 'default' })
} else {
cb(null, assignment)
}
}
)
}
)
},
},
],
legacySourceEditorAssignment: [
'participatingInVisualEditorNamingTest',
'visualEditorNameAssignment',
(results, cb) => {
// Hide Ace for people in the Rich Text naming test
if (results.participatingInVisualEditorNamingTest) {
cb(null, { variant: 'true' })
} else {
SplitTestHandler.getAssignment(
req,
res,
'source-editor-legacy',
(error, assignment) => {
// do not fail editor load if assignment fails
if (error) {
cb(null, { variant: 'default' })
} else {
cb(null, assignment)
}
}
)
}
},
],
pdfjsAssignment(cb) {
SplitTestHandler.getAssignment(
req,
@@ -1148,6 +1189,8 @@ const ProjectController = {
isTokenMember,
isInvitedMember,
brandVariation,
visualEditorNameAssignment,
participatingInVisualEditorNamingTest,
legacySourceEditorAssignment,
pdfjsAssignment,
editorLeftMenuAssignment,
@@ -1271,6 +1314,11 @@ const ProjectController = {
detachRole === 'detached'
? 'project/editor_detached'
: 'project/editor'
const isParticipatingInVisualEditorNamingTest =
Features.hasFeature('saas') &&
participatingInVisualEditorNamingTest
res.render(template, {
title: project.name,
priority_title: true,
@@ -1336,6 +1384,8 @@ const ProjectController = {
),
pdfjsVariant: pdfjsAssignment.variant,
debugPdfDetach,
isParticipatingInVisualEditorNamingTest,
visualEditorNameVariant: visualEditorNameAssignment.variant,
showLegacySourceEditor,
showSymbolPalette,
galileoEnabled,