|
@@ -8,14 +8,6 @@ vi.mock('../../../../app/src/Features/Errors/Errors.js', () => {
|
|
|
return vi.importActual('../../../../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 () {
|
|
describe('UserController', function () {
|
|
|
beforeEach(async function (ctx) {
|
|
beforeEach(async function (ctx) {
|
|
|
ctx.user_id = '323123'
|
|
ctx.user_id = '323123'
|
|
@@ -151,12 +143,6 @@ describe('UserController', function () {
|
|
|
},
|
|
},
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- ctx.SplitTestHandler = {
|
|
|
|
|
- promises: {
|
|
|
|
|
- getAssignment: sinon.stub().resolves({ variant: 'default' }),
|
|
|
|
|
- },
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
vi.doMock('../../../../app/src/Features/Helpers/UrlHelper', () => ({
|
|
vi.doMock('../../../../app/src/Features/Helpers/UrlHelper', () => ({
|
|
|
default: ctx.UrlHelper,
|
|
default: ctx.UrlHelper,
|
|
|
}))
|
|
}))
|
|
@@ -253,13 +239,6 @@ describe('UserController', function () {
|
|
|
default: ctx.Modules,
|
|
default: ctx.Modules,
|
|
|
}))
|
|
}))
|
|
|
|
|
|
|
|
- vi.doMock(
|
|
|
|
|
- '../../../../app/src/Features/SplitTests/SplitTestHandler.mjs',
|
|
|
|
|
- () => ({
|
|
|
|
|
- default: ctx.SplitTestHandler,
|
|
|
|
|
- })
|
|
|
|
|
- )
|
|
|
|
|
-
|
|
|
|
|
ctx.UserController = (await import(modulePath)).default
|
|
ctx.UserController = (await import(modulePath)).default
|
|
|
|
|
|
|
|
ctx.res = {
|
|
ctx.res = {
|
|
@@ -586,85 +565,36 @@ describe('UserController', function () {
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- 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 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 enabled', function () {
|
|
|
|
|
- beforeEach(function (ctx) {
|
|
|
|
|
- ctx.SplitTestHandler.promises.getAssignment.resolves({
|
|
|
|
|
- variant: 'enabled',
|
|
|
|
|
- })
|
|
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
- 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 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)
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ 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)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|