[MNT-25541] PDFs containing JP2 images (JPEG 2000) cannot be displayed in ADW viewer (#11618)

* [MNT-25541]: adds wasmUrl to default options

* [MNT-25541]: updates UTs

* [MNT-25541]: naming change
This commit is contained in:
Anton Ramanovich
2026-02-25 11:01:44 +01:00
committed by MichalKinas
parent f751370b60
commit d4714e2b01
3 changed files with 47 additions and 16 deletions
@@ -17,19 +17,34 @@
export default { export default {
GlobalWorkerOptions: {}, GlobalWorkerOptions: {},
getDocument() { getDocument: jasmine.createSpy('getDocument').and.callFake(() => ({
return { loadingTask: () => ({
loadingTask: () => ({ destroy: () => Promise.resolve()
destroy: () => Promise.resolve() }),
}), promise: new Promise((resolve) => {
promise: new Promise((resolve) => { resolve({
resolve({ numPages: 6,
numPages: 6, getPage: () =>
getPage: () => 'fakePage' Promise.resolve({
}); getAnnotations: () => [
}) {
}; subtype: 'Text',
}, name: 'NoIcon',
id: 'R13',
titleObj: {
str: 'Annotation title'
},
contentsObj: {
str: 'Annotation contents'
},
modificationDate: "D:20260202104106Z00'00",
popupRef: 'R1'
}
]
})
});
})
})),
PasswordResponses: { PasswordResponses: {
NEED_PASSWORD: 1, NEED_PASSWORD: 1,
INCORRECT_PASSWORD: 2 INCORRECT_PASSWORD: 2
@@ -16,7 +16,7 @@
*/ */
import { LEFT_ARROW, RIGHT_ARROW } from '@angular/cdk/keycodes'; import { LEFT_ARROW, RIGHT_ARROW } from '@angular/cdk/keycodes';
import { Component, SimpleChange, ViewChild } from '@angular/core'; import { Component, SimpleChange, SimpleChanges, ViewChild } from '@angular/core';
import { ComponentFixture, fakeAsync, flush, TestBed, tick } from '@angular/core/testing'; import { ComponentFixture, fakeAsync, flush, TestBed, tick } from '@angular/core/testing';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
@@ -326,7 +326,7 @@ describe('Test PdfViewer component', () => {
() => () =>
({ ({
afterClosed: () => of('') afterClosed: () => of('')
} as any) }) as any
); );
spyOn(componentUrlTestPasswordComponent.pdfViewerComponent.close, 'emit'); spyOn(componentUrlTestPasswordComponent.pdfViewerComponent.close, 'emit');
@@ -510,6 +510,21 @@ describe('Test PdfViewer - User interaction', () => {
expect(component.displayPage).toBe(2); expect(component.displayPage).toBe(2);
}); });
it('should configure PDF.js with the correct wasmUrl', () => {
const changes: SimpleChanges = {
blobFile: new SimpleChange(null, component.blobFile, true)
};
component.ngOnChanges(changes);
const getDocumentSpy = pdfjsLibraryMock.getDocument;
expect(getDocumentSpy).toHaveBeenCalled();
const loadingArgs = getDocumentSpy.calls.mostRecent().args[0];
expect(loadingArgs.wasmUrl).toBe('./wasm/');
});
describe('Zoom', () => { describe('Zoom', () => {
it('should zoom in increment the scale value', () => { it('should zoom in increment the scale value', () => {
const zoomBefore = component.pdfViewer.currentScaleValue; const zoomBefore = component.pdfViewer.currentScaleValue;
@@ -147,7 +147,8 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
disableAutoFetch: true, disableAutoFetch: true,
disableStream: true, disableStream: true,
cMapUrl: './cmaps/', cMapUrl: './cmaps/',
cMapPacked: true cMapPacked: true,
wasmUrl: './wasm/'
}; };
private pdfjsWorkerDestroy$ = new Subject<boolean>(); private pdfjsWorkerDestroy$ = new Subject<boolean>();