Fixhancement: restore search highlighting and add for built-in viewer (#8885)

This commit is contained in:
shamoon
2025-01-23 15:00:46 -08:00
committed by GitHub
parent 6c34e37838
commit 18c4e6029f
6 changed files with 90 additions and 44 deletions

View File

@@ -158,4 +158,24 @@ describe('PreviewPopupComponent', () => {
jest.advanceTimersByTime(1)
expect(component.popover.isOpen()).toBeFalsy()
})
it('should dispatch find event on viewer loaded if searchQuery set', () => {
documentService.searchQuery = 'test'
settingsService.set(SETTINGS_KEYS.USE_NATIVE_PDF_VIEWER, false)
component.popover.open()
jest.advanceTimersByTime(1000)
fixture.detectChanges()
// normally setup by pdf-viewer
jest.replaceProperty(component.pdfViewer, 'eventBus', {
dispatch: jest.fn(),
} as any)
const dispatchSpy = jest.spyOn(component.pdfViewer.eventBus, 'dispatch')
component.onPageRendered()
expect(dispatchSpy).toHaveBeenCalledWith('find', {
query: 'test',
caseSensitive: false,
highlightAll: true,
phraseSearch: true,
})
})
})