mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +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 {
|
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: () =>
|
Promise.resolve({
|
||||||
Promise.resolve({
|
getAnnotations: () => [
|
||||||
getAnnotations: () => [
|
{
|
||||||
{
|
subtype: 'Text',
|
||||||
subtype: 'Text',
|
name: 'NoIcon',
|
||||||
name: 'NoIcon',
|
id: 'R13',
|
||||||
id: 'R13',
|
titleObj: {
|
||||||
titleObj: {
|
str: 'Annotation title'
|
||||||
str: 'Annotation title'
|
},
|
||||||
},
|
contentsObj: {
|
||||||
contentsObj: {
|
str: 'Annotation contents'
|
||||||
str: 'Annotation contents'
|
},
|
||||||
},
|
modificationDate: "D:20260202104106Z00'00",
|
||||||
modificationDate: "D:20260202104106Z00'00",
|
popupRef: 'R1'
|
||||||
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';
|
||||||
@@ -514,6 +514,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;
|
||||||
|
|||||||
@@ -148,7 +148,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>();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user