mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-09-17 14:21:29 +00:00
[ci:force][AAE-30877] - fixing core pdf test
This commit is contained in:
committed by
Wojciech Duda
parent
012b99f501
commit
6e230adaa5
@@ -7,7 +7,6 @@ const { constants } = require('karma');
|
|||||||
module.exports = function (config) {
|
module.exports = function (config) {
|
||||||
config.set({
|
config.set({
|
||||||
basePath: '../../',
|
basePath: '../../',
|
||||||
|
|
||||||
files: [
|
files: [
|
||||||
{ pattern: 'node_modules/pdfjs-dist/build/pdf.min.mjs', type: 'module', included: true, watched: false },
|
{ pattern: 'node_modules/pdfjs-dist/build/pdf.min.mjs', type: 'module', included: true, watched: false },
|
||||||
{ pattern: 'node_modules/pdfjs-dist/build/pdf.worker.min.mjs', type: 'module', included: true, watched: false },
|
{ pattern: 'node_modules/pdfjs-dist/build/pdf.worker.min.mjs', type: 'module', included: true, watched: false },
|
||||||
|
@@ -20,11 +20,11 @@ import { Component, SimpleChange, ViewChild } from '@angular/core';
|
|||||||
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
|
import { ComponentFixture, fakeAsync, 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';
|
||||||
import { of } from 'rxjs';
|
import { firstValueFrom, of } from 'rxjs';
|
||||||
import { take } from 'rxjs/operators';
|
import { take } from 'rxjs/operators';
|
||||||
import { AppConfigService } from '../../../app-config';
|
import { AppConfigService } from '../../../app-config';
|
||||||
import { EventMock } from '../../../mock';
|
import { EventMock } from '../../../mock';
|
||||||
import { CoreTestingModule, UnitTestingUtils } from '../../../testing';
|
import { NoopAuthModule, NoopTranslateModule, UnitTestingUtils } from '../../../testing';
|
||||||
import { RenderingQueueServices } from '../../services/rendering-queue.services';
|
import { RenderingQueueServices } from '../../services/rendering-queue.services';
|
||||||
import { PdfThumbListComponent } from '../pdf-viewer-thumbnails/pdf-viewer-thumbnails.component';
|
import { PdfThumbListComponent } from '../pdf-viewer-thumbnails/pdf-viewer-thumbnails.component';
|
||||||
import { PdfViewerComponent } from './pdf-viewer.component';
|
import { PdfViewerComponent } from './pdf-viewer.component';
|
||||||
@@ -40,6 +40,7 @@ declare const pdfjsLib: any;
|
|||||||
class TestDialogComponent {}
|
class TestDialogComponent {}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
selector: 'adf-url-test-component',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [PdfViewerComponent],
|
imports: [PdfViewerComponent],
|
||||||
template: ` <adf-pdf-viewer [allowThumbnails]="true" [showToolbar]="true" [urlFile]="urlFile" /> `
|
template: ` <adf-pdf-viewer [allowThumbnails]="true" [showToolbar]="true" [urlFile]="urlFile" /> `
|
||||||
@@ -56,6 +57,7 @@ class UrlTestComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
selector: 'adf-url-test-password-component',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [PdfViewerComponent],
|
imports: [PdfViewerComponent],
|
||||||
template: ` <adf-pdf-viewer [allowThumbnails]="true" [showToolbar]="true" [urlFile]="urlFile" /> `
|
template: ` <adf-pdf-viewer [allowThumbnails]="true" [showToolbar]="true" [urlFile]="urlFile" /> `
|
||||||
@@ -115,7 +117,7 @@ describe('Test PdfViewer component', () => {
|
|||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [CoreTestingModule, UrlTestComponent, TestDialogComponent, UrlTestPasswordComponent, BlobTestComponent],
|
imports: [NoopAuthModule, NoopTranslateModule, UrlTestComponent, TestDialogComponent, UrlTestPasswordComponent, BlobTestComponent],
|
||||||
providers: [
|
providers: [
|
||||||
{
|
{
|
||||||
provide: MatDialog,
|
provide: MatDialog,
|
||||||
@@ -138,6 +140,10 @@ describe('Test PdfViewer component', () => {
|
|||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
fixture.destroy();
|
||||||
|
});
|
||||||
|
|
||||||
describe('User interaction', () => {
|
describe('User interaction', () => {
|
||||||
let fixtureUrlTestComponent: ComponentFixture<UrlTestComponent>;
|
let fixtureUrlTestComponent: ComponentFixture<UrlTestComponent>;
|
||||||
let componentUrlTestComponent: UrlTestComponent;
|
let componentUrlTestComponent: UrlTestComponent;
|
||||||
@@ -148,6 +154,8 @@ describe('Test PdfViewer component', () => {
|
|||||||
componentUrlTestComponent = fixtureUrlTestComponent.componentInstance;
|
componentUrlTestComponent = fixtureUrlTestComponent.componentInstance;
|
||||||
elementUrlTestComponent = fixtureUrlTestComponent.nativeElement;
|
elementUrlTestComponent = fixtureUrlTestComponent.nativeElement;
|
||||||
testingUtils.setDebugElement(fixtureUrlTestComponent.debugElement);
|
testingUtils.setDebugElement(fixtureUrlTestComponent.debugElement);
|
||||||
|
const appConfig: AppConfigService = TestBed.inject(AppConfigService);
|
||||||
|
appConfig.config['adf-viewer.pdf-viewer-scaling'] = 10;
|
||||||
|
|
||||||
fixtureUrlTestComponent.detectChanges();
|
fixtureUrlTestComponent.detectChanges();
|
||||||
|
|
||||||
@@ -160,34 +168,26 @@ describe('Test PdfViewer component', () => {
|
|||||||
document.body.removeChild(elementUrlTestComponent);
|
document.body.removeChild(elementUrlTestComponent);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should init the viewer with annotation mode disabled', (done) => {
|
it('should init the viewer with annotation mode disabled', fakeAsync(() => {
|
||||||
fixtureUrlTestComponent.detectChanges();
|
fixtureUrlTestComponent.detectChanges();
|
||||||
|
tick(400);
|
||||||
|
expect(componentUrlTestComponent.pdfViewerComponent.pdfViewer.annotationEditorMode).toBe(AnnotationMode.DISABLE);
|
||||||
|
}));
|
||||||
|
|
||||||
fixtureUrlTestComponent.whenStable().then(() => {
|
it('should Total number of pages be loaded', fakeAsync(() => {
|
||||||
expect(componentUrlTestComponent.pdfViewerComponent.pdfViewer.annotationEditorMode).toBe(AnnotationMode.DISABLE);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
}, 55000);
|
|
||||||
|
|
||||||
it('should Total number of pages be loaded', (done) => {
|
|
||||||
fixtureUrlTestComponent.detectChanges();
|
fixtureUrlTestComponent.detectChanges();
|
||||||
|
tick(400);
|
||||||
|
expect(componentUrlTestComponent.pdfViewerComponent.totalPages).toBe(6);
|
||||||
|
}));
|
||||||
|
|
||||||
fixtureUrlTestComponent.whenStable().then(() => {
|
it('should nextPage move to the next page', fakeAsync(() => {
|
||||||
expect(componentUrlTestComponent.pdfViewerComponent.totalPages).toBe(6);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
}, 55000);
|
|
||||||
|
|
||||||
it('should nextPage move to the next page', (done) => {
|
|
||||||
testingUtils.clickByCSS('#viewer-next-page-button');
|
testingUtils.clickByCSS('#viewer-next-page-button');
|
||||||
|
|
||||||
fixtureUrlTestComponent.detectChanges();
|
fixtureUrlTestComponent.detectChanges();
|
||||||
|
tick(400);
|
||||||
|
|
||||||
fixtureUrlTestComponent.whenStable().then(() => {
|
expect(componentUrlTestComponent.pdfViewerComponent.displayPage).toBe(2);
|
||||||
expect(componentUrlTestComponent.pdfViewerComponent.displayPage).toBe(2);
|
}));
|
||||||
done();
|
|
||||||
});
|
|
||||||
}, 55000);
|
|
||||||
|
|
||||||
it('should event RIGHT_ARROW keyboard change pages', fakeAsync(() => {
|
it('should event RIGHT_ARROW keyboard change pages', fakeAsync(() => {
|
||||||
fixtureUrlTestComponent.whenStable();
|
fixtureUrlTestComponent.whenStable();
|
||||||
@@ -249,31 +249,33 @@ describe('Test PdfViewer component', () => {
|
|||||||
}, 55000);
|
}, 55000);
|
||||||
|
|
||||||
describe('Zoom', () => {
|
describe('Zoom', () => {
|
||||||
it('should zoom in increment the scale value', (done) => {
|
it('should zoom in increment the scale value', async () => {
|
||||||
spyOn(componentUrlTestComponent.pdfViewerComponent.pdfViewer, 'forceRendering').and.callFake(() => {});
|
spyOn(componentUrlTestComponent.pdfViewerComponent.pdfViewer, 'forceRendering').and.callFake(() => {});
|
||||||
|
|
||||||
const zoomBefore = componentUrlTestComponent.pdfViewerComponent.pdfViewer.currentScaleValue;
|
const zoomBefore = componentUrlTestComponent.pdfViewerComponent.pdfViewer.currentScaleValue;
|
||||||
testingUtils.clickByCSS('#viewer-zoom-in-button');
|
testingUtils.clickByCSS('#viewer-zoom-in-button');
|
||||||
fixtureUrlTestComponent.detectChanges();
|
fixtureUrlTestComponent.detectChanges();
|
||||||
|
await fixtureUrlTestComponent.whenRenderingDone();
|
||||||
|
|
||||||
expect(componentUrlTestComponent.pdfViewerComponent.currentScaleMode).toBe('auto');
|
expect(componentUrlTestComponent.pdfViewerComponent.currentScaleMode).toBe('auto');
|
||||||
const currentZoom = componentUrlTestComponent.pdfViewerComponent.pdfViewer.currentScaleValue;
|
const currentZoom = componentUrlTestComponent.pdfViewerComponent.pdfViewer.currentScaleValue;
|
||||||
expect(zoomBefore < currentZoom).toBe(true);
|
expect(zoomBefore < currentZoom).toBe(true);
|
||||||
done();
|
});
|
||||||
}, 55000);
|
|
||||||
|
|
||||||
it('should zoom out decrement the scale value', (done) => {
|
it('should zoom out decrement the scale value', async () => {
|
||||||
spyOn(componentUrlTestComponent.pdfViewerComponent.pdfViewer, 'forceRendering').and.callFake(() => {});
|
spyOn(componentUrlTestComponent.pdfViewerComponent.pdfViewer, 'forceRendering').and.callFake(() => {});
|
||||||
|
testingUtils.clickByCSS('#viewer-zoom-in-button');
|
||||||
|
fixtureUrlTestComponent.detectChanges();
|
||||||
const zoomBefore = componentUrlTestComponent.pdfViewerComponent.pdfViewer.currentScaleValue;
|
const zoomBefore = componentUrlTestComponent.pdfViewerComponent.pdfViewer.currentScaleValue;
|
||||||
|
|
||||||
testingUtils.clickByCSS('#viewer-zoom-out-button');
|
testingUtils.clickByCSS('#viewer-zoom-out-button');
|
||||||
fixtureUrlTestComponent.detectChanges();
|
fixtureUrlTestComponent.detectChanges();
|
||||||
|
await fixtureUrlTestComponent.whenRenderingDone();
|
||||||
|
|
||||||
expect(componentUrlTestComponent.pdfViewerComponent.currentScaleMode).toBe('auto');
|
expect(componentUrlTestComponent.pdfViewerComponent.currentScaleMode).toBe('auto');
|
||||||
const currentZoom = componentUrlTestComponent.pdfViewerComponent.pdfViewer.currentScaleValue;
|
const currentZoom = componentUrlTestComponent.pdfViewerComponent.pdfViewer.currentScaleValue;
|
||||||
expect(zoomBefore > currentZoom).toBe(true);
|
expect(zoomBefore > currentZoom).toBe(true);
|
||||||
done();
|
});
|
||||||
}, 55000);
|
|
||||||
|
|
||||||
it('should it-in button toggle page-fit and auto scale mode', fakeAsync(() => {
|
it('should it-in button toggle page-fit and auto scale mode', fakeAsync(() => {
|
||||||
spyOn(componentUrlTestComponent.pdfViewerComponent.pdfViewer, 'forceRendering').and.callFake(() => {});
|
spyOn(componentUrlTestComponent.pdfViewerComponent.pdfViewer, 'forceRendering').and.callFake(() => {});
|
||||||
@@ -286,7 +288,7 @@ describe('Test PdfViewer component', () => {
|
|||||||
expect(componentUrlTestComponent.pdfViewerComponent.currentScaleMode).toBe('auto');
|
expect(componentUrlTestComponent.pdfViewerComponent.currentScaleMode).toBe('auto');
|
||||||
testingUtils.clickByCSS('#viewer-scale-page-button');
|
testingUtils.clickByCSS('#viewer-scale-page-button');
|
||||||
expect(componentUrlTestComponent.pdfViewerComponent.currentScaleMode).toBe('page-fit');
|
expect(componentUrlTestComponent.pdfViewerComponent.currentScaleMode).toBe('page-fit');
|
||||||
}), 55000);
|
}), 300);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Resize interaction', () => {
|
describe('Resize interaction', () => {
|
||||||
@@ -454,14 +456,13 @@ describe('Test PdfViewer component', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
// TODO: https://alfresco.atlassian.net/browse/ACS-6061
|
|
||||||
// eslint-disable-next-line
|
describe('greater than the maximum allowed value', () => {
|
||||||
xdescribe('greater than the maximum allowed value', () => {
|
|
||||||
let fixtureUrlTestComponent: ComponentFixture<UrlTestComponent>;
|
let fixtureUrlTestComponent: ComponentFixture<UrlTestComponent>;
|
||||||
let componentUrlTestComponent: UrlTestComponent;
|
let componentUrlTestComponent: UrlTestComponent;
|
||||||
let elementUrlTestComponent: HTMLElement;
|
let elementUrlTestComponent: HTMLElement;
|
||||||
|
|
||||||
beforeEach((done) => {
|
beforeEach(() => {
|
||||||
const appConfig: AppConfigService = TestBed.inject(AppConfigService);
|
const appConfig: AppConfigService = TestBed.inject(AppConfigService);
|
||||||
appConfig.config['adf-viewer.pdf-viewer-scaling'] = 55555;
|
appConfig.config['adf-viewer.pdf-viewer-scaling'] = 55555;
|
||||||
|
|
||||||
@@ -470,24 +471,19 @@ describe('Test PdfViewer component', () => {
|
|||||||
elementUrlTestComponent = fixtureUrlTestComponent.nativeElement;
|
elementUrlTestComponent = fixtureUrlTestComponent.nativeElement;
|
||||||
|
|
||||||
fixtureUrlTestComponent.detectChanges();
|
fixtureUrlTestComponent.detectChanges();
|
||||||
|
|
||||||
componentUrlTestComponent.pdfViewerComponent.rendered.pipe(take(1)).subscribe(() => {
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
document.body.removeChild(elementUrlTestComponent);
|
document.body.removeChild(elementUrlTestComponent);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should use the maximum scale zoom if the value given in app.config is greater than the maximum allowed scale', (done) => {
|
it('should use the maximum scale zoom if the value given in app.config is greater than the maximum allowed scale', async () => {
|
||||||
|
await firstValueFrom(componentUrlTestComponent.pdfViewerComponent.rendered)
|
||||||
spyOn(componentUrlTestComponent.pdfViewerComponent.pdfViewer, 'forceRendering').and.callFake(() => {});
|
spyOn(componentUrlTestComponent.pdfViewerComponent.pdfViewer, 'forceRendering').and.callFake(() => {});
|
||||||
|
|
||||||
fixtureUrlTestComponent.detectChanges();
|
fixtureUrlTestComponent.detectChanges();
|
||||||
fixtureUrlTestComponent.whenStable().then(() => {
|
await fixtureUrlTestComponent.whenStable();
|
||||||
expect(componentUrlTestComponent.pdfViewerComponent.pdfViewer.currentScale).toBe(10);
|
expect(componentUrlTestComponent.pdfViewerComponent.pdfViewer.currentScale).toBe(10);
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user