[MNT-24538] Update PDFjs viewer version and disable annotation mode (#10538)

* [MNT-24538] Bump PDFjs viewer version and use annotation mode disabled

* [MNT-24538] Proper test params

* [ci:force]

* [MNT-24538] Use different pdfjs version

* [ci:force]

* [MNT-24538][ci:force] Use proper legacy paths

* [MNT-24538][ci:force] Use Node 22 LTS

* [MNT-24538] Use pdfjs legacy version

* [MNT-24538] Use existing pdfjs-dist version with new param

* [MNT-24538] Legacy build cleanup

* [MNT-24538] Lockfile fix

* [MNT-24538] Lockfile fix

* [MNT-24538] Unit test fix

* [MNT-24538] Unit test fixes
This commit is contained in:
MichalKinas
2025-01-15 11:41:56 +01:00
committed by GitHub
parent 18ff34c6c8
commit 8b5dcf19b9
6 changed files with 63 additions and 61 deletions

View File

@@ -28,6 +28,7 @@ import { CoreTestingModule } from '../../../testing';
import { RenderingQueueServices } from '../../services/rendering-queue.services';
import { PdfThumbListComponent } from '../pdf-viewer-thumbnails/pdf-viewer-thumbnails.component';
import { PdfViewerComponent } from './pdf-viewer.component';
import { AnnotationMode } from 'pdfjs-dist';
declare const pdfjsLib: any;
@@ -159,6 +160,15 @@ describe('Test PdfViewer component', () => {
document.body.removeChild(elementUrlTestComponent);
});
it('should init the viewer with annotation mode disabled', (done) => {
fixtureUrlTestComponent.detectChanges();
fixtureUrlTestComponent.whenStable().then(() => {
expect(componentUrlTestComponent.pdfViewerComponent.pdfViewer.annotationEditorMode).toBe(AnnotationMode.DISABLE);
done();
});
}, 55000);
it('should Total number of pages be loaded', (done) => {
fixtureUrlTestComponent.detectChanges();
@@ -243,32 +253,34 @@ describe('Test PdfViewer component', () => {
}, 55000);
describe('Zoom', () => {
it('should zoom in increment the scale value', fakeAsync(() => {
it('should zoom in increment the scale value', (done) => {
spyOn(componentUrlTestComponent.pdfViewerComponent.pdfViewer, 'forceRendering').and.callFake(() => {});
const zoomInButton: any = elementUrlTestComponent.querySelector('#viewer-zoom-in-button');
tick(250);
const zoomBefore = componentUrlTestComponent.pdfViewerComponent.pdfViewer.currentScaleValue;
zoomInButton.click();
fixtureUrlTestComponent.detectChanges();
expect(componentUrlTestComponent.pdfViewerComponent.currentScaleMode).toBe('auto');
const currentZoom = componentUrlTestComponent.pdfViewerComponent.pdfViewer.currentScaleValue;
expect(zoomBefore < currentZoom).toBe(true);
}), 55000);
done();
}, 55000);
it('should zoom out decrement the scale value', fakeAsync(() => {
it('should zoom out decrement the scale value', (done) => {
spyOn(componentUrlTestComponent.pdfViewerComponent.pdfViewer, 'forceRendering').and.callFake(() => {});
const zoomOutButton: any = elementUrlTestComponent.querySelector('#viewer-zoom-out-button');
tick(250);
const zoomBefore = componentUrlTestComponent.pdfViewerComponent.pdfViewer.currentScaleValue;
zoomOutButton.click();
fixtureUrlTestComponent.detectChanges();
expect(componentUrlTestComponent.pdfViewerComponent.currentScaleMode).toBe('auto');
const currentZoom = componentUrlTestComponent.pdfViewerComponent.pdfViewer.currentScaleValue;
expect(zoomBefore > currentZoom).toBe(true);
}), 55000);
done();
}, 55000);
it('should it-in button toggle page-fit and auto scale mode', fakeAsync(() => {
spyOn(componentUrlTestComponent.pdfViewerComponent.pdfViewer, 'forceRendering').and.callFake(() => {});

View File

@@ -37,7 +37,7 @@ import { MatDialog } from '@angular/material/dialog';
import { MatIconModule } from '@angular/material/icon';
import { MatProgressBarModule } from '@angular/material/progress-bar';
import { TranslateModule } from '@ngx-translate/core';
import { OnProgressParameters, PDFDocumentLoadingTask, PDFDocumentProxy } from 'pdfjs-dist';
import { AnnotationMode, OnProgressParameters, PDFDocumentLoadingTask, PDFDocumentProxy } from 'pdfjs-dist';
import { Subject } from 'rxjs';
import { catchError, delay } from 'rxjs/operators';
import { AppConfigService } from '../../../app-config';
@@ -246,7 +246,8 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
container,
viewer,
renderingQueue: this.renderingQueueServices,
eventBus: this.eventBus
eventBus: this.eventBus,
annotationMode: AnnotationMode.DISABLE
});
// cspell: disable-next