Merge pull request #14836 from overleaf/ab-split-test-cache-refactoring
[web] Fetch all active split test into cache at once GitOrigin-RevId: b477b88bf281349433af2cf692a0e9ea5b036588
This commit is contained in:
committed by
Copybot
parent
719da5fbd8
commit
b8a5eca1d0
@@ -22,6 +22,10 @@ describe('SplitTestHandler', function () {
|
||||
versionNumber: 2,
|
||||
}),
|
||||
]
|
||||
this.cachedSplitTests = new Map()
|
||||
for (const splitTest of this.splitTests) {
|
||||
this.cachedSplitTests.set(splitTest.name, splitTest)
|
||||
}
|
||||
|
||||
this.UserGetter = {
|
||||
promises: {
|
||||
@@ -36,11 +40,9 @@ describe('SplitTestHandler', function () {
|
||||
}
|
||||
|
||||
this.SplitTestCache = {
|
||||
get: sinon.stub().resolves(null),
|
||||
}
|
||||
for (const splitTest of this.splitTests) {
|
||||
this.SplitTestCache.get.withArgs(splitTest.name).resolves(splitTest)
|
||||
get: sinon.stub().resolves({}),
|
||||
}
|
||||
this.SplitTestCache.get.resolves(this.cachedSplitTests)
|
||||
this.Settings = {
|
||||
moduleImportSequence: [],
|
||||
overleaf: {},
|
||||
@@ -203,22 +205,29 @@ describe('SplitTestHandler', function () {
|
||||
this.AnalyticsManager.getIdsFromSession.returns({
|
||||
userId: 'abc123abc123',
|
||||
})
|
||||
this.SplitTestCache.get.returns({
|
||||
name: 'my-test-name',
|
||||
versions: [
|
||||
{
|
||||
versionNumber: 0,
|
||||
active: true,
|
||||
variants: [
|
||||
{
|
||||
name: '100-percent-variant',
|
||||
rolloutPercent: 100,
|
||||
rolloutStripes: [{ start: 0, end: 100 }],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
})
|
||||
this.SplitTestCache.get.resolves(
|
||||
new Map([
|
||||
[
|
||||
'my-test-name',
|
||||
{
|
||||
name: 'my-test-name',
|
||||
versions: [
|
||||
{
|
||||
versionNumber: 0,
|
||||
active: true,
|
||||
variants: [
|
||||
{
|
||||
name: '100-percent-variant',
|
||||
rolloutPercent: 100,
|
||||
rolloutStripes: [{ start: 0, end: 100 }],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
])
|
||||
)
|
||||
|
||||
const assignment = await this.SplitTestHandler.promises.getAssignment(
|
||||
this.req,
|
||||
|
||||
Reference in New Issue
Block a user