mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #4136 from overleaf/jel-add-gallery-bundle
Add JS bundle for gallery and begin Algolia/React gallery search migration GitOrigin-RevId: ddce48df9108b4880b39e522c30617fd1a7c0a87
This commit is contained in:
parent
e15b49fa17
commit
fefa4ec391
2 changed files with 61 additions and 0 deletions
9
services/web/app/src/Features/Helpers/FeatureFlag.js
Normal file
9
services/web/app/src/Features/Helpers/FeatureFlag.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
function shouldDisplayFeature(req, name, variantFlag) {
|
||||
if (req.query && req.query[name]) {
|
||||
return req.query[name] === 'true'
|
||||
} else {
|
||||
return variantFlag === true
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { shouldDisplayFeature }
|
52
services/web/test/unit/src/HelperFiles/FeatureFlagTests.js
Normal file
52
services/web/test/unit/src/HelperFiles/FeatureFlagTests.js
Normal file
|
@ -0,0 +1,52 @@
|
|||
const { expect } = require('chai')
|
||||
const SandboxedModule = require('sandboxed-module')
|
||||
const modulePath = require('path').join(
|
||||
__dirname,
|
||||
'../../../../app/src/Features/Helpers/FeatureFlag'
|
||||
)
|
||||
|
||||
describe('FeatureFlag', function () {
|
||||
beforeEach(function () {
|
||||
this.FeatureFlag = SandboxedModule.require(modulePath, {})
|
||||
})
|
||||
|
||||
describe('shouldDisplayFeature', function () {
|
||||
describe('no req.query', function () {
|
||||
const req = {}
|
||||
it('should return false when variantFlag=false', function () {
|
||||
expect(this.FeatureFlag.shouldDisplayFeature(req, '', false)).to.be
|
||||
.false
|
||||
})
|
||||
it('should return true when variantFlag=true', function () {
|
||||
expect(this.FeatureFlag.shouldDisplayFeature(req, '', true)).to.be.true
|
||||
})
|
||||
})
|
||||
|
||||
describe('req.query but no query param', function () {
|
||||
const req = { query: {} }
|
||||
it('should return false when variantFlag=false', function () {
|
||||
expect(this.FeatureFlag.shouldDisplayFeature(req, '', false)).to.be
|
||||
.false
|
||||
})
|
||||
it('should return true when variantFlag=true', function () {
|
||||
expect(this.FeatureFlag.shouldDisplayFeature(req, '', true)).to.be.true
|
||||
})
|
||||
})
|
||||
|
||||
describe('req.query[name] exists', function () {
|
||||
const paramName = 'test'
|
||||
const req = { query: {} }
|
||||
|
||||
it('should return false when value is not "true"', function () {
|
||||
req.query[paramName] = 'nope'
|
||||
expect(this.FeatureFlag.shouldDisplayFeature(req, paramName, false)).to
|
||||
.be.false
|
||||
})
|
||||
it('should return true when value is "true"', function () {
|
||||
req.query[paramName] = 'true'
|
||||
expect(this.FeatureFlag.shouldDisplayFeature(req, paramName, false)).to
|
||||
.be.true
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
Loading…
Reference in a new issue