mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
[MNT-23560] TIFF PDF Renderer Error (#8921)
* [MNT-23560] added horizontal scroll * [MNT-23560] fixed user interaction tests * [MNT-23560] unit tests * [MNT-23560] fixed pdf-viewer unit tests * [MNT-23560] linter * [MNT-23560] added to do comment
This commit is contained in:
parent
5345838744
commit
8370a3de66
@ -37,7 +37,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="adf-pdf-viewer__toolbar" *ngIf="showToolbar">
|
<div class="adf-pdf-viewer__toolbar" *ngIf="showToolbar" [ngStyle]="documentOverflow && {bottom: '25px'}">
|
||||||
<adf-toolbar>
|
<adf-toolbar>
|
||||||
|
|
||||||
<ng-container *ngIf="allowThumbnails">
|
<ng-container *ngIf="allowThumbnails">
|
||||||
|
@ -63,7 +63,8 @@
|
|||||||
|
|
||||||
&__container {
|
&__container {
|
||||||
display: flex;
|
display: flex;
|
||||||
height: 100vh;
|
height: 100%;
|
||||||
|
min-height: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__content {
|
&__content {
|
||||||
|
@ -115,8 +115,8 @@ class BlobTestComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line
|
|
||||||
xdescribe('Test PdfViewer component', () => {
|
describe('Test PdfViewer component', () => {
|
||||||
|
|
||||||
let component: PdfViewerComponent;
|
let component: PdfViewerComponent;
|
||||||
let fixture: ComponentFixture<PdfViewerComponent>;
|
let fixture: ComponentFixture<PdfViewerComponent>;
|
||||||
@ -154,7 +154,6 @@ xdescribe('Test PdfViewer component', () => {
|
|||||||
|
|
||||||
component.showToolbar = true;
|
component.showToolbar = true;
|
||||||
component.inputPage('1');
|
component.inputPage('1');
|
||||||
component.pdfViewer.currentScale = 1;
|
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
@ -279,10 +278,10 @@ xdescribe('Test PdfViewer component', () => {
|
|||||||
|
|
||||||
tick(250);
|
tick(250);
|
||||||
|
|
||||||
const zoomBefore = componentUrlTestComponent.pdfViewerComponent.pdfViewer.currentScale;
|
const zoomBefore = componentUrlTestComponent.pdfViewerComponent.pdfViewer.currentScaleValue;
|
||||||
zoomInButton.click();
|
zoomInButton.click();
|
||||||
expect(componentUrlTestComponent.pdfViewerComponent.currentScaleMode).toBe('auto');
|
expect(componentUrlTestComponent.pdfViewerComponent.currentScaleMode).toBe('auto');
|
||||||
const currentZoom = componentUrlTestComponent.pdfViewerComponent.pdfViewer.currentScale;
|
const currentZoom = componentUrlTestComponent.pdfViewerComponent.pdfViewer.currentScaleValue;
|
||||||
expect(zoomBefore < currentZoom).toBe(true);
|
expect(zoomBefore < currentZoom).toBe(true);
|
||||||
}), 55000);
|
}), 55000);
|
||||||
|
|
||||||
@ -293,10 +292,10 @@ xdescribe('Test PdfViewer component', () => {
|
|||||||
|
|
||||||
tick(250);
|
tick(250);
|
||||||
|
|
||||||
const zoomBefore = componentUrlTestComponent.pdfViewerComponent.pdfViewer.currentScale;
|
const zoomBefore = componentUrlTestComponent.pdfViewerComponent.pdfViewer.currentScaleValue;
|
||||||
zoomOutButton.click();
|
zoomOutButton.click();
|
||||||
expect(componentUrlTestComponent.pdfViewerComponent.currentScaleMode).toBe('auto');
|
expect(componentUrlTestComponent.pdfViewerComponent.currentScaleMode).toBe('auto');
|
||||||
const currentZoom = componentUrlTestComponent.pdfViewerComponent.pdfViewer.currentScale;
|
const currentZoom = componentUrlTestComponent.pdfViewerComponent.pdfViewer.currentScaleValue;
|
||||||
expect(zoomBefore > currentZoom).toBe(true);
|
expect(zoomBefore > currentZoom).toBe(true);
|
||||||
}), 55000);
|
}), 55000);
|
||||||
|
|
||||||
@ -414,6 +413,17 @@ xdescribe('Test PdfViewer component', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should check if document has overflow', (done) => {
|
||||||
|
spyOn(componentUrlTestComponent.pdfViewerComponent, 'setScaleUpdatePages');
|
||||||
|
componentUrlTestComponent.pdfViewerComponent.scalePage('auto');
|
||||||
|
|
||||||
|
fixtureUrlTestComponent.detectChanges();
|
||||||
|
fixtureUrlTestComponent.whenStable().then(() => {
|
||||||
|
expect(componentUrlTestComponent.pdfViewerComponent.setScaleUpdatePages).toHaveBeenCalled();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -496,14 +506,15 @@ xdescribe('Test PdfViewer component', () => {
|
|||||||
fixtureUrlTestComponent.detectChanges();
|
fixtureUrlTestComponent.detectChanges();
|
||||||
|
|
||||||
fixtureUrlTestComponent.whenStable().then(() => {
|
fixtureUrlTestComponent.whenStable().then(() => {
|
||||||
expect(componentUrlTestComponent.pdfViewerComponent.pdfViewer.currentScale).toBe(0.25);
|
expect(componentUrlTestComponent.pdfViewerComponent.pdfViewer.currentScaleValue).toBe('0.25');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
// TODO: https://alfresco.atlassian.net/browse/ACS-6061
|
||||||
describe('greater than the maximum allowed value', () => {
|
// eslint-disable-next-line
|
||||||
|
xdescribe('greater than the maximum allowed value', () => {
|
||||||
|
|
||||||
let fixtureUrlTestComponent: ComponentFixture<UrlTestComponent>;
|
let fixtureUrlTestComponent: ComponentFixture<UrlTestComponent>;
|
||||||
let componentUrlTestComponent: UrlTestComponent;
|
let componentUrlTestComponent: UrlTestComponent;
|
||||||
@ -538,9 +549,7 @@ xdescribe('Test PdfViewer component', () => {
|
|||||||
fixtureUrlTestComponent.whenStable().then(() => {
|
fixtureUrlTestComponent.whenStable().then(() => {
|
||||||
expect(componentUrlTestComponent.pdfViewerComponent.pdfViewer.currentScale).toBe(10);
|
expect(componentUrlTestComponent.pdfViewerComponent.pdfViewer.currentScale).toBe(10);
|
||||||
done();
|
done();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -623,21 +632,17 @@ xdescribe('Test PdfViewer component', () => {
|
|||||||
describe('View with blob file', () => {
|
describe('View with blob file', () => {
|
||||||
|
|
||||||
let fixtureBlobTestComponent: ComponentFixture<BlobTestComponent>;
|
let fixtureBlobTestComponent: ComponentFixture<BlobTestComponent>;
|
||||||
let componentBlobTestComponent: BlobTestComponent;
|
|
||||||
let elementBlobTestComponent: HTMLElement;
|
let elementBlobTestComponent: HTMLElement;
|
||||||
|
|
||||||
beforeEach((done) => {
|
beforeEach((done) => {
|
||||||
fixtureBlobTestComponent = TestBed.createComponent(BlobTestComponent);
|
fixtureBlobTestComponent = TestBed.createComponent(BlobTestComponent);
|
||||||
componentBlobTestComponent = fixtureBlobTestComponent.componentInstance;
|
|
||||||
elementBlobTestComponent = fixtureBlobTestComponent.nativeElement;
|
elementBlobTestComponent = fixtureBlobTestComponent.nativeElement;
|
||||||
|
|
||||||
fixtureBlobTestComponent.detectChanges();
|
fixtureBlobTestComponent.detectChanges();
|
||||||
|
|
||||||
componentBlobTestComponent.pdfViewerComponent.rendered
|
fixtureBlobTestComponent.whenStable().then(() => {
|
||||||
.pipe(take(1))
|
done();
|
||||||
.subscribe(() => {
|
});
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@ -679,7 +684,7 @@ xdescribe('Test PdfViewer component', () => {
|
|||||||
}, 55000);
|
}, 55000);
|
||||||
|
|
||||||
it('should Toolbar be hide if showToolbar is false', (done) => {
|
it('should Toolbar be hide if showToolbar is false', (done) => {
|
||||||
componentBlobTestComponent.pdfViewerComponent.showToolbar = false;
|
fixtureBlobTestComponent.componentInstance.pdfViewerComponent.showToolbar = false;
|
||||||
|
|
||||||
fixtureBlobTestComponent.detectChanges();
|
fixtureBlobTestComponent.detectChanges();
|
||||||
|
|
||||||
@ -697,7 +702,7 @@ xdescribe('Test PdfViewer component', () => {
|
|||||||
let componentUrlTestPasswordComponent: UrlTestPasswordComponent;
|
let componentUrlTestPasswordComponent: UrlTestPasswordComponent;
|
||||||
|
|
||||||
describe('Open password dialog', () => {
|
describe('Open password dialog', () => {
|
||||||
beforeEach((done) => {
|
beforeEach( async () => {
|
||||||
fixtureUrlTestPasswordComponent = TestBed.createComponent(UrlTestPasswordComponent);
|
fixtureUrlTestPasswordComponent = TestBed.createComponent(UrlTestPasswordComponent);
|
||||||
componentUrlTestPasswordComponent = fixtureUrlTestPasswordComponent.componentInstance;
|
componentUrlTestPasswordComponent = fixtureUrlTestPasswordComponent.componentInstance;
|
||||||
|
|
||||||
@ -718,10 +723,7 @@ xdescribe('Test PdfViewer component', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
fixtureUrlTestPasswordComponent.detectChanges();
|
fixtureUrlTestPasswordComponent.detectChanges();
|
||||||
|
await fixtureUrlTestPasswordComponent.whenStable();
|
||||||
componentUrlTestPasswordComponent.pdfViewerComponent.rendered.subscribe(() => {
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@ -729,16 +731,18 @@ xdescribe('Test PdfViewer component', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should try to access protected pdf', (done) => {
|
it('should try to access protected pdf', (done) => {
|
||||||
|
componentUrlTestPasswordComponent.pdfViewerComponent.onPdfPassword(() => {}, pdfjsLib.PasswordResponses.NEED_PASSWORD);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
expect(dialog.open).toHaveBeenCalledTimes(2);
|
expect(dialog.open).toHaveBeenCalledTimes(1);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should raise dialog asking for password', (done) => {
|
it('should raise dialog asking for password', (done) => {
|
||||||
|
componentUrlTestPasswordComponent.pdfViewerComponent.onPdfPassword(() => {}, pdfjsLib.PasswordResponses.NEED_PASSWORD);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@ -750,10 +754,11 @@ xdescribe('Test PdfViewer component', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('it should raise dialog with incorrect password', (done) => {
|
it('it should raise dialog with incorrect password', (done) => {
|
||||||
|
componentUrlTestPasswordComponent.pdfViewerComponent.onPdfPassword(() => {}, pdfjsLib.PasswordResponses.INCORRECT_PASSWORD);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(dialog.open['calls'].all()[1].args[1].data).toEqual({
|
expect(dialog.open['calls'].all()[0].args[1].data).toEqual({
|
||||||
reason: pdfjsLib.PasswordResponses.INCORRECT_PASSWORD
|
reason: pdfjsLib.PasswordResponses.INCORRECT_PASSWORD
|
||||||
});
|
});
|
||||||
done();
|
done();
|
||||||
@ -767,17 +772,14 @@ xdescribe('Test PdfViewer component', () => {
|
|||||||
componentUrlTestPasswordComponent = fixtureUrlTestPasswordComponent.componentInstance;
|
componentUrlTestPasswordComponent = fixtureUrlTestPasswordComponent.componentInstance;
|
||||||
|
|
||||||
spyOn(dialog, 'open').and.callFake(() => ({
|
spyOn(dialog, 'open').and.callFake(() => ({
|
||||||
afterClosed: () => {
|
afterClosed: () => of('')
|
||||||
done();
|
|
||||||
return of('');
|
|
||||||
}
|
|
||||||
} as any));
|
} as any));
|
||||||
|
|
||||||
spyOn(componentUrlTestPasswordComponent.pdfViewerComponent.close, 'emit');
|
spyOn(componentUrlTestPasswordComponent.pdfViewerComponent.close, 'emit');
|
||||||
|
|
||||||
fixtureUrlTestPasswordComponent.detectChanges();
|
fixtureUrlTestPasswordComponent.detectChanges();
|
||||||
|
|
||||||
componentUrlTestPasswordComponent.pdfViewerComponent.rendered.subscribe(() => {
|
fixtureUrlTestPasswordComponent.whenStable().then(() => {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -787,6 +789,7 @@ xdescribe('Test PdfViewer component', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should try to access protected pdf', (done) => {
|
it('should try to access protected pdf', (done) => {
|
||||||
|
componentUrlTestPasswordComponent.pdfViewerComponent.onPdfPassword(() => {}, pdfjsLib.PasswordResponses.NEED_PASSWORD);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
@ -99,6 +99,7 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
|
|||||||
showThumbnails: boolean = false;
|
showThumbnails: boolean = false;
|
||||||
pdfThumbnailsContext: { viewer: any } = { viewer: null };
|
pdfThumbnailsContext: { viewer: any } = { viewer: null };
|
||||||
randomPdfId: string;
|
randomPdfId: string;
|
||||||
|
documentOverflow = false;
|
||||||
|
|
||||||
get currentScaleText(): string {
|
get currentScaleText(): string {
|
||||||
return this.pdfViewer?.currentScaleValue ? Math.round(this.pdfViewer.currentScaleValue * 100) + '%' : '';
|
return this.pdfViewer?.currentScaleValue ? Math.round(this.pdfViewer.currentScaleValue * 100) + '%' : '';
|
||||||
@ -369,6 +370,13 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
|
|||||||
return scale;
|
return scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setDocumentOverflow() {
|
||||||
|
const documentContainerSize = this.getDocumentContainer();
|
||||||
|
const page = this.pdfViewer._pages[this.pdfViewer._currentPageNumber - 1];
|
||||||
|
|
||||||
|
this.documentOverflow = page.width > documentContainerSize.clientWidth;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update all the pages with the newScale scale
|
* Update all the pages with the newScale scale
|
||||||
*
|
*
|
||||||
@ -382,6 +390,7 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
|
|||||||
|
|
||||||
this.pdfViewer.update();
|
this.pdfViewer.update();
|
||||||
}
|
}
|
||||||
|
this.setDocumentOverflow();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user