@@ -233,6 +233,54 @@ describe('PageManager tests', () => {
233233 // Assert
234234 expect ( pageManager . getPage ( ) ?. interaction ) . toEqual ( 1 ) ;
235235
236+ // Assert
237+ expect ( pageManager . getAttributes ( ) ) . toMatchObject ( {
238+ pageId : '/console/home' ,
239+ interaction : 1
240+ } ) ;
241+
242+ window . removeEventListener (
243+ 'popstate' ,
244+ ( pageManager as any ) . popstateListener
245+ ) ;
246+ } ) ;
247+
248+ test ( 'when session resumes and page is manually recorded with custom page attributes then custom page attributes are restored' , async ( ) => {
249+ // Init
250+ const pageManager : PageManager = new PageManager (
251+ {
252+ ...DEFAULT_CONFIG ,
253+ allowCookies : true
254+ } ,
255+ record
256+ ) ;
257+
258+ pageManager . resumeSession ( {
259+ pageId : '/console/home' ,
260+ interaction : 1 ,
261+ start : Date . now ( )
262+ } ) ;
263+
264+ pageManager . recordPageView ( {
265+ pageId : '/console/home' ,
266+ pageTags : [ 'pageGroup1' ] ,
267+ pageAttributes : {
268+ customPageAttributeString : 'customPageAttributeValue' ,
269+ customPageAttributeNumber : 1 ,
270+ customPageAttributeBoolean : true
271+ }
272+ } ) ;
273+
274+ // Assert
275+ expect ( record . mock . calls ) . toHaveLength ( 0 ) ; // No event emitted, but attributes restored in PageManager state
276+ expect ( pageManager . getAttributes ( ) ) . toMatchObject ( {
277+ pageId : '/console/home' ,
278+ pageTags : [ 'pageGroup1' ] ,
279+ customPageAttributeString : 'customPageAttributeValue' ,
280+ customPageAttributeNumber : 1 ,
281+ customPageAttributeBoolean : true
282+ } ) ;
283+
236284 window . removeEventListener (
237285 'popstate' ,
238286 ( pageManager as any ) . popstateListener
0 commit comments