Merge pull request #8886 from overleaf/jpa-pdf-caching-alpha

[web] prepare alpha release of pdf caching

GitOrigin-RevId: 5617dd443da57b7077db793c2bc39be35ec44ef1
This commit is contained in:
Jakob Ackermann
2022-07-20 09:32:05 +01:00
committed by Copybot
parent 1a9487d5fd
commit 3c0bb25249
9 changed files with 118 additions and 157 deletions
@@ -1126,77 +1126,6 @@ describe('ProjectController', function () {
this.ProjectController.loadEditor(this.req, this.res)
})
describe('pdf caching feature flags', function () {
function expectBandwidthTrackingEnabled() {
it('should track pdf bandwidth', function (done) {
this.res.render = (pageName, opts) => {
expect(opts.trackPdfDownload).to.equal(true)
done()
}
this.ProjectController.loadEditor(this.req, this.res)
})
}
function expectPDFCachingEnabled(mode) {
it('should enable pdf caching', function (done) {
this.res.render = (pageName, opts) => {
expect(opts.pdfCachingMode).to.equal(mode)
done()
}
this.ProjectController.loadEditor(this.req, this.res)
})
}
function expectBandwidthTrackingDisabled() {
it('should not track pdf bandwidth', function (done) {
this.res.render = (pageName, opts) => {
expect(opts.trackPdfDownload).to.equal(false)
done()
}
this.ProjectController.loadEditor(this.req, this.res)
})
}
function expectPDFCachingDisabled() {
it('should disable pdf caching', function (done) {
this.res.render = (pageName, opts) => {
expect(opts.pdfCachingMode).to.equal('')
done()
}
this.ProjectController.loadEditor(this.req, this.res)
})
}
beforeEach(function () {
this.settings.enablePdfCaching = true
})
describe('during opt-in only', function () {
describe('with no query', function () {
expectBandwidthTrackingDisabled()
expectPDFCachingDisabled()
})
describe('with track-pdf-download=false', function () {
beforeEach(function () {
this.req.query['track-pdf-download'] = 'false'
})
expectBandwidthTrackingDisabled()
})
describe('with track-pdf-download=true', function () {
beforeEach(function () {
this.req.query['track-pdf-download'] = 'true'
})
expectBandwidthTrackingEnabled()
})
describe('with pdf-caching-mode=enabled', function () {
beforeEach(function () {
this.req.query['pdf-caching-mode'] = 'enabled'
})
expectPDFCachingEnabled('enabled')
})
})
})
describe('wsUrl', function () {
function checkLoadEditorWsMetric(metric) {
it(`should inc metric ${metric}`, function (done) {