mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-04-23 22:30:37 +00:00
[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:
@@ -17,36 +17,34 @@
|
||||
|
||||
export default {
|
||||
GlobalWorkerOptions: {},
|
||||
getDocument() {
|
||||
return {
|
||||
loadingTask: () => ({
|
||||
destroy: () => Promise.resolve()
|
||||
}),
|
||||
promise: new Promise((resolve) => {
|
||||
resolve({
|
||||
numPages: 6,
|
||||
getPage: () =>
|
||||
Promise.resolve({
|
||||
getAnnotations: () => [
|
||||
{
|
||||
subtype: 'Text',
|
||||
name: 'NoIcon',
|
||||
id: 'R13',
|
||||
titleObj: {
|
||||
str: 'Annotation title'
|
||||
},
|
||||
contentsObj: {
|
||||
str: 'Annotation contents'
|
||||
},
|
||||
modificationDate: "D:20260202104106Z00'00",
|
||||
popupRef: 'R1'
|
||||
}
|
||||
]
|
||||
})
|
||||
});
|
||||
})
|
||||
};
|
||||
},
|
||||
getDocument: jasmine.createSpy('getDocument').and.callFake(() => ({
|
||||
loadingTask: () => ({
|
||||
destroy: () => Promise.resolve()
|
||||
}),
|
||||
promise: new Promise((resolve) => {
|
||||
resolve({
|
||||
numPages: 6,
|
||||
getPage: () =>
|
||||
Promise.resolve({
|
||||
getAnnotations: () => [
|
||||
{
|
||||
subtype: 'Text',
|
||||
name: 'NoIcon',
|
||||
id: 'R13',
|
||||
titleObj: {
|
||||
str: 'Annotation title'
|
||||
},
|
||||
contentsObj: {
|
||||
str: 'Annotation contents'
|
||||
},
|
||||
modificationDate: "D:20260202104106Z00'00",
|
||||
popupRef: 'R1'
|
||||
}
|
||||
]
|
||||
})
|
||||
});
|
||||
})
|
||||
})),
|
||||
PasswordResponses: {
|
||||
NEED_PASSWORD: 1,
|
||||
INCORRECT_PASSWORD: 2
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
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 { MatDialog } from '@angular/material/dialog';
|
||||
import { By } from '@angular/platform-browser';
|
||||
@@ -514,6 +514,21 @@ describe('Test PdfViewer - User interaction', () => {
|
||||
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', () => {
|
||||
it('should zoom in increment the scale value', () => {
|
||||
const zoomBefore = component.pdfViewer.currentScaleValue;
|
||||
|
||||
@@ -148,7 +148,8 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
|
||||
disableAutoFetch: true,
|
||||
disableStream: true,
|
||||
cMapUrl: './cmaps/',
|
||||
cMapPacked: true
|
||||
cMapPacked: true,
|
||||
wasmUrl: './wasm/'
|
||||
};
|
||||
private pdfjsWorkerDestroy$ = new Subject<boolean>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user