@@ -4,12 +4,15 @@ import { loadExternalScriptStub } from 'test/mocks/adloaderStub.js';
4
4
import { getStorageManager } from '../../../src/storageManager.js' ;
5
5
import { MODULE_TYPE_UID } from '../../../src/activities/modules.js' ;
6
6
import * as events from '../../../src/events' ;
7
+ import * as utils from 'src/utils.js' ;
7
8
import Sinon from 'sinon' ;
9
+ import { deepClone } from '../../../src/utils.js' ;
8
10
9
11
const MODULE_NAME = 'contxtful' ;
10
12
11
13
const VERSION = 'v1' ;
12
14
const CUSTOMER = 'CUSTOMER' ;
15
+ const SM = 'SM' ;
13
16
const CONTXTFUL_CONNECTOR_ENDPOINT = `https://api.receptivity.io/${ VERSION } /prebid/${ CUSTOMER } /connector/rxConnector.js` ;
14
17
15
18
const RX_FROM_SESSION_STORAGE = { ReceptivityState : 'Receptive' , test_info : 'rx_from_session_storage' } ;
@@ -62,6 +65,8 @@ describe('contxtfulRtdProvider', function () {
62
65
63
66
eventsEmitSpy = sandbox . spy ( events , [ 'emit' ] ) ;
64
67
68
+ sandbox . stub ( utils , 'generateUUID' ) . returns ( SM ) ;
69
+
65
70
let tagId = CUSTOMER ;
66
71
sessionStorage . clear ( ) ;
67
72
} ) ;
@@ -534,6 +539,7 @@ describe('contxtfulRtdProvider', function () {
534
539
name : 'contxtful' ,
535
540
ext : {
536
541
rx : RX_FROM_API ,
542
+ sm : SM ,
537
543
params : {
538
544
ev : config . params ?. version ,
539
545
ci : config . params ?. customer ,
@@ -549,11 +555,40 @@ describe('contxtfulRtdProvider', function () {
549
555
550
556
expect ( data . name ) . to . deep . equal ( expectedData . name ) ;
551
557
expect ( data . ext . rx ) . to . deep . equal ( expectedData . ext . rx ) ;
558
+ expect ( data . ext . sm ) . to . deep . equal ( expectedData . ext . sm ) ;
552
559
expect ( data . ext . params ) . to . deep . equal ( expectedData . ext . params ) ;
553
560
done ( ) ;
554
561
} , TIMEOUT ) ;
555
562
} ) ;
556
563
564
+ it ( 'does not change the sm' , function ( done ) {
565
+ let config = buildInitConfig ( VERSION , CUSTOMER ) ;
566
+ contxtfulSubmodule . init ( config ) ;
567
+ window . dispatchEvent ( RX_CONNECTOR_IS_READY_EVENT ) ;
568
+
569
+ let firstReqBidsConfigObj = {
570
+ ortb2Fragments : {
571
+ global : { } ,
572
+ bidder : { } ,
573
+ } ,
574
+ } ;
575
+
576
+ let secondReqBidsConfigObj = deepClone ( firstReqBidsConfigObj ) ;
577
+
578
+ setTimeout ( ( ) => {
579
+ const onDoneSpy = sinon . spy ( ) ;
580
+ contxtfulSubmodule . getBidRequestData ( firstReqBidsConfigObj , onDoneSpy , config ) ;
581
+ contxtfulSubmodule . getBidRequestData ( secondReqBidsConfigObj , onDoneSpy , config ) ;
582
+
583
+ let firstData = firstReqBidsConfigObj . ortb2Fragments . bidder [ config . params . bidders [ 0 ] ] . user . data [ 0 ] ;
584
+ let secondData = secondReqBidsConfigObj . ortb2Fragments . bidder [ config . params . bidders [ 0 ] ] . user . data [ 0 ] ;
585
+
586
+ expect ( firstData . ext . sm ) . to . equal ( secondData . ext . sm ) ;
587
+
588
+ done ( ) ;
589
+ } , TIMEOUT ) ;
590
+ } ) ;
591
+
557
592
describe ( 'before rxApi is loaded' , function ( ) {
558
593
const moveEventTheories = [
559
594
[
@@ -628,7 +663,7 @@ describe('contxtfulRtdProvider', function () {
628
663
} ) ;
629
664
630
665
describe ( 'after rxApi is loaded' , function ( ) {
631
- it ( 'does not add event' , function ( done ) {
666
+ it ( 'should add event' , function ( done ) {
632
667
let config = buildInitConfig ( VERSION , CUSTOMER ) ;
633
668
contxtfulSubmodule . init ( config ) ;
634
669
window . dispatchEvent ( RX_CONNECTOR_IS_READY_EVENT ) ;
@@ -648,7 +683,7 @@ describe('contxtfulRtdProvider', function () {
648
683
649
684
let events = ext . events ;
650
685
651
- expect ( events ) . to . be . undefined ;
686
+ expect ( events ) . to . be . not . undefined ;
652
687
done ( ) ;
653
688
} , TIMEOUT ) ;
654
689
} ) ;
0 commit comments