Merge pull request #5655 from overleaf/jel-detach-feature-flag

Make showNewPdfPreview a dependency of showPdfDetach

GitOrigin-RevId: 2bb2f5cd8b2cf68a28e8979713c08c0ceef33fa5
This commit is contained in:
Jessica Lawshe 2021-11-03 08:21:24 -05:00 committed by Copybot
parent 3ad686c30b
commit b90b7c92ac
2 changed files with 102 additions and 8 deletions

View file

@ -819,6 +819,20 @@ const ProjectController = {
return shouldDisplayFeature('enable_pdf_caching', false)
}
let showNewPdfPreview = shouldDisplayFeature(
'new_pdf_preview',
user.alphaProgram
)
const showPdfDetach = shouldDisplayFeature(
'pdf_detach',
user.alphaProgram
)
if (showPdfDetach) {
showNewPdfPreview = true
}
res.render('project/editor', {
title: project.name,
priority_title: true,
@ -881,14 +895,8 @@ const ProjectController = {
'new_navigation_ui',
true
),
showPdfDetach: shouldDisplayFeature(
'pdf_detach',
user.alphaProgram
),
showNewPdfPreview: shouldDisplayFeature(
'new_pdf_preview',
user.alphaProgram
),
showPdfDetach,
showNewPdfPreview,
showSymbolPalette: shouldDisplayFeature(
'symbol_palette',
user.alphaProgram || user.betaProgram

View file

@ -1557,6 +1557,92 @@ describe('ProjectController', function () {
})
})
})
describe('feature flags', function () {
describe('showNewPdfPreview', function () {
it('should be false by default', function (done) {
this.res.render = (pageName, opts) => {
expect(opts.showNewPdfPreview).to.be.false
done()
}
this.ProjectController.loadEditor(this.req, this.res)
})
it('should be true when ?new_pdf_preview=true ', function (done) {
this.res.render = (pageName, opts) => {
expect(opts.showNewPdfPreview).to.be.true
done()
}
this.req.query.new_pdf_preview = 'true'
this.ProjectController.loadEditor(this.req, this.res)
})
it('should be true for alpha group', function (done) {
this.res.render = (pageName, opts) => {
expect(opts.showNewPdfPreview).to.be.true
done()
}
this.user.alphaProgram = true
this.ProjectController.loadEditor(this.req, this.res)
})
it('should be false when when ?new_pdf_preview=true and alpha group', function (done) {
this.res.render = (pageName, opts) => {
expect(opts.showNewPdfPreview).to.be.true
done()
}
this.user.alphaProgram = true
this.req.query.new_pdf_preview = 'false'
this.ProjectController.loadEditor(this.req, this.res)
})
})
describe('showPdfDetach', function () {
describe('showPdfDetach=false', function () {
it('should be false by default', function (done) {
this.res.render = (pageName, opts) => {
expect(opts.showPdfDetach).to.be.false
done()
}
this.ProjectController.loadEditor(this.req, this.res)
})
it('should be false by default, even when ?new_pdf_preview=true', function (done) {
this.res.render = (pageName, opts) => {
expect(opts.showPdfDetach).to.be.false
expect(opts.showNewPdfPreview).to.be.true
done()
}
this.req.query.new_pdf_preview = 'true'
this.ProjectController.loadEditor(this.req, this.res)
})
it('should be false when when ?pdf_detach=true and alpha group', function (done) {
this.res.render = (pageName, opts) => {
done()
}
this.user.alphaProgram = true
this.req.query.pdf_detach = 'false'
this.ProjectController.loadEditor(this.req, this.res)
})
})
describe('showPdfDetach=true', function () {
it('should be true when ?pdf_detach=true, and set showNewPdfPreview as true ', function (done) {
this.res.render = (pageName, opts) => {
expect(opts.showPdfDetach).to.be.true
expect(opts.showNewPdfPreview).to.be.true
done()
}
this.req.query.pdf_detach = 'true'
this.ProjectController.loadEditor(this.req, this.res)
})
it('should be true for alpha group, and set showNewPdfPreview as true', function (done) {
this.res.render = (pageName, opts) => {
expect(opts.showPdfDetach).to.be.true
expect(opts.showNewPdfPreview).to.be.true
done()
}
this.user.alphaProgram = true
this.ProjectController.loadEditor(this.req, this.res)
})
})
})
})
})
describe('userProjectsJson', function () {