@@ -50,4 +50,63 @@ describe('notebooklm automatic binding', () => {
5050 await expect ( ensureNotebooklmNotebookBinding ( page as any ) ) . resolves . toBe ( false ) ;
5151 expect ( mockBindCurrentTab ) . not . toHaveBeenCalled ( ) ;
5252 } ) ;
53+
54+ it ( 'does not rebind to another notebook when the real page is already a notebook add-source url' , async ( ) => {
55+ const page = {
56+ getCurrentUrl : async ( ) => 'https://notebooklm.google.com/' ,
57+ evaluate : vi . fn ( async ( ) => ( {
58+ url : 'https://notebooklm.google.com/notebook/nb-demo?addSource=true' ,
59+ title : 'NotebookLM' ,
60+ hostname : 'notebooklm.google.com' ,
61+ kind : 'notebook' ,
62+ notebookId : 'nb-demo' ,
63+ loginRequired : false ,
64+ notebookCount : 1 ,
65+ path : '/notebook/nb-demo' ,
66+ } ) ) ,
67+ goto : vi . fn ( async ( ) => undefined ) ,
68+ wait : vi . fn ( async ( ) => undefined ) ,
69+ } ;
70+
71+ await expect ( ensureNotebooklmNotebookBinding ( page as any ) ) . resolves . toBe ( false ) ;
72+ expect ( mockBindCurrentTab ) . not . toHaveBeenCalled ( ) ;
73+ expect ( page . goto ) . toHaveBeenCalledWith ( 'https://notebooklm.google.com/notebook/nb-demo' ) ;
74+ } ) ;
75+
76+ it ( 'canonicalizes the bound notebook page after bind-current lands on add-source' , async ( ) => {
77+ const page = {
78+ getCurrentUrl : async ( ) => 'https://notebooklm.google.com/' ,
79+ evaluate : vi . fn ( )
80+ . mockResolvedValueOnce ( {
81+ url : 'https://notebooklm.google.com/' ,
82+ title : 'NotebookLM' ,
83+ hostname : 'notebooklm.google.com' ,
84+ kind : 'home' ,
85+ notebookId : '' ,
86+ loginRequired : false ,
87+ notebookCount : 1 ,
88+ path : '/' ,
89+ } )
90+ . mockResolvedValueOnce ( {
91+ url : 'https://notebooklm.google.com/notebook/nb-live?addSource=true' ,
92+ title : 'NotebookLM' ,
93+ hostname : 'notebooklm.google.com' ,
94+ kind : 'notebook' ,
95+ notebookId : 'nb-live' ,
96+ loginRequired : false ,
97+ notebookCount : 1 ,
98+ path : '/notebook/nb-live' ,
99+ } ) ,
100+ goto : vi . fn ( async ( ) => undefined ) ,
101+ wait : vi . fn ( async ( ) => undefined ) ,
102+ } ;
103+
104+ mockBindCurrentTab . mockResolvedValue ( { } ) ;
105+ await expect ( ensureNotebooklmNotebookBinding ( page as any ) ) . resolves . toBe ( true ) ;
106+ expect ( mockBindCurrentTab ) . toHaveBeenCalledWith ( 'site:notebooklm' , {
107+ matchDomain : 'notebooklm.google.com' ,
108+ matchPathPrefix : '/notebook/' ,
109+ } ) ;
110+ expect ( page . goto ) . toHaveBeenCalledWith ( 'https://notebooklm.google.com/notebook/nb-live' ) ;
111+ } ) ;
53112} ) ;
0 commit comments