@@ -434,6 +434,7 @@ describe('EppoClient Bandits E2E test', () => {
434
434
describe ( 'Assignment logging deduplication' , ( ) => {
435
435
let mockEvaluateFlag : jest . SpyInstance ;
436
436
let mockEvaluateBandit : jest . SpyInstance ;
437
+ // The below two variables allow easily changing what the mock evaluation functions return throughout the test
437
438
let variationToReturn : string ;
438
439
let actionToReturn : string | null ;
439
440
@@ -485,6 +486,7 @@ describe('EppoClient Bandits E2E test', () => {
485
486
486
487
afterEach ( ( ) => {
487
488
client . disableAssignmentCache ( ) ;
489
+ client . disableBanditAssignmentCache ( ) ;
488
490
} ) ;
489
491
490
492
afterAll ( ( ) => {
@@ -500,8 +502,8 @@ describe('EppoClient Bandits E2E test', () => {
500
502
501
503
expect ( firstNonBanditAssignment . variation ) . toBe ( 'non-bandit' ) ;
502
504
expect ( firstNonBanditAssignment . action ) . toBeNull ( ) ;
503
- expect ( mockLogAssignment ) . toHaveBeenCalledTimes ( 1 ) ;
504
- expect ( mockLogBanditAction ) . not . toHaveBeenCalled ( ) ;
505
+ expect ( mockLogAssignment ) . toHaveBeenCalledTimes ( 1 ) ; // new variation assignment
506
+ expect ( mockLogBanditAction ) . not . toHaveBeenCalled ( ) ; // no bandit assignment
505
507
506
508
// Assign bandit action
507
509
variationToReturn = 'banner_bandit' ;
@@ -510,8 +512,8 @@ describe('EppoClient Bandits E2E test', () => {
510
512
511
513
expect ( firstBanditAssignment . variation ) . toBe ( 'banner_bandit' ) ;
512
514
expect ( firstBanditAssignment . action ) . toBe ( 'toyota' ) ;
513
- expect ( mockLogAssignment ) . toHaveBeenCalledTimes ( 2 ) ;
514
- expect ( mockLogBanditAction ) . toHaveBeenCalledTimes ( 1 ) ;
515
+ expect ( mockLogAssignment ) . toHaveBeenCalledTimes ( 2 ) ; // new variation assignment
516
+ expect ( mockLogBanditAction ) . toHaveBeenCalledTimes ( 1 ) ; // new bandit assignment
515
517
516
518
// Repeat bandit action assignment
517
519
variationToReturn = 'banner_bandit' ;
@@ -520,8 +522,8 @@ describe('EppoClient Bandits E2E test', () => {
520
522
521
523
expect ( secondBanditAssignment . variation ) . toBe ( 'banner_bandit' ) ;
522
524
expect ( secondBanditAssignment . action ) . toBe ( 'toyota' ) ;
523
- expect ( mockLogAssignment ) . toHaveBeenCalledTimes ( 2 ) ;
524
- expect ( mockLogBanditAction ) . toHaveBeenCalledTimes ( 1 ) ;
525
+ expect ( mockLogAssignment ) . toHaveBeenCalledTimes ( 2 ) ; // repeat variation assignment
526
+ expect ( mockLogBanditAction ) . toHaveBeenCalledTimes ( 1 ) ; // repeat bandit assignment
525
527
526
528
// New bandit action assignment
527
529
variationToReturn = 'banner_bandit' ;
@@ -530,8 +532,8 @@ describe('EppoClient Bandits E2E test', () => {
530
532
531
533
expect ( thirdBanditAssignment . variation ) . toBe ( 'banner_bandit' ) ;
532
534
expect ( thirdBanditAssignment . action ) . toBe ( 'honda' ) ;
533
- expect ( mockLogAssignment ) . toHaveBeenCalledTimes ( 2 ) ;
534
- expect ( mockLogBanditAction ) . toHaveBeenCalledTimes ( 2 ) ;
535
+ expect ( mockLogAssignment ) . toHaveBeenCalledTimes ( 2 ) ; // repeat variation assignment
536
+ expect ( mockLogBanditAction ) . toHaveBeenCalledTimes ( 2 ) ; // new bandit assignment
535
537
536
538
// Flip-flop to an earlier action assignment
537
539
variationToReturn = 'banner_bandit' ;
@@ -540,8 +542,8 @@ describe('EppoClient Bandits E2E test', () => {
540
542
541
543
expect ( fourthBanditAssignment . variation ) . toBe ( 'banner_bandit' ) ;
542
544
expect ( fourthBanditAssignment . action ) . toBe ( 'toyota' ) ;
543
- expect ( mockLogAssignment ) . toHaveBeenCalledTimes ( 2 ) ;
544
- expect ( mockLogBanditAction ) . toHaveBeenCalledTimes ( 3 ) ;
545
+ expect ( mockLogAssignment ) . toHaveBeenCalledTimes ( 2 ) ; // repeat variation assignment
546
+ expect ( mockLogBanditAction ) . toHaveBeenCalledTimes ( 3 ) ; // "new" bandit assignment
545
547
546
548
// Flip-flop back to non-bandit assignment
547
549
variationToReturn = 'non-bandit' ;
@@ -550,8 +552,8 @@ describe('EppoClient Bandits E2E test', () => {
550
552
551
553
expect ( secondNonBanditAssignment . variation ) . toBe ( 'non-bandit' ) ;
552
554
expect ( secondNonBanditAssignment . action ) . toBeNull ( ) ;
553
- expect ( mockLogAssignment ) . toHaveBeenCalledTimes ( 3 ) ;
554
- expect ( mockLogBanditAction ) . toHaveBeenCalledTimes ( 3 ) ;
555
+ expect ( mockLogAssignment ) . toHaveBeenCalledTimes ( 3 ) ; // "new" variation assignment
556
+ expect ( mockLogBanditAction ) . toHaveBeenCalledTimes ( 3 ) ; // no bandit assignment
555
557
} ) ;
556
558
} ) ;
557
559
} ) ;
0 commit comments