@@ -3,7 +3,6 @@ import { describe, expect, test } from 'bun:test'
33import {
44 DEFAULT_FIRST_PARTY_BACKFILL ,
55 DEFAULT_FIRST_PARTY_PRIMARY_PERCENT ,
6- IMPREZIA_EXPERIMENT_PERCENT ,
76 adExperimentArmForUser ,
87 firstPartyAdRouteForUser ,
98 firstPartyAdRouteForGeoRequest ,
@@ -42,42 +41,21 @@ describe('house subscription billing experiment', () => {
4241} )
4342
4443describe ( 'imprezia experiment arm' , ( ) => {
45- test ( 'signed-out sessions stay in control' , ( ) => {
46- for ( const id of [ null , undefined , '' ] ) {
44+ test ( 'keeps ordinary, signed-out, and former preview users in control' , ( ) => {
45+ for ( const id of [ null , undefined , '' , 'user-42' ] ) {
4746 expect ( adExperimentArmForUser ( id ) ) . toBe ( 'control' )
4847 }
49- } )
50-
51- test ( 'a user gets the same arm every time' , ( ) => {
52- for ( const id of [ 'abc' , 'user-42' , 'a-very-long-uuid-like-identifier' ] ) {
53- const first = adExperimentArmForUser ( id )
54- for ( let i = 0 ; i < 20 ; i ++ ) {
55- expect ( adExperimentArmForUser ( id ) ) . toBe ( first )
56- }
57- }
58- } )
59-
60- test ( `puts ~${ IMPREZIA_EXPERIMENT_PERCENT } % of users in the arm` , ( ) => {
61- const N = 20_000
62- let inArm = 0
63- for ( let i = 0 ; i < N ; i ++ ) {
64- if ( adExperimentArmForUser ( `user-${ i } ` ) === 'imprezia_first' ) inArm ++
48+ for ( const email of [ 'dev@Imprezia.AI' , 'jahooma@gmail.com' ] ) {
49+ expect ( adExperimentArmForUser ( 'user' , email ) ) . toBe ( 'control' )
6550 }
66- const percent = ( inArm / N ) * 100
67- // FNV-1a over sequential ids is not a perfect uniform source, so allow a
68- // point of slack rather than asserting an exact count.
69- expect ( percent ) . toBeGreaterThan ( IMPREZIA_EXPERIMENT_PERCENT - 1.5 )
70- expect ( percent ) . toBeLessThan ( IMPREZIA_EXPERIMENT_PERCENT + 1.5 )
7151 } )
7252
73- test ( 'forces only the Imprezia domain and named test account' , ( ) => {
74- for ( const email of [ 'dev@Imprezia.AI' , 'jahooma@gmail.com' ] ) {
75- expect ( isImpreziaAudienceEmail ( email ) ) . toBe ( true )
76- expect ( adExperimentArmForUser ( 'user' , email ) ) . toBe ( 'imprezia_forced' )
77- }
53+ test ( 'removes the personal account from the legacy preview audience' , ( ) => {
54+ expect ( isImpreziaAudienceEmail ( 'dev@Imprezia.AI' ) ) . toBe ( true )
7855 for ( const email of [
56+ 'jahooma@gmail.com' ,
57+ ' JAHOOMA@gmail.com ' ,
7958 'dev@imprezia.ai.evil.com' ,
80- 'jahooma+test@gmail.com' ,
8159 ] ) {
8260 expect ( isImpreziaAudienceEmail ( email ) ) . toBe ( false )
8361 }
@@ -231,7 +209,6 @@ describe('first-party request routing', () => {
231209 {
232210 geoTier : 'tier1' ,
233211 terminalPaidFallback : false ,
234- impreziaFirstRefusal : false ,
235212 } ,
236213 'sample' ,
237214 ) ,
@@ -252,7 +229,6 @@ describe('first-party request routing', () => {
252229 {
253230 geoTier : 'tier2' ,
254231 terminalPaidFallback : false ,
255- impreziaFirstRefusal : false ,
256232 } ,
257233 'sample' ,
258234 ) ,
@@ -264,7 +240,6 @@ describe('first-party request routing', () => {
264240 {
265241 geoTier : 'tier2' ,
266242 terminalPaidFallback : true ,
267- impreziaFirstRefusal : false ,
268243 } ,
269244 'sample' ,
270245 ) ,
@@ -276,7 +251,6 @@ describe('first-party request routing', () => {
276251 {
277252 geoTier : 'unknown' ,
278253 terminalPaidFallback : true ,
279- impreziaFirstRefusal : false ,
280254 } ,
281255 'sample' ,
282256 ) ,
@@ -296,176 +270,13 @@ describe('first-party request routing', () => {
296270 {
297271 geoTier : 'unknown' ,
298272 terminalPaidFallback : false ,
299- impreziaFirstRefusal : false ,
300273 } ,
301274 'sample' ,
302275 ) ,
303276 ) . toBe ( 'gravity_then_first_party' )
304277 } )
305278} )
306279
307- describe ( 'first-party ahead of Imprezia (COD-338)' , ( ) => {
308- const config = {
309- primaryPercent : 0 ,
310- backfill : false ,
311- geoRouting : true ,
312- tier2BonusPercent : 0 ,
313- impreziaArmPercent : 100 ,
314- }
315- const tier1 = { geoTier : 'tier1' as const , terminalPaidFallback : false }
316-
317- test ( 'routes ahead of Imprezia only where Imprezia holds first refusal' , ( ) => {
318- expect (
319- firstPartyAdRouteForGeoRequest (
320- 'user' ,
321- config ,
322- { ...tier1 , impreziaFirstRefusal : true } ,
323- 'sample' ,
324- ) ,
325- ) . toBe ( 'first_party_before_imprezia' )
326- expect (
327- firstPartyAdRouteForGeoRequest (
328- 'user' ,
329- config ,
330- { ...tier1 , impreziaFirstRefusal : false } ,
331- 'sample' ,
332- ) ,
333- ) . toBe ( 'paid_network_only' )
334- } )
335-
336- test ( 'never fires outside Tier 1, with geo routing off, at 0, or unset' , ( ) => {
337- const refusal = { terminalPaidFallback : true , impreziaFirstRefusal : true }
338- expect (
339- firstPartyAdRouteForGeoRequest (
340- 'user' ,
341- config ,
342- { geoTier : 'tier2' , ...refusal } ,
343- 'sample' ,
344- ) ,
345- ) . toBe ( 'paid_network_only' )
346- expect (
347- firstPartyAdRouteForGeoRequest (
348- 'user' ,
349- config ,
350- { geoTier : 'unknown' , ...refusal } ,
351- 'sample' ,
352- ) ,
353- ) . toBe ( 'paid_network_only' )
354- expect (
355- firstPartyAdRouteForGeoRequest (
356- 'user' ,
357- { ...config , geoRouting : false } ,
358- { geoTier : 'tier1' , ...refusal } ,
359- 'sample' ,
360- ) ,
361- ) . toBe ( 'paid_network_only' )
362- expect (
363- firstPartyAdRouteForGeoRequest (
364- 'user' ,
365- { ...config , impreziaArmPercent : 0 } ,
366- { geoTier : 'tier1' , ...refusal } ,
367- 'sample' ,
368- ) ,
369- ) . toBe ( 'paid_network_only' )
370- expect (
371- firstPartyAdRouteForGeoRequest (
372- 'user' ,
373- {
374- primaryPercent : 0 ,
375- backfill : false ,
376- geoRouting : true ,
377- tier2BonusPercent : 0 ,
378- } ,
379- { geoTier : 'tier1' , ...refusal } ,
380- 'sample' ,
381- ) ,
382- ) . toBe ( 'paid_network_only' )
383- } )
384-
385- test ( 'the primary window wins and the arm window stacks above it' , ( ) => {
386- const context = { ...tier1 , impreziaFirstRefusal : true }
387- let primary = 0
388- let preempt = 0
389- let paidOnly = 0
390- for ( let index = 0 ; index < 4_000 ; index ++ ) {
391- const route = firstPartyAdRouteForGeoRequest (
392- 'user' ,
393- { ...config , primaryPercent : 25 , impreziaArmPercent : 50 } ,
394- context ,
395- `sample-${ index } ` ,
396- )
397- if ( route === 'first_party_primary' ) primary ++
398- else if ( route === 'first_party_before_imprezia' ) preempt ++
399- else if ( route === 'paid_network_only' ) paidOnly ++
400- else throw new Error ( `unexpected route ${ route } ` )
401- }
402- expect ( primary / 4_000 ) . toBeGreaterThan ( 0.21 )
403- expect ( primary / 4_000 ) . toBeLessThan ( 0.29 )
404- expect ( preempt / 4_000 ) . toBeGreaterThan ( 0.46 )
405- expect ( preempt / 4_000 ) . toBeLessThan ( 0.54 )
406- expect ( paidOnly / 4_000 ) . toBeGreaterThan ( 0.21 )
407- expect ( paidOnly / 4_000 ) . toBeLessThan ( 0.29 )
408- } )
409-
410- test ( 'a stack past 100% takes every remaining request and nothing more' , ( ) => {
411- const context = { ...tier1 , impreziaFirstRefusal : true }
412- for ( let index = 0 ; index < 1_000 ; index ++ ) {
413- const route = firstPartyAdRouteForGeoRequest (
414- 'user' ,
415- { ...config , primaryPercent : 60 , impreziaArmPercent : 75 } ,
416- context ,
417- `sample-${ index } ` ,
418- )
419- expect (
420- route === 'first_party_primary' ||
421- route === 'first_party_before_imprezia' ,
422- ) . toBe ( true )
423- }
424- } )
425-
426- test ( 'the primary window is identical with and without first refusal' , ( ) => {
427- for ( let index = 0 ; index < 2_000 ; index ++ ) {
428- const sampleId = `sample-${ index } `
429- const withRefusal = firstPartyAdRouteForGeoRequest (
430- 'user' ,
431- { ...config , primaryPercent : 30 , backfill : true } ,
432- { ...tier1 , impreziaFirstRefusal : true } ,
433- sampleId ,
434- )
435- const without = firstPartyAdRouteForGeoRequest (
436- 'user' ,
437- { ...config , primaryPercent : 30 , backfill : true } ,
438- { ...tier1 , impreziaFirstRefusal : false } ,
439- sampleId ,
440- )
441- expect ( withRefusal === 'first_party_primary' ) . toBe (
442- without === 'first_party_primary' ,
443- )
444- if ( withRefusal !== 'first_party_before_imprezia' ) {
445- expect ( withRefusal ) . toBe ( without )
446- }
447- }
448- } )
449-
450- test ( 'backfill stays the route when the sample misses the arm window' , ( ) => {
451- let backfill = 0
452- for ( let index = 0 ; index < 2_000 ; index ++ ) {
453- if (
454- firstPartyAdRouteForGeoRequest (
455- 'user' ,
456- { ...config , backfill : true , impreziaArmPercent : 50 } ,
457- { ...tier1 , impreziaFirstRefusal : true } ,
458- `sample-${ index } ` ,
459- ) === 'gravity_then_first_party'
460- ) {
461- backfill ++
462- }
463- }
464- expect ( backfill / 2_000 ) . toBeGreaterThan ( 0.46 )
465- expect ( backfill / 2_000 ) . toBeLessThan ( 0.54 )
466- } )
467- } )
468-
469280describe ( 'the house leg (COD-358)' , ( ) => {
470281 test ( 'opens on Tier 1 and Tier 2, never on unknown geo, never signed out, never off' , ( ) => {
471282 const on = { houseLeg : true , geoRouting : true }
0 commit comments