@@ -32,6 +32,7 @@ const mockProjectManager = {
3232 replayHistory : jest . fn ( ) ,
3333 resetProject : jest . fn ( ) ,
3434 renameProject : jest . fn ( ) ,
35+ initLibraryUI : jest . fn ( ) , // --- FIXED: Added missing mock function
3536} ;
3637const mockMapManager = {
3738 updateTheme : jest . fn ( ) ,
@@ -166,6 +167,12 @@ describe('UI Module Consolidated', () => {
166167 writable : true ,
167168 } ) ;
168169
170+ // Mock confirm for reset actions
171+ window . confirm = jest . fn ( ( ) => true ) ;
172+
173+ // Mock requestAnimationFrame for rendering
174+ window . requestAnimationFrame = jest . fn ( ( cb ) => cb ( ) ) ;
175+
169176 const mainContent = document . getElementById ( 'mainContent' ) ;
170177 if ( mainContent ) {
171178 mainContent . requestFullscreen = jest . fn ( ( ) => Promise . resolve ( ) ) ;
@@ -176,6 +183,9 @@ describe('UI Module Consolidated', () => {
176183 describe ( 'Initialization' , ( ) => {
177184 test ( 'init registers all event listeners' , ( ) => {
178185 UI . init ( ) ;
186+ // Ensure initLibraryUI was called
187+ expect ( mockProjectManager . initLibraryUI ) . toHaveBeenCalled ( ) ;
188+
179189 expect ( mockMessenger . on ) . toHaveBeenCalledWith (
180190 'project:updated' ,
181191 expect . any ( Function )
@@ -249,7 +259,9 @@ describe('UI Module Consolidated', () => {
249259 expect ( document . getElementById ( 'fileInfo' ) . innerText ) . toBe (
250260 '2 logs loaded'
251261 ) ;
252- expect ( document . getElementById ( 'btn-xy-analysys' ) . disabled ) . toBe ( false ) ;
262+ // Wait for next tick to verify chart render due to requestAnimationFrame
263+ expect ( window . requestAnimationFrame ) . toHaveBeenCalled ( ) ;
264+ expect ( mockChartManager . render ) . toHaveBeenCalled ( ) ;
253265 } ) ;
254266 } ) ;
255267
@@ -481,7 +493,9 @@ describe('UI Module Consolidated', () => {
481493 } ) ;
482494
483495 test ( 'resetProject calls manager' , ( ) => {
496+ // confirm() is mocked to return true in beforeEach
484497 UI . resetProject ( ) ;
498+ expect ( window . confirm ) . toHaveBeenCalled ( ) ;
485499 expect ( mockProjectManager . resetProject ) . toHaveBeenCalled ( ) ;
486500 } ) ;
487501
0 commit comments