|
@@ -128,7 +128,7 @@ describe('ProjectController', function () {
|
|
|
promises: {
|
|
promises: {
|
|
|
getTestSegmentation: sinon.stub().resolves({ enabled: false }),
|
|
getTestSegmentation: sinon.stub().resolves({ enabled: false }),
|
|
|
},
|
|
},
|
|
|
- getTestSegmentation: sinon.stub().returns({ enabled: false }),
|
|
|
|
|
|
|
+ getTestSegmentation: sinon.stub().yields(null, { enabled: false }),
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
this.ProjectController = SandboxedModule.require(MODULE_PATH, {
|
|
this.ProjectController = SandboxedModule.require(MODULE_PATH, {
|
|
@@ -1076,6 +1076,21 @@ describe('ProjectController', function () {
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('pdf caching feature flags', function () {
|
|
describe('pdf caching feature flags', function () {
|
|
|
|
|
+ /* eslint-disable mocha/no-identical-title */
|
|
|
|
|
+ function showNoVariant() {
|
|
|
|
|
+ beforeEach(function () {
|
|
|
|
|
+ this.SplitTestHandler.getTestSegmentation = sinon
|
|
|
|
|
+ .stub()
|
|
|
|
|
+ .yields(null, { enabled: false })
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ function showVariant(variant) {
|
|
|
|
|
+ beforeEach(function () {
|
|
|
|
|
+ this.SplitTestHandler.getTestSegmentation = sinon
|
|
|
|
|
+ .stub()
|
|
|
|
|
+ .yields(null, { enabled: true, variant })
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
function expectBandwidthTrackingEnabled() {
|
|
function expectBandwidthTrackingEnabled() {
|
|
|
it('should track pdf bandwidth', function (done) {
|
|
it('should track pdf bandwidth', function (done) {
|
|
|
this.res.render = (pageName, opts) => {
|
|
this.res.render = (pageName, opts) => {
|
|
@@ -1112,15 +1127,10 @@ describe('ProjectController', function () {
|
|
|
this.ProjectController.loadEditor(this.req, this.res)
|
|
this.ProjectController.loadEditor(this.req, this.res)
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- beforeEach(function () {
|
|
|
|
|
- this.settings.enablePdfCaching = true
|
|
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
- describe('regular user', function () {
|
|
|
|
|
|
|
+ function expectToCollectMetricsAndCachePDF() {
|
|
|
describe('with no query', function () {
|
|
describe('with no query', function () {
|
|
|
- expectBandwidthTrackingDisabled()
|
|
|
|
|
- expectPDFCachingDisabled()
|
|
|
|
|
|
|
+ expectBandwidthTrackingEnabled()
|
|
|
|
|
+ expectPDFCachingEnabled()
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('with enable_pdf_caching=false', function () {
|
|
describe('with enable_pdf_caching=false', function () {
|
|
@@ -1135,25 +1145,21 @@ describe('ProjectController', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
this.req.query.enable_pdf_caching = 'true'
|
|
this.req.query.enable_pdf_caching = 'true'
|
|
|
})
|
|
})
|
|
|
- expectBandwidthTrackingDisabled()
|
|
|
|
|
|
|
+ expectBandwidthTrackingEnabled()
|
|
|
expectPDFCachingEnabled()
|
|
expectPDFCachingEnabled()
|
|
|
})
|
|
})
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
- describe('alpha user', function () {
|
|
|
|
|
- beforeEach(function () {
|
|
|
|
|
- this.user.alphaProgram = true
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ function expectToCollectMetricsOnly() {
|
|
|
describe('with no query', function () {
|
|
describe('with no query', function () {
|
|
|
expectBandwidthTrackingEnabled()
|
|
expectBandwidthTrackingEnabled()
|
|
|
- expectPDFCachingEnabled()
|
|
|
|
|
|
|
+ expectPDFCachingDisabled()
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('with enable_pdf_caching=false', function () {
|
|
describe('with enable_pdf_caching=false', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
this.req.query.enable_pdf_caching = 'false'
|
|
this.req.query.enable_pdf_caching = 'false'
|
|
|
})
|
|
})
|
|
|
- expectBandwidthTrackingEnabled()
|
|
|
|
|
|
|
+ expectBandwidthTrackingDisabled()
|
|
|
expectPDFCachingDisabled()
|
|
expectPDFCachingDisabled()
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -1162,15 +1168,34 @@ describe('ProjectController', function () {
|
|
|
this.req.query.enable_pdf_caching = 'true'
|
|
this.req.query.enable_pdf_caching = 'true'
|
|
|
})
|
|
})
|
|
|
expectBandwidthTrackingEnabled()
|
|
expectBandwidthTrackingEnabled()
|
|
|
|
|
+ expectPDFCachingDisabled()
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function expectToCachePDFOnly() {
|
|
|
|
|
+ describe('with no query', function () {
|
|
|
|
|
+ expectBandwidthTrackingDisabled()
|
|
|
expectPDFCachingEnabled()
|
|
expectPDFCachingEnabled()
|
|
|
})
|
|
})
|
|
|
- })
|
|
|
|
|
|
|
|
|
|
- describe('beta user', function () {
|
|
|
|
|
- beforeEach(function () {
|
|
|
|
|
- this.user.betaProgram = true
|
|
|
|
|
|
|
+ describe('with enable_pdf_caching=false', function () {
|
|
|
|
|
+ beforeEach(function () {
|
|
|
|
|
+ this.req.query.enable_pdf_caching = 'false'
|
|
|
|
|
+ })
|
|
|
|
|
+ expectBandwidthTrackingDisabled()
|
|
|
|
|
+ expectPDFCachingDisabled()
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ describe('with enable_pdf_caching=true', function () {
|
|
|
|
|
+ beforeEach(function () {
|
|
|
|
|
+ this.req.query.enable_pdf_caching = 'true'
|
|
|
|
|
+ })
|
|
|
|
|
+ expectBandwidthTrackingDisabled()
|
|
|
|
|
+ expectPDFCachingEnabled()
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function expectToNotBeEnrolledAtAll() {
|
|
|
describe('with no query', function () {
|
|
describe('with no query', function () {
|
|
|
expectBandwidthTrackingDisabled()
|
|
expectBandwidthTrackingDisabled()
|
|
|
expectPDFCachingDisabled()
|
|
expectPDFCachingDisabled()
|
|
@@ -1189,7 +1214,129 @@ describe('ProjectController', function () {
|
|
|
this.req.query.enable_pdf_caching = 'true'
|
|
this.req.query.enable_pdf_caching = 'true'
|
|
|
})
|
|
})
|
|
|
expectBandwidthTrackingDisabled()
|
|
expectBandwidthTrackingDisabled()
|
|
|
- expectPDFCachingEnabled()
|
|
|
|
|
|
|
+ expectPDFCachingDisabled()
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function tagAnonymous() {
|
|
|
|
|
+ beforeEach(function () {
|
|
|
|
|
+ this.AuthenticationController.isUserLoggedIn = sinon
|
|
|
|
|
+ .stub()
|
|
|
|
|
+ .returns(false)
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ function tagAlpha() {
|
|
|
|
|
+ beforeEach(function () {
|
|
|
|
|
+ this.user.alphaProgram = true
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ function tagBeta() {
|
|
|
|
|
+ beforeEach(function () {
|
|
|
|
|
+ this.user.betaProgram = true
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ beforeEach(function () {
|
|
|
|
|
+ this.settings.enablePdfCaching = true
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ describe('alpha rollout', function () {
|
|
|
|
|
+ describe('regular user', function () {
|
|
|
|
|
+ expectToNotBeEnrolledAtAll()
|
|
|
|
|
+ })
|
|
|
|
|
+ describe('anonymous user', function () {
|
|
|
|
|
+ tagAnonymous()
|
|
|
|
|
+ expectToNotBeEnrolledAtAll()
|
|
|
|
|
+ })
|
|
|
|
|
+ describe('alpha user', function () {
|
|
|
|
|
+ tagAlpha()
|
|
|
|
|
+ expectToCollectMetricsAndCachePDF()
|
|
|
|
|
+ })
|
|
|
|
|
+ describe('beta user', function () {
|
|
|
|
|
+ tagBeta()
|
|
|
|
|
+ expectToNotBeEnrolledAtAll()
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ describe('during beta roll-out', function () {
|
|
|
|
|
+ describe('disabled', function () {
|
|
|
|
|
+ showNoVariant()
|
|
|
|
|
+
|
|
|
|
|
+ describe('regular user', function () {
|
|
|
|
|
+ expectToNotBeEnrolledAtAll()
|
|
|
|
|
+ })
|
|
|
|
|
+ describe('anonymous user', function () {
|
|
|
|
|
+ tagAnonymous()
|
|
|
|
|
+ expectToNotBeEnrolledAtAll()
|
|
|
|
|
+ })
|
|
|
|
|
+ describe('alpha user', function () {
|
|
|
|
|
+ tagAlpha()
|
|
|
|
|
+ expectToCollectMetricsAndCachePDF()
|
|
|
|
|
+ })
|
|
|
|
|
+ describe('beta user', function () {
|
|
|
|
|
+ tagBeta()
|
|
|
|
|
+ expectToNotBeEnrolledAtAll()
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ describe('variant=collect-metrics', function () {
|
|
|
|
|
+ showVariant('collect-metrics')
|
|
|
|
|
+
|
|
|
|
|
+ describe('regular user', function () {
|
|
|
|
|
+ expectToNotBeEnrolledAtAll()
|
|
|
|
|
+ })
|
|
|
|
|
+ describe('anonymous user', function () {
|
|
|
|
|
+ tagAnonymous()
|
|
|
|
|
+ expectToNotBeEnrolledAtAll()
|
|
|
|
|
+ })
|
|
|
|
|
+ describe('alpha user', function () {
|
|
|
|
|
+ tagAlpha()
|
|
|
|
|
+ expectToCollectMetricsAndCachePDF()
|
|
|
|
|
+ })
|
|
|
|
|
+ describe('beta user', function () {
|
|
|
|
|
+ tagBeta()
|
|
|
|
|
+ expectToCollectMetricsOnly()
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ describe('variant=collect-metrics-and-enable-caching', function () {
|
|
|
|
|
+ showVariant('collect-metrics-and-enable-caching')
|
|
|
|
|
+
|
|
|
|
|
+ describe('regular user', function () {
|
|
|
|
|
+ expectToNotBeEnrolledAtAll()
|
|
|
|
|
+ })
|
|
|
|
|
+ describe('anonymous user', function () {
|
|
|
|
|
+ tagAnonymous()
|
|
|
|
|
+ expectToNotBeEnrolledAtAll()
|
|
|
|
|
+ })
|
|
|
|
|
+ describe('alpha user', function () {
|
|
|
|
|
+ tagAlpha()
|
|
|
|
|
+ expectToCollectMetricsAndCachePDF()
|
|
|
|
|
+ })
|
|
|
|
|
+ describe('beta user', function () {
|
|
|
|
|
+ tagBeta()
|
|
|
|
|
+ expectToCollectMetricsAndCachePDF()
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ describe('variant=enable-caching-only', function () {
|
|
|
|
|
+ showVariant('enable-caching-only')
|
|
|
|
|
+
|
|
|
|
|
+ describe('regular user', function () {
|
|
|
|
|
+ expectToNotBeEnrolledAtAll()
|
|
|
|
|
+ })
|
|
|
|
|
+ describe('anonymous user', function () {
|
|
|
|
|
+ tagAnonymous()
|
|
|
|
|
+ expectToNotBeEnrolledAtAll()
|
|
|
|
|
+ })
|
|
|
|
|
+ describe('alpha user', function () {
|
|
|
|
|
+ tagAlpha()
|
|
|
|
|
+ expectToCollectMetricsAndCachePDF()
|
|
|
|
|
+ })
|
|
|
|
|
+ describe('beta user', function () {
|
|
|
|
|
+ tagBeta()
|
|
|
|
|
+ expectToCachePDFOnly()
|
|
|
|
|
+ })
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|