mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-26 18:51:50 +02:00
Merge pull request #30393 from overleaf/dp-test-revert-2
Revert "Merge pull request #29916 from overleaf/dp-cleanup-editor-red… GitOrigin-RevId: c2f14fb55e74a1fcb026e37822774724c36bc0dc
This commit is contained in:
@@ -8,6 +8,14 @@ vi.mock('../../../../app/src/Features/Errors/Errors.js', () => {
|
||||
return vi.importActual('../../../../app/src/Features/Errors/Errors.js')
|
||||
})
|
||||
|
||||
vi.mock('../../../../app/src/infrastructure/Metrics.js', () => ({
|
||||
default: {
|
||||
analyticsQueue: {
|
||||
inc: vi.fn(),
|
||||
},
|
||||
},
|
||||
}))
|
||||
|
||||
describe('UserController', function () {
|
||||
beforeEach(async function (ctx) {
|
||||
ctx.user_id = '323123'
|
||||
@@ -143,6 +151,12 @@ describe('UserController', function () {
|
||||
},
|
||||
}
|
||||
|
||||
ctx.SplitTestHandler = {
|
||||
promises: {
|
||||
getAssignment: sinon.stub().resolves({ variant: 'default' }),
|
||||
},
|
||||
}
|
||||
|
||||
vi.doMock('../../../../app/src/Features/Helpers/UrlHelper', () => ({
|
||||
default: ctx.UrlHelper,
|
||||
}))
|
||||
@@ -239,6 +253,13 @@ describe('UserController', function () {
|
||||
default: ctx.Modules,
|
||||
}))
|
||||
|
||||
vi.doMock(
|
||||
'../../../../app/src/Features/SplitTests/SplitTestHandler.mjs',
|
||||
() => ({
|
||||
default: ctx.SplitTestHandler,
|
||||
})
|
||||
)
|
||||
|
||||
ctx.UserController = (await import(modulePath)).default
|
||||
|
||||
ctx.res = {
|
||||
@@ -565,36 +586,85 @@ describe('UserController', function () {
|
||||
})
|
||||
})
|
||||
|
||||
it('should set enableNewEditorStageFour to true', function (ctx) {
|
||||
return new Promise(resolve => {
|
||||
ctx.req.body = { enableNewEditor: true }
|
||||
ctx.res.sendStatus = code => {
|
||||
ctx.user.ace.enableNewEditorStageFour.should.equal(true)
|
||||
resolve()
|
||||
}
|
||||
ctx.UserController.updateUserSettings(ctx.req, ctx.res)
|
||||
describe('when editor-redesign-opt-out is set to default', function () {
|
||||
beforeEach(function (ctx) {
|
||||
ctx.SplitTestHandler.promises.getAssignment.resolves({
|
||||
variant: 'default',
|
||||
})
|
||||
})
|
||||
|
||||
it('should set enableNewEditor to true', function (ctx) {
|
||||
return new Promise(resolve => {
|
||||
ctx.req.body = { enableNewEditor: true }
|
||||
ctx.res.sendStatus = code => {
|
||||
ctx.user.ace.enableNewEditor.should.equal(true)
|
||||
resolve()
|
||||
}
|
||||
ctx.UserController.updateUserSettings(ctx.req, ctx.res)
|
||||
})
|
||||
})
|
||||
|
||||
it('should set enableNewEditor to false', function (ctx) {
|
||||
return new Promise(resolve => {
|
||||
ctx.req.body = { enableNewEditor: false }
|
||||
ctx.res.sendStatus = code => {
|
||||
ctx.user.ace.enableNewEditor.should.equal(false)
|
||||
resolve()
|
||||
}
|
||||
ctx.UserController.updateUserSettings(ctx.req, ctx.res)
|
||||
})
|
||||
})
|
||||
|
||||
it('should keep enableNewEditor a boolean', function (ctx) {
|
||||
return new Promise(resolve => {
|
||||
ctx.req.body = { enableNewEditor: 'foobar' }
|
||||
ctx.res.sendStatus = code => {
|
||||
ctx.user.ace.enableNewEditor.should.equal(true)
|
||||
resolve()
|
||||
}
|
||||
ctx.UserController.updateUserSettings(ctx.req, ctx.res)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
it('should set enableNewEditorStageFour to false', function (ctx) {
|
||||
return new Promise(resolve => {
|
||||
ctx.req.body = { enableNewEditor: false }
|
||||
ctx.res.sendStatus = code => {
|
||||
ctx.user.ace.enableNewEditorStageFour.should.equal(false)
|
||||
resolve()
|
||||
}
|
||||
ctx.UserController.updateUserSettings(ctx.req, ctx.res)
|
||||
describe('when editor-redesign-opt-out is set to enabled', function () {
|
||||
beforeEach(function (ctx) {
|
||||
ctx.SplitTestHandler.promises.getAssignment.resolves({
|
||||
variant: 'enabled',
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
it('should keep enableNewEditorStageFour a boolean', function (ctx) {
|
||||
return new Promise(resolve => {
|
||||
ctx.req.body = { enableNewEditor: 'foobar' }
|
||||
ctx.res.sendStatus = code => {
|
||||
ctx.user.ace.enableNewEditorStageFour.should.equal(true)
|
||||
resolve()
|
||||
}
|
||||
ctx.UserController.updateUserSettings(ctx.req, ctx.res)
|
||||
it('should set enableNewEditorStageFour to true', function (ctx) {
|
||||
return new Promise(resolve => {
|
||||
ctx.req.body = { enableNewEditor: true }
|
||||
ctx.res.sendStatus = code => {
|
||||
ctx.user.ace.enableNewEditorStageFour.should.equal(true)
|
||||
resolve()
|
||||
}
|
||||
ctx.UserController.updateUserSettings(ctx.req, ctx.res)
|
||||
})
|
||||
})
|
||||
|
||||
it('should set enableNewEditorStageFour to false', function (ctx) {
|
||||
return new Promise(resolve => {
|
||||
ctx.req.body = { enableNewEditor: false }
|
||||
ctx.res.sendStatus = code => {
|
||||
ctx.user.ace.enableNewEditorStageFour.should.equal(false)
|
||||
resolve()
|
||||
}
|
||||
ctx.UserController.updateUserSettings(ctx.req, ctx.res)
|
||||
})
|
||||
})
|
||||
|
||||
it('should keep enableNewEditorStageFour a boolean', function (ctx) {
|
||||
return new Promise(resolve => {
|
||||
ctx.req.body = { enableNewEditor: 'foobar' }
|
||||
ctx.res.sendStatus = code => {
|
||||
ctx.user.ace.enableNewEditorStageFour.should.equal(true)
|
||||
resolve()
|
||||
}
|
||||
ctx.UserController.updateUserSettings(ctx.req, ctx.res)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user