Skip to content

Commit 8fd99a0

Browse files
committed
Don't serve ab tests set to off
1 parent c2e2d9f commit 8fd99a0

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

ab-testing/scripts/build/calculate-mvt-updates.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,3 +602,28 @@ Deno.test(
602602
);
603603
},
604604
);
605+
606+
Deno.test(
607+
'calculateSpaceUpdates - tests that are switched off should have expiration of 0',
608+
() => {
609+
const existingAudienceSpace = createMockAudienceSpace({
610+
'commercial-test1:control': [0, 1],
611+
'commercial-test1:variant': [2, 3],
612+
});
613+
614+
const tests = [
615+
createMockABTest('commercial-test1', {
616+
audienceSize: 0.002,
617+
groups: ['control', 'variant'],
618+
status: 'OFF', // Test is switched off
619+
}),
620+
];
621+
622+
const result = calculateSpaceUpdates(existingAudienceSpace, tests);
623+
624+
// All entries for the test should have exp set to 0
625+
result.forEach((entry) => {
626+
assertEquals(entry.exp, 0);
627+
});
628+
},
629+
);

ab-testing/scripts/build/calculate-mvt-updates.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ export const calculateSpaceUpdates = (
2222
name: test.name,
2323
type: test.type,
2424
audienceSize: test.audienceSize / test.groups.length,
25-
expirationDate: test.expirationDate,
25+
// If the test is OFF we set the expiration to 0 so it is not served by Fastly
26+
expirationDate:
27+
test.status === 'OFF' ? 0 : test.expirationDate,
2628
group,
2729
},
2830
]),

0 commit comments

Comments
 (0)