Merge pull request #18022 from overleaf/revert-18018-revert-17906-ab-split-test-assignments-optim-pt2

Revert "Revert "[web] Store anonymous users split test assignments in new format in session""

GitOrigin-RevId: bd48a21c17df91eda1536378d8d999a1933e83a2
This commit is contained in:
Alexandre Bourdin
2024-04-23 08:04:47 +00:00
committed by Copybot
parent 10d218fe8f
commit 3022f573e9
5 changed files with 166 additions and 172 deletions
@@ -15,6 +15,45 @@ describe('SplitTestSessionHandler', function () {
}
this.SplitTestUserGetter = {}
this.Metrics = {}
this.SplitTestCache.get = sinon.stub().resolves(
new Map(
Object.entries({
'anon-test-1': {
_id: '661f92a4669764bb03f73e37',
name: 'anon-test-1',
versions: [
{
versionNumber: 1,
variants: [
{
name: 'enabled',
},
],
},
],
},
'anon-test-2': {
_id: '661f92a9d68ea711d6bf2df4',
name: 'anon-test-2',
versions: [
{
versionNumber: 1,
variants: [
{
name: 'v-1',
},
{
name: 'v-2',
},
],
},
],
},
})
)
)
this.SplitTestSessionHandler = SandboxedModule.require(MODULE_PATH, {
requires: {
'./SplitTestCache': this.SplitTestCache,
@@ -152,43 +191,6 @@ describe('SplitTestSessionHandler', function () {
})
it('should merge assignments from both splitTests and sta fields', async function () {
this.SplitTestCache.get = sinon.stub().resolves(
new Map(
Object.entries({
'anon-test-1': {
_id: '661f92a4669764bb03f73e37',
name: 'anon-test-1',
versions: [
{
versionNumber: 1,
variants: [
{
name: 'enabled',
},
],
},
],
},
'anon-test-2': {
_id: '661f92a9d68ea711d6bf2df4',
name: 'anon-test-2',
versions: [
{
versionNumber: 1,
variants: [
{
name: 'v-1',
},
{
name: 'v-2',
},
],
},
],
},
})
)
)
const session = {
splitTests: {
'anon-test-1': [
@@ -223,18 +225,18 @@ describe('SplitTestSessionHandler', function () {
},
],
'anon-test-2': [
{
variantName: 'default',
versionNumber: 1,
phase: 'release',
assignedAt: new Date(1712307600000),
},
{
variantName: 'v-2',
versionNumber: 2,
phase: 'release',
assignedAt: new Date(1712858400000),
},
{
variantName: 'default',
versionNumber: 1,
phase: 'release',
assignedAt: new Date(1712307600000),
},
],
})
})