@@ -28,7 +28,8 @@ const {
28
28
BIDDER_DONE ,
29
29
BID_WON ,
30
30
BID_TIMEOUT ,
31
- BILLABLE_EVENT
31
+ BILLABLE_EVENT ,
32
+ SEAT_NON_BID
32
33
}
33
34
} = CONSTANTS ;
34
35
@@ -160,6 +161,16 @@ const MOCK = {
160
161
'status' : 'rendered' ,
161
162
getStatusCode : ( ) => 1 ,
162
163
} ,
164
+ SEAT_NON_BID : {
165
+ auctionId : '99785e47-a7c8-4c8a-ae05-ef1c717a4b4d' ,
166
+ seatnonbid : [ {
167
+ seat : 'rubicon' ,
168
+ nonbid : [ {
169
+ status : 1 ,
170
+ impid : 'box'
171
+ } ]
172
+ } ]
173
+ } ,
163
174
AUCTION_END : {
164
175
'auctionId' : '99785e47-a7c8-4c8a-ae05-ef1c717a4b4d' ,
165
176
'auctionEnd' : 1658868384019 ,
@@ -2039,4 +2050,121 @@ describe('magnite analytics adapter', function () {
2039
2050
}
2040
2051
} )
2041
2052
} ) ;
2053
+
2054
+ describe ( 'BID_RESPONSE events' , ( ) => {
2055
+ beforeEach ( ( ) => {
2056
+ magniteAdapter . enableAnalytics ( {
2057
+ options : {
2058
+ endpoint : '//localhost:9999/event' ,
2059
+ accountId : 1001
2060
+ }
2061
+ } ) ;
2062
+ config . setConfig ( { rubicon : { updatePageView : true } } ) ;
2063
+ } ) ;
2064
+
2065
+ it ( 'should add a no-bid bid to the add unit if it recieves one from the server' , ( ) => {
2066
+ const bidResponse = utils . deepClone ( MOCK . BID_RESPONSE ) ;
2067
+ const auctionInit = utils . deepClone ( MOCK . AUCTION_INIT ) ;
2068
+
2069
+ bidResponse . requestId = 'fakeId' ;
2070
+ bidResponse . seatBidId = 'fakeId' ;
2071
+
2072
+ bidResponse . requestId = 'fakeId' ;
2073
+ events . emit ( AUCTION_INIT , auctionInit ) ;
2074
+ events . emit ( BID_REQUESTED , MOCK . BID_REQUESTED ) ;
2075
+ events . emit ( BID_RESPONSE , bidResponse )
2076
+ events . emit ( BIDDER_DONE , MOCK . BIDDER_DONE ) ;
2077
+ events . emit ( AUCTION_END , MOCK . AUCTION_END ) ;
2078
+ clock . tick ( rubiConf . analyticsBatchTimeout + 1000 ) ;
2079
+
2080
+ let message = JSON . parse ( server . requests [ 0 ] . requestBody ) ;
2081
+ expect ( utils . generateUUID . called ) . to . equal ( true ) ;
2082
+
2083
+ expect ( message . auctions [ 0 ] . adUnits [ 0 ] . bids [ 1 ] ) . to . deep . equal (
2084
+ {
2085
+ bidder : 'rubicon' ,
2086
+ source : 'server' ,
2087
+ status : 'success' ,
2088
+ bidResponse : {
2089
+ 'bidPriceUSD' : 3.4 ,
2090
+ 'dimensions' : {
2091
+ 'height' : 250 ,
2092
+ 'width' : 300
2093
+ } ,
2094
+ 'mediaType' : 'banner'
2095
+ } ,
2096
+ oldBidId : 'fakeId' ,
2097
+ unknownBid : true ,
2098
+ bidId : 'fakeId' ,
2099
+ clientLatencyMillis : 271
2100
+ }
2101
+ ) ;
2102
+ } ) ;
2103
+ } ) ;
2104
+
2105
+ describe ( 'SEAT_NON_BID events' , ( ) => {
2106
+ let seatnonbid ;
2107
+
2108
+ const runNonBidAuction = ( ) => {
2109
+ events . emit ( AUCTION_INIT , MOCK . AUCTION_INIT ) ;
2110
+ events . emit ( BID_REQUESTED , MOCK . BID_REQUESTED ) ;
2111
+ events . emit ( SEAT_NON_BID , seatnonbid )
2112
+ events . emit ( BIDDER_DONE , MOCK . BIDDER_DONE ) ;
2113
+ events . emit ( AUCTION_END , MOCK . AUCTION_END ) ;
2114
+ clock . tick ( rubiConf . analyticsBatchTimeout + 1000 ) ;
2115
+ } ;
2116
+ const checkStatusAgainstCode = ( status , code , error , index ) => {
2117
+ seatnonbid . seatnonbid [ 0 ] . nonbid [ 0 ] . status = code ;
2118
+ runNonBidAuction ( ) ;
2119
+ let message = JSON . parse ( server . requests [ index ] . requestBody ) ;
2120
+ let bid = message . auctions [ 0 ] . adUnits [ 0 ] . bids [ 1 ] ;
2121
+
2122
+ if ( error ) {
2123
+ expect ( bid . error ) . to . deep . equal ( error ) ;
2124
+ } else {
2125
+ expect ( bid . error ) . to . equal ( undefined ) ;
2126
+ }
2127
+ expect ( bid . source ) . to . equal ( 'server' ) ;
2128
+ expect ( bid . status ) . to . equal ( status ) ;
2129
+ expect ( bid . isSeatNonBid ) . to . equal ( true ) ;
2130
+ } ;
2131
+ beforeEach ( ( ) => {
2132
+ magniteAdapter . enableAnalytics ( {
2133
+ options : {
2134
+ endpoint : '//localhost:9999/event' ,
2135
+ accountId : 1001
2136
+ }
2137
+ } ) ;
2138
+ seatnonbid = utils . deepClone ( MOCK . SEAT_NON_BID ) ;
2139
+ } ) ;
2140
+
2141
+ it ( 'adds seatnonbid info to bids array' , ( ) => {
2142
+ runNonBidAuction ( ) ;
2143
+ let message = JSON . parse ( server . requests [ 0 ] . requestBody ) ;
2144
+
2145
+ expect ( message . auctions [ 0 ] . adUnits [ 0 ] . bids [ 1 ] ) . to . deep . equal (
2146
+ {
2147
+ bidder : 'rubicon' ,
2148
+ source : 'server' ,
2149
+ status : 'no-bid' ,
2150
+ isSeatNonBid : true ,
2151
+ clientLatencyMillis : - 139101369960
2152
+ }
2153
+ ) ;
2154
+ } ) ;
2155
+
2156
+ it ( 'adjusts the status according to the status map' , ( ) => {
2157
+ const statuses = [
2158
+ { code : 0 , status : 'no-bid' } ,
2159
+ { code : 100 , status : 'error' , error : { code : 'request-error' , description : 'general error' } } ,
2160
+ { code : 101 , status : 'error' , error : { code : 'timeout-error' , description : 'prebid server timeout' } } ,
2161
+ { code : 200 , status : 'rejected' } ,
2162
+ { code : 202 , status : 'rejected' } ,
2163
+ { code : 301 , status : 'rejected-ipf' }
2164
+ ] ;
2165
+ statuses . forEach ( ( info , index ) => {
2166
+ checkStatusAgainstCode ( info . status , info . code , info . error , index ) ;
2167
+ } ) ;
2168
+ } ) ;
2169
+ } ) ;
2042
2170
} ) ;
0 commit comments