mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
[ADF-2240] fix e2e and test in demo shell (#3035)
* fix e2e and test in demo shell * test single run demo shell conf * fix script e2e * fix test lint problems * remove async from nested test * fix pdf test * modify url load pdf strategy test * SimpleChange import * pdf viewer test fix * remove force closing * refactor pdf viewer -remove promise approach -add event rendered -add destroy worker * increment timeout * use proxy files * remove require * fix viewer component test * remove last require * prefer use of done for txt viewer test
This commit is contained in:
parent
606009cac2
commit
ae489f6737
@ -149,14 +149,6 @@
|
|||||||
{
|
{
|
||||||
"project": "src/tsconfig.app.json",
|
"project": "src/tsconfig.app.json",
|
||||||
"exclude": "**/node_modules/**/*"
|
"exclude": "**/node_modules/**/*"
|
||||||
},
|
|
||||||
{
|
|
||||||
"project": "src/tsconfig.spec.json",
|
|
||||||
"exclude": "**/node_modules/**/*"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"project": "e2e/tsconfig.e2e.json",
|
|
||||||
"exclude": "**/node_modules/**/*"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"test": {
|
"test": {
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
import { MyappPage } from './app.po';
|
import { MyappPage } from './app.po';
|
||||||
|
|
||||||
describe('myapp App', () => {
|
describe('myapp App', () => {
|
||||||
let page: MyappPage;
|
let page: MyappPage;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
page = new MyappPage();
|
page = new MyappPage();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display message saying app works', () => {
|
it('should display toolbar', () => {
|
||||||
page.navigateTo();
|
page.navigateTo();
|
||||||
expect(page.getParagraphText()).toEqual('app works!');
|
expect(page.getToolbar()).toBeDefined();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { browser, element, by } from 'protractor';
|
import { browser, element, by } from 'protractor';
|
||||||
|
|
||||||
export class MyappPage {
|
export class MyappPage {
|
||||||
navigateTo() {
|
navigateTo() {
|
||||||
return browser.get('/');
|
return browser.get('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
getParagraphText() {
|
getToolbar() {
|
||||||
return element(by.css('app-root h1')).getText();
|
return element(by.tagName('adf-toolbar'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
"build:dist": "npm run validate-config && npm run style:dev && npm run server-versions && rimraf dist && node --max_old_space_size=30000 node_modules/.bin/ng build --prod --build-optimizer=false --aot=false --app dist",
|
"build:dist": "npm run validate-config && npm run style:dev && npm run server-versions && rimraf dist && node --max_old_space_size=30000 node_modules/.bin/ng build --prod --build-optimizer=false --aot=false --app dist",
|
||||||
"style:dev": "npm run webpack -- --config config/webpack.style.js --progress --profile --bail",
|
"style:dev": "npm run webpack -- --config config/webpack.style.js --progress --profile --bail",
|
||||||
"copy:dev": "node ./config/dev-copy-watch.js",
|
"copy:dev": "node ./config/dev-copy-watch.js",
|
||||||
"test": "ng test",
|
"test": " npm run clean-lib-angular && ng test --single-run",
|
||||||
"lint": "ng lint",
|
"lint": "ng lint",
|
||||||
"e2e": "ng e2e",
|
"e2e": "ng e2e",
|
||||||
"validate-config": "ajv validate -s ../lib/core/app-config/schema.json -d ./src/app.config.json --errors=text --verbose",
|
"validate-config": "ajv validate -s ../lib/core/app-config/schema.json -d ./src/app.config.json --errors=text --verbose",
|
||||||
|
@ -1,32 +1,25 @@
|
|||||||
import { TestBed, async } from '@angular/core/testing';
|
import { TestBed, async } from '@angular/core/testing';
|
||||||
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
|
|
||||||
|
import { AdfModule } from './adf.module';
|
||||||
import { AppComponent } from './app.component';
|
import { AppComponent } from './app.component';
|
||||||
|
|
||||||
describe('AppComponent', () => {
|
describe('AppComponent', () => {
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
declarations: [
|
imports: [
|
||||||
AppComponent
|
RouterTestingModule,
|
||||||
],
|
AdfModule
|
||||||
}).compileComponents();
|
],
|
||||||
}));
|
declarations: [
|
||||||
|
AppComponent
|
||||||
|
]
|
||||||
|
}).compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
it('should create the app', async(() => {
|
it('should create the app', async(() => {
|
||||||
const fixture = TestBed.createComponent(AppComponent);
|
const fixture = TestBed.createComponent(AppComponent);
|
||||||
const app = fixture.debugElement.componentInstance;
|
const app = fixture.debugElement.componentInstance;
|
||||||
expect(app).toBeTruthy();
|
expect(app).toBeTruthy();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it(`should have as title 'app works!'`, async(() => {
|
|
||||||
const fixture = TestBed.createComponent(AppComponent);
|
|
||||||
const app = fixture.debugElement.componentInstance;
|
|
||||||
expect(app.title).toEqual('app works!');
|
|
||||||
}));
|
|
||||||
|
|
||||||
it('should render title in a h1 tag', async(() => {
|
|
||||||
const fixture = TestBed.createComponent(AppComponent);
|
|
||||||
fixture.detectChanges();
|
|
||||||
const compiled = fixture.debugElement.nativeElement;
|
|
||||||
expect(compiled.querySelector('h1').textContent).toContain('app works!');
|
|
||||||
}));
|
|
||||||
});
|
});
|
||||||
|
@ -60,6 +60,10 @@ import 'zone.js/dist/zone'; // Included with Angular CLI.
|
|||||||
* Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10
|
* Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10
|
||||||
*/
|
*/
|
||||||
import 'intl'; // Run `npm install --save intl`.
|
import 'intl'; // Run `npm install --save intl`.
|
||||||
|
/**
|
||||||
|
* Need to import at least one locale-data with intl.
|
||||||
|
*/
|
||||||
|
import 'intl/locale-data/jsonp/en';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Support custom event in IE11
|
* Support custom event in IE11
|
||||||
|
@ -2,19 +2,41 @@
|
|||||||
"extends": "../tsconfig.json",
|
"extends": "../tsconfig.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "../out-tsc/spec",
|
"outDir": "../out-tsc/spec",
|
||||||
"module": "commonjs",
|
"module": "es2015",
|
||||||
"target": "es5",
|
"rootDir": "..",
|
||||||
"baseUrl": "",
|
"baseUrl": ".",
|
||||||
|
"skipLibCheck": false,
|
||||||
"types": [
|
"types": [
|
||||||
"jasmine",
|
"jasmine",
|
||||||
"node"
|
"node"
|
||||||
]
|
],
|
||||||
|
"paths": {
|
||||||
|
"alfresco-js-api": [
|
||||||
|
"../node_modules/alfresco-js-api/dist/alfresco-js-api.js"
|
||||||
|
],
|
||||||
|
"rxjs/*": [
|
||||||
|
"../node_modules/rxjs/*"
|
||||||
|
],
|
||||||
|
"@angular/*": [
|
||||||
|
"../node_modules/@angular/*"
|
||||||
|
],
|
||||||
|
"@alfresco/adf-core": [
|
||||||
|
"../../lib/core"
|
||||||
|
],
|
||||||
|
"@alfresco/adf-content-services": [
|
||||||
|
"../../lib/content-services"
|
||||||
|
],
|
||||||
|
"@alfresco/adf-process-services": [
|
||||||
|
"../../lib/process-services"
|
||||||
|
],
|
||||||
|
"@alfresco/adf-insights": [
|
||||||
|
"../../lib/insights"
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"files": [
|
"exclude": [
|
||||||
"test.ts"
|
|
||||||
],
|
],
|
||||||
"include": [
|
"angularCompilerOptions": {
|
||||||
"**/*.spec.ts",
|
"skipTemplateCodegen": false
|
||||||
"**/*.d.ts"
|
}
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,6 @@
|
|||||||
"variable-declaration": "nospace"
|
"variable-declaration": "nospace"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"typeof-compare": true,
|
|
||||||
"unified-signatures": true,
|
"unified-signatures": true,
|
||||||
"variable-name": false,
|
"variable-name": false,
|
||||||
"whitespace": [
|
"whitespace": [
|
||||||
|
@ -44,7 +44,9 @@ module.exports = function (config) {
|
|||||||
|
|
||||||
{pattern: config.component + '/**/*.ts', included: false, served: true, watched: false},
|
{pattern: config.component + '/**/*.ts', included: false, served: true, watched: false},
|
||||||
|
|
||||||
{pattern: './config/app.config.json', included: false, served: true, watched: false}
|
{pattern: './config/app.config.json', included: false, served: true, watched: false},
|
||||||
|
{pattern: './core/viewer/assets/fake-test-file.pdf', included: false, served: true, watched: false},
|
||||||
|
{pattern: './core/viewer/assets/fake-test-file.txt', included: false, served: true, watched: false}
|
||||||
],
|
],
|
||||||
|
|
||||||
webpack: (config.mode === 'coverage') ? webpackCoverage(config) : webpackTest(config),
|
webpack: (config.mode === 'coverage') ? webpackCoverage(config) : webpackTest(config),
|
||||||
@ -59,7 +61,9 @@ module.exports = function (config) {
|
|||||||
port: 9876,
|
port: 9876,
|
||||||
|
|
||||||
proxies: {
|
proxies: {
|
||||||
'/app.config.json': '/base/config/app.config.json'
|
'/app.config.json': '/base/config/app.config.json',
|
||||||
|
'/fake-test-file.pdf': '/base/core/viewer/assets/fake-test-file.pdf',
|
||||||
|
'/fake-test-file.txt': '/base/core/viewer/assets/fake-test-file.txt'
|
||||||
},
|
},
|
||||||
|
|
||||||
// level of logging
|
// level of logging
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* tslint:disable:no-input-rename */
|
/* tslint:disable: no-input-rename no-use-before-declare no-input-rename */
|
||||||
|
|
||||||
import { ENTER, ESCAPE } from '@angular/cdk/keycodes';
|
import { ENTER, ESCAPE } from '@angular/cdk/keycodes';
|
||||||
import {
|
import {
|
||||||
|
@ -59,7 +59,7 @@ describe('SearchComponent', () => {
|
|||||||
fixture.destroy();
|
fixture.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should clear results straight away when a new search term is entered', async(() => {
|
it('should clear results straight away when a new search term is entered', (done) => {
|
||||||
spyOn(searchService, 'search')
|
spyOn(searchService, 'search')
|
||||||
.and.returnValues(Observable.of(result), Observable.of(differentResult));
|
.and.returnValues(Observable.of(result), Observable.of(differentResult));
|
||||||
|
|
||||||
@ -75,11 +75,12 @@ describe('SearchComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
optionShowed = element.querySelectorAll('#autocomplete-search-result-list > li').length;
|
optionShowed = element.querySelectorAll('#autocomplete-search-result-list > li').length;
|
||||||
expect(optionShowed).toBe(1);
|
expect(optionShowed).toBe(1);
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}));
|
});
|
||||||
|
|
||||||
it('should display the returned search results', async(() => {
|
it('should display the returned search results', (done) => {
|
||||||
spyOn(searchService, 'search')
|
spyOn(searchService, 'search')
|
||||||
.and.returnValue(Observable.of(result));
|
.and.returnValue(Observable.of(result));
|
||||||
|
|
||||||
@ -89,10 +90,11 @@ describe('SearchComponent', () => {
|
|||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(element.querySelector('#result_option_0').textContent.trim()).toBe('MyDoc');
|
expect(element.querySelector('#result_option_0').textContent.trim()).toBe('MyDoc');
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
}));
|
});
|
||||||
|
|
||||||
it('should emit error event when search call fail', async(() => {
|
it('should emit error event when search call fail', (done) => {
|
||||||
spyOn(searchService, 'search')
|
spyOn(searchService, 'search')
|
||||||
.and.returnValue(Observable.fromPromise(Promise.reject({ status: 402 })));
|
.and.returnValue(Observable.fromPromise(Promise.reject({ status: 402 })));
|
||||||
component.setSearchWordTo('searchTerm');
|
component.setSearchWordTo('searchTerm');
|
||||||
@ -101,10 +103,11 @@ describe('SearchComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
let message: HTMLElement = <HTMLElement> element.querySelector('#component-result-message');
|
let message: HTMLElement = <HTMLElement> element.querySelector('#component-result-message');
|
||||||
expect(message.textContent).toBe('ERROR');
|
expect(message.textContent).toBe('ERROR');
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
}));
|
});
|
||||||
|
|
||||||
it('should be able to hide the result panel', async(() => {
|
it('should be able to hide the result panel', (done) => {
|
||||||
spyOn(searchService, 'search')
|
spyOn(searchService, 'search')
|
||||||
.and.returnValues(Observable.of(result), Observable.of(differentResult));
|
.and.returnValues(Observable.of(result), Observable.of(differentResult));
|
||||||
|
|
||||||
@ -120,9 +123,10 @@ describe('SearchComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
let elementList = element.querySelector('#adf-search-results-content');
|
let elementList = element.querySelector('#adf-search-results-content');
|
||||||
expect(elementList.classList).toContain('adf-search-hide');
|
expect(elementList.classList).toContain('adf-search-hide');
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}));
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('search node', () => {
|
describe('search node', () => {
|
||||||
@ -131,7 +135,7 @@ describe('SearchComponent', () => {
|
|||||||
fixture.destroy();
|
fixture.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should perform a search based on the query node given', async(() => {
|
it('should perform a search based on the query node given', (done) => {
|
||||||
spyOn(searchService, 'searchByQueryBody')
|
spyOn(searchService, 'searchByQueryBody')
|
||||||
.and.callFake((searchObj) => fakeNodeResultSearch(searchObj));
|
.and.callFake((searchObj) => fakeNodeResultSearch(searchObj));
|
||||||
let fakeSearchNode: QueryBody = {
|
let fakeSearchNode: QueryBody = {
|
||||||
@ -151,10 +155,11 @@ describe('SearchComponent', () => {
|
|||||||
expect(optionShowed).toBe(1);
|
expect(optionShowed).toBe(1);
|
||||||
let folderOption: HTMLElement = <HTMLElement> element.querySelector('#result_option_0');
|
let folderOption: HTMLElement = <HTMLElement> element.querySelector('#result_option_0');
|
||||||
expect(folderOption.textContent.trim()).toBe('MyFolder');
|
expect(folderOption.textContent.trim()).toBe('MyFolder');
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
}));
|
});
|
||||||
|
|
||||||
it('should perform a search with a defaultNode if no searchnode is given', async(() => {
|
it('should perform a search with a defaultNode if no searchnode is given', (done) => {
|
||||||
spyOn(searchService, 'search')
|
spyOn(searchService, 'search')
|
||||||
.and.returnValue(Observable.of(result));
|
.and.returnValue(Observable.of(result));
|
||||||
component.setSearchWordTo('searchTerm');
|
component.setSearchWordTo('searchTerm');
|
||||||
@ -165,10 +170,11 @@ describe('SearchComponent', () => {
|
|||||||
expect(optionShowed).toBe(1);
|
expect(optionShowed).toBe(1);
|
||||||
let folderOption: HTMLElement = <HTMLElement> element.querySelector('#result_option_0');
|
let folderOption: HTMLElement = <HTMLElement> element.querySelector('#result_option_0');
|
||||||
expect(folderOption.textContent.trim()).toBe('MyDoc');
|
expect(folderOption.textContent.trim()).toBe('MyDoc');
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
}));
|
});
|
||||||
|
|
||||||
it('should perform a search with the searchNode given', async(() => {
|
it('should perform a search with the searchNode given', (done) => {
|
||||||
spyOn(searchService, 'searchByQueryBody')
|
spyOn(searchService, 'searchByQueryBody')
|
||||||
.and.callFake((searchObj) => fakeNodeResultSearch(searchObj));
|
.and.callFake((searchObj) => fakeNodeResultSearch(searchObj));
|
||||||
let fakeSearchNode: QueryBody = {
|
let fakeSearchNode: QueryBody = {
|
||||||
@ -188,7 +194,8 @@ describe('SearchComponent', () => {
|
|||||||
expect(optionShowed).toBe(1);
|
expect(optionShowed).toBe(1);
|
||||||
let folderOption: HTMLElement = <HTMLElement> element.querySelector('#result_option_0');
|
let folderOption: HTMLElement = <HTMLElement> element.querySelector('#result_option_0');
|
||||||
expect(folderOption.textContent.trim()).toBe('TEST_DOC');
|
expect(folderOption.textContent.trim()).toBe('TEST_DOC');
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
}));
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -18,6 +18,17 @@
|
|||||||
import { BaseEvent } from '../../../events';
|
import { BaseEvent } from '../../../events';
|
||||||
import { DataRow } from '../../data/data-row.model';
|
import { DataRow } from '../../data/data-row.model';
|
||||||
|
|
||||||
|
export class DataRowActionModel {
|
||||||
|
|
||||||
|
row: DataRow;
|
||||||
|
action: any;
|
||||||
|
|
||||||
|
constructor(row: DataRow, action: any) {
|
||||||
|
this.row = row;
|
||||||
|
this.action = action;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export class DataRowActionEvent extends BaseEvent<DataRowActionModel> {
|
export class DataRowActionEvent extends BaseEvent<DataRowActionModel> {
|
||||||
|
|
||||||
// backwards compatibility with 1.2.0 and earlier
|
// backwards compatibility with 1.2.0 and earlier
|
||||||
@ -31,14 +42,3 @@ export class DataRowActionEvent extends BaseEvent<DataRowActionModel> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DataRowActionModel {
|
|
||||||
|
|
||||||
row: DataRow;
|
|
||||||
action: any;
|
|
||||||
|
|
||||||
constructor(row: DataRow, action: any) {
|
|
||||||
this.row = row;
|
|
||||||
this.action = action;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -33,29 +33,6 @@ export class BpmProductVersionModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class EcmProductVersionModel {
|
|
||||||
edition: string;
|
|
||||||
version: VersionModel;
|
|
||||||
license: LicenseModel;
|
|
||||||
status: VersionStatusModel;
|
|
||||||
modules: VersionModuleModel[] = [];
|
|
||||||
|
|
||||||
constructor(obj?: any) {
|
|
||||||
if (obj && obj.entry && obj.entry.repository) {
|
|
||||||
this.edition = obj.entry.repository.edition || null;
|
|
||||||
this.version = new VersionModel(obj.entry.repository.version);
|
|
||||||
this.license = new LicenseModel(obj.entry.repository.license);
|
|
||||||
this.status = new VersionStatusModel(obj.entry.repository.status);
|
|
||||||
if (obj.entry.repository.modules) {
|
|
||||||
obj.entry.repository.modules.forEach((module) => {
|
|
||||||
this.modules.push(new VersionModuleModel(module));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
export class VersionModel {
|
export class VersionModel {
|
||||||
major: string;
|
major: string;
|
||||||
minor: string;
|
minor: string;
|
||||||
@ -139,3 +116,26 @@ export class VersionModuleModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class EcmProductVersionModel {
|
||||||
|
edition: string;
|
||||||
|
version: VersionModel;
|
||||||
|
license: LicenseModel;
|
||||||
|
status: VersionStatusModel;
|
||||||
|
modules: VersionModuleModel[] = [];
|
||||||
|
|
||||||
|
constructor(obj?: any) {
|
||||||
|
if (obj && obj.entry && obj.entry.repository) {
|
||||||
|
this.edition = obj.entry.repository.edition || null;
|
||||||
|
this.version = new VersionModel(obj.entry.repository.version);
|
||||||
|
this.license = new LicenseModel(obj.entry.repository.license);
|
||||||
|
this.status = new VersionStatusModel(obj.entry.repository.status);
|
||||||
|
if (obj.entry.repository.modules) {
|
||||||
|
obj.entry.repository.modules.forEach((module) => {
|
||||||
|
this.modules.push(new VersionModuleModel(module));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { Component, SimpleChange, ViewChild } from '@angular/core';
|
||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import {
|
import {
|
||||||
AlfrescoApiService,
|
AlfrescoApiService,
|
||||||
@ -28,36 +29,48 @@ import { RenderingQueueServices } from '../services/rendering-queue.services';
|
|||||||
import { PdfViewerComponent } from './pdfViewer.component';
|
import { PdfViewerComponent } from './pdfViewer.component';
|
||||||
import { PdfThumbListComponent } from './pdfViewer-thumbnails.component';
|
import { PdfThumbListComponent } from './pdfViewer-thumbnails.component';
|
||||||
import { PdfThumbComponent } from './pdfViewer-thumb.component';
|
import { PdfThumbComponent } from './pdfViewer-thumb.component';
|
||||||
|
import { RIGHT_ARROW, LEFT_ARROW } from '@angular/cdk/keycodes';
|
||||||
|
|
||||||
declare var require: any;
|
@Component({
|
||||||
|
template: `
|
||||||
|
<adf-pdf-viewer [allowThumbnails]="true"
|
||||||
|
[showToolbar]="true"
|
||||||
|
[urlFile]="urlFile">
|
||||||
|
</adf-pdf-viewer>
|
||||||
|
`
|
||||||
|
})
|
||||||
|
class UrlTestComponent {
|
||||||
|
|
||||||
describe('Test PdfViewer component', () => {
|
@ViewChild(PdfViewerComponent)
|
||||||
|
pdfViewerComponent: PdfViewerComponent;
|
||||||
|
|
||||||
let component: PdfViewerComponent;
|
urlFile: any;
|
||||||
let fixture: ComponentFixture<PdfViewerComponent>;
|
|
||||||
let element: HTMLElement;
|
|
||||||
|
|
||||||
beforeEach(async(() => {
|
constructor() {
|
||||||
TestBed.configureTestingModule({
|
this.urlFile = './fake-test-file.pdf';
|
||||||
imports: [
|
}
|
||||||
ToolbarModule,
|
}
|
||||||
MaterialModule
|
|
||||||
],
|
|
||||||
declarations: [
|
|
||||||
PdfViewerComponent,
|
|
||||||
PdfThumbListComponent,
|
|
||||||
PdfThumbComponent
|
|
||||||
],
|
|
||||||
providers: [
|
|
||||||
SettingsService,
|
|
||||||
AuthenticationService,
|
|
||||||
AlfrescoApiService,
|
|
||||||
RenderingQueueServices
|
|
||||||
]
|
|
||||||
}).compileComponents();
|
|
||||||
}));
|
|
||||||
|
|
||||||
function createFakeBlob(): Blob {
|
@Component({
|
||||||
|
template: `
|
||||||
|
<adf-pdf-viewer [allowThumbnails]="true"
|
||||||
|
[showToolbar]="true"
|
||||||
|
[blobFile]="blobFile">
|
||||||
|
</adf-pdf-viewer>
|
||||||
|
`
|
||||||
|
})
|
||||||
|
class BlobTestComponent {
|
||||||
|
|
||||||
|
@ViewChild(PdfViewerComponent)
|
||||||
|
pdfViewerComponent: PdfViewerComponent;
|
||||||
|
|
||||||
|
blobFile: any;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.blobFile = this.createFakeBlob();
|
||||||
|
}
|
||||||
|
|
||||||
|
createFakeBlob(): Blob {
|
||||||
let pdfData = atob(
|
let pdfData = atob(
|
||||||
'JVBERi0xLjcKCjEgMCBvYmogICUgZW50cnkgcG9pbnQKPDwKICAvVHlwZSAvQ2F0YWxvZwog' +
|
'JVBERi0xLjcKCjEgMCBvYmogICUgZW50cnkgcG9pbnQKPDwKICAvVHlwZSAvQ2F0YWxvZwog' +
|
||||||
'IC9QYWdlcyAyIDAgUgo+PgplbmRvYmoKCjIgMCBvYmoKPDwKICAvVHlwZSAvUGFnZXMKICAv' +
|
'IC9QYWdlcyAyIDAgUgo+PgplbmRvYmoKCjIgMCBvYmoKPDwKICAvVHlwZSAvUGFnZXMKICAv' +
|
||||||
@ -75,418 +88,408 @@ describe('Test PdfViewer component', () => {
|
|||||||
return new Blob([pdfData], { type: 'application/pdf' });
|
return new Blob([pdfData], { type: 'application/pdf' });
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(() => {
|
}
|
||||||
|
|
||||||
|
describe('Test PdfViewer component', () => {
|
||||||
|
|
||||||
|
let component: PdfViewerComponent;
|
||||||
|
let fixture: ComponentFixture<PdfViewerComponent>;
|
||||||
|
let element: HTMLElement;
|
||||||
|
let change: any;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports: [
|
||||||
|
ToolbarModule,
|
||||||
|
MaterialModule
|
||||||
|
],
|
||||||
|
declarations: [
|
||||||
|
PdfViewerComponent,
|
||||||
|
PdfThumbListComponent,
|
||||||
|
PdfThumbComponent,
|
||||||
|
UrlTestComponent,
|
||||||
|
BlobTestComponent
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
SettingsService,
|
||||||
|
AuthenticationService,
|
||||||
|
AlfrescoApiService,
|
||||||
|
RenderingQueueServices
|
||||||
|
]
|
||||||
|
}).compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach((done) => {
|
||||||
fixture = TestBed.createComponent(PdfViewerComponent);
|
fixture = TestBed.createComponent(PdfViewerComponent);
|
||||||
|
|
||||||
element = fixture.nativeElement;
|
element = fixture.nativeElement;
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
|
|
||||||
component.showToolbar = true;
|
component.showToolbar = true;
|
||||||
|
component.inputPage('1');
|
||||||
|
component.currentScale = 1;
|
||||||
|
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
fixture.whenStable().then(() => {
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should Loader be present', () => {
|
||||||
|
expect(element.querySelector('.loader-container')).not.toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Required values', () => {
|
||||||
|
it('should thrown an error If urlfile is not present', () => {
|
||||||
|
change = new SimpleChange(null, null, true);
|
||||||
|
|
||||||
|
expect(() => {
|
||||||
|
component.ngOnChanges({ 'urlFile': change });
|
||||||
|
}).toThrow(new Error('Attribute urlFile or blobFile is required'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should If blobFile is not present thrown an error ', () => {
|
||||||
|
change = new SimpleChange(null, null, true);
|
||||||
|
|
||||||
|
expect(() => {
|
||||||
|
component.ngOnChanges({ 'blobFile': change });
|
||||||
|
}).toThrow(new Error('Attribute urlFile or blobFile is required'));
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('View with url file', () => {
|
describe('View with url file', () => {
|
||||||
beforeEach(() => {
|
|
||||||
component.urlFile = require('../assets/fake-test-file.pdf');
|
let fixtureUrlTestComponent: ComponentFixture<UrlTestComponent>;
|
||||||
fixture.detectChanges();
|
let elementUrlTestComponent: HTMLElement;
|
||||||
|
|
||||||
|
beforeEach((done) => {
|
||||||
|
fixtureUrlTestComponent = TestBed.createComponent(UrlTestComponent);
|
||||||
|
elementUrlTestComponent = fixtureUrlTestComponent.nativeElement;
|
||||||
|
|
||||||
|
fixtureUrlTestComponent.detectChanges();
|
||||||
|
|
||||||
|
fixtureUrlTestComponent.whenStable().then(() => {
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should thrown an error If urlfile is not present', () => {
|
it('should Canvas be present', (done) => {
|
||||||
component.urlFile = undefined;
|
fixtureUrlTestComponent.detectChanges();
|
||||||
|
fixtureUrlTestComponent.whenStable().then(() => {
|
||||||
|
expect(elementUrlTestComponent.querySelector('.pdfViewer')).not.toBeNull();
|
||||||
|
expect(elementUrlTestComponent.querySelector('.viewer-pdf-viewer')).not.toBeNull();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
}, 5000);
|
||||||
|
|
||||||
fixture.detectChanges();
|
it('should Next an Previous Buttons be present', (done) => {
|
||||||
|
fixtureUrlTestComponent.detectChanges();
|
||||||
|
fixtureUrlTestComponent.whenStable().then(() => {
|
||||||
|
expect(elementUrlTestComponent.querySelector('#viewer-previous-page-button')).not.toBeNull();
|
||||||
|
expect(elementUrlTestComponent.querySelector('#viewer-next-page-button')).not.toBeNull();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
}, 5000);
|
||||||
|
|
||||||
expect(() => {
|
it('should Input Page elements be present', (done) => {
|
||||||
component.ngOnChanges(null);
|
|
||||||
}).toThrow(new Error('Attribute urlFile or blobFile is required'));
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should Canvas be present', () => {
|
fixtureUrlTestComponent.detectChanges();
|
||||||
expect(element.querySelector('.pdfViewer')).not.toBeNull();
|
fixtureUrlTestComponent.whenStable().then(() => {
|
||||||
expect(element.querySelector('.viewer-pdf-viewer')).not.toBeNull();
|
expect(elementUrlTestComponent.querySelector('.viewer-pagenumber-input')).toBeDefined();
|
||||||
});
|
expect(elementUrlTestComponent.querySelector('.viewer-total-pages')).toBeDefined();
|
||||||
|
|
||||||
it('should Loader be present', () => {
|
expect(elementUrlTestComponent.querySelector('#viewer-previous-page-button')).not.toBeNull();
|
||||||
expect(element.querySelector('.loader-container')).not.toBeNull();
|
expect(elementUrlTestComponent.querySelector('#viewer-next-page-button')).not.toBeNull();
|
||||||
});
|
done();
|
||||||
|
});
|
||||||
|
}, 5000);
|
||||||
|
|
||||||
it('should Next an Previous Buttons be present', () => {
|
it('should Toolbar be hide if showToolbar is false', (done) => {
|
||||||
expect(element.querySelector('#viewer-previous-page-button')).not.toBeNull();
|
|
||||||
expect(element.querySelector('#viewer-next-page-button')).not.toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should Input Page elements be present', () => {
|
|
||||||
expect(element.querySelector('.viewer-pagenumber-input')).toBeDefined();
|
|
||||||
expect(element.querySelector('.viewer-total-pages')).toBeDefined();
|
|
||||||
|
|
||||||
expect(element.querySelector('#viewer-previous-page-button')).not.toBeNull();
|
|
||||||
expect(element.querySelector('#viewer-next-page-button')).not.toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should Toolbar be hide if showToolbar is false', () => {
|
|
||||||
component.showToolbar = false;
|
component.showToolbar = false;
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixtureUrlTestComponent.detectChanges();
|
||||||
|
fixtureUrlTestComponent.whenStable().then(() => {
|
||||||
expect(element.querySelector('.viewer-toolbar-command')).toBeNull();
|
expect(elementUrlTestComponent.querySelector('.viewer-toolbar-command')).toBeNull();
|
||||||
expect(element.querySelector('.viewer-toolbar-pagination')).toBeNull();
|
expect(elementUrlTestComponent.querySelector('.viewer-toolbar-pagination')).toBeNull();
|
||||||
});
|
done();
|
||||||
|
});
|
||||||
|
}, 5000);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('View with blob file', () => {
|
describe('View with blob file', () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
let fixtureBlobTestComponent: ComponentFixture<BlobTestComponent>;
|
||||||
component.urlFile = undefined;
|
let componentBlobTestComponent: BlobTestComponent;
|
||||||
component.blobFile = createFakeBlob();
|
let elementBlobTestComponent: HTMLElement;
|
||||||
|
|
||||||
fixture.detectChanges();
|
beforeEach((done) => {
|
||||||
|
fixtureBlobTestComponent = TestBed.createComponent(BlobTestComponent);
|
||||||
|
componentBlobTestComponent = fixtureBlobTestComponent.componentInstance;
|
||||||
|
elementBlobTestComponent = fixtureBlobTestComponent.nativeElement;
|
||||||
|
|
||||||
|
fixtureBlobTestComponent.detectChanges();
|
||||||
|
|
||||||
|
componentBlobTestComponent.pdfViewerComponent.rendered.subscribe(() => {
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should If blobFile is not present thrown an error ', () => {
|
it('should Canvas be present', (done) => {
|
||||||
component.blobFile = undefined;
|
fixtureBlobTestComponent.detectChanges();
|
||||||
expect(() => {
|
|
||||||
component.ngOnChanges(null);
|
|
||||||
}).toThrow(new Error('Attribute urlFile or blobFile is required'));
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should Canvas be present', () => {
|
fixtureBlobTestComponent.whenStable().then(() => {
|
||||||
expect(element.querySelector('.pdfViewer')).not.toBeNull();
|
expect(elementBlobTestComponent.querySelector('.pdfViewer')).not.toBeNull();
|
||||||
expect(element.querySelector('.viewer-pdf-viewer')).not.toBeNull();
|
expect(elementBlobTestComponent.querySelector('.viewer-pdf-viewer')).not.toBeNull();
|
||||||
});
|
done();
|
||||||
|
};
|
||||||
|
}, 5000);
|
||||||
|
|
||||||
it('should Loader be present', () => {
|
it('should Next an Previous Buttons be present', (done) => {
|
||||||
expect(element.querySelector('.loader-container')).not.toBeNull();
|
fixtureBlobTestComponent.detectChanges();
|
||||||
});
|
|
||||||
|
|
||||||
it('should Next an Previous Buttons be present', () => {
|
fixtureBlobTestComponent.whenStable().then(() => {
|
||||||
expect(element.querySelector('#viewer-previous-page-button')).not.toBeNull();
|
expect(elementBlobTestComponent.querySelector('#viewer-previous-page-button')).not.toBeNull();
|
||||||
expect(element.querySelector('#viewer-next-page-button')).not.toBeNull();
|
expect(elementBlobTestComponent.querySelector('#viewer-next-page-button')).not.toBeNull();
|
||||||
});
|
done();
|
||||||
|
};
|
||||||
|
}, 5000);
|
||||||
|
|
||||||
it('should Input Page elements be present', () => {
|
it('should Input Page elements be present', (done) => {
|
||||||
expect(element.querySelector('.viewer-pagenumber-input')).toBeDefined();
|
fixtureBlobTestComponent.detectChanges();
|
||||||
expect(element.querySelector('.viewer-total-pages')).toBeDefined();
|
|
||||||
|
|
||||||
expect(element.querySelector('#viewer-previous-page-button')).not.toBeNull();
|
fixtureBlobTestComponent.whenStable().then(() => {
|
||||||
expect(element.querySelector('#viewer-next-page-button')).not.toBeNull();
|
expect(elementBlobTestComponent.querySelector('.viewer-pagenumber-input')).toBeDefined();
|
||||||
});
|
expect(elementBlobTestComponent.querySelector('.viewer-total-pages')).toBeDefined();
|
||||||
|
|
||||||
it('should Toolbar be hide if showToolbar is false', () => {
|
expect(elementBlobTestComponent.querySelector('#viewer-previous-page-button')).not.toBeNull();
|
||||||
component.showToolbar = false;
|
expect(elementBlobTestComponent.querySelector('#viewer-next-page-button')).not.toBeNull();
|
||||||
|
done();
|
||||||
|
};
|
||||||
|
}, 5000);
|
||||||
|
|
||||||
fixture.detectChanges();
|
it('should Toolbar be hide if showToolbar is false', (done) => {
|
||||||
|
componentBlobTestComponent.pdfViewerComponent.showToolbar = false;
|
||||||
|
|
||||||
expect(element.querySelector('.viewer-toolbar-command')).toBeNull();
|
fixtureBlobTestComponent.detectChanges();
|
||||||
expect(element.querySelector('.viewer-toolbar-pagination')).toBeNull();
|
|
||||||
});
|
fixtureBlobTestComponent.whenStable().then(() => {
|
||||||
|
expect(elementBlobTestComponent.querySelector('.viewer-toolbar-command')).toBeNull();
|
||||||
|
expect(elementBlobTestComponent.querySelector('.viewer-toolbar-pagination')).toBeNull();
|
||||||
|
done();
|
||||||
|
};
|
||||||
|
}, 5000);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('User interaction', () => {
|
describe('User interaction', () => {
|
||||||
|
|
||||||
beforeEach(async(() => {
|
let fixtureUrlTestComponent: ComponentFixture<UrlTestComponent>;
|
||||||
component.urlFile = require('../assets/fake-test-file.pdf');
|
let componentUrlTestComponent: UrlTestComponent;
|
||||||
fixture.detectChanges();
|
let elementUrlTestComponent: HTMLElement;
|
||||||
fixture.whenStable().then(() => {
|
|
||||||
component.inputPage('1');
|
beforeEach((done) => {
|
||||||
|
fixtureUrlTestComponent = TestBed.createComponent(UrlTestComponent);
|
||||||
|
componentUrlTestComponent = fixtureUrlTestComponent.componentInstance;
|
||||||
|
elementUrlTestComponent = fixtureUrlTestComponent.nativeElement;
|
||||||
|
|
||||||
|
fixtureUrlTestComponent.detectChanges();
|
||||||
|
|
||||||
|
componentUrlTestComponent.pdfViewerComponent.rendered.subscribe(() => {
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
}));
|
});
|
||||||
|
|
||||||
it('should Total number of pages be loaded', (done) => {
|
it('should Total number of pages be loaded', (done) => {
|
||||||
component.ngOnChanges(null).then(() => {
|
fixtureUrlTestComponent.detectChanges();
|
||||||
fixture.detectChanges();
|
|
||||||
fixture.whenStable().then(() => {
|
|
||||||
expect(component.totalPages).toEqual(6);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should right arrow move to the next page', (done) => {
|
fixtureUrlTestComponent.whenStable().then(() => {
|
||||||
component.ngOnChanges(null).then(() => {
|
expect(componentUrlTestComponent.pdfViewerComponent.totalPages).toBe(6);
|
||||||
fixture.detectChanges();
|
done();
|
||||||
fixture.whenStable().then(() => {
|
|
||||||
expect(component.displayPage).toBe(1);
|
|
||||||
EventMock.keyDown(39);
|
|
||||||
fixture.detectChanges();
|
|
||||||
expect(component.displayPage).toBe(2);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
}, 5000);
|
||||||
|
|
||||||
it('should nextPage move to the next page', (done) => {
|
it('should nextPage move to the next page', (done) => {
|
||||||
let nextPageButton: any = element.querySelector('#viewer-next-page-button');
|
let nextPageButton: any = elementUrlTestComponent.querySelector('#viewer-next-page-button');
|
||||||
|
nextPageButton.click();
|
||||||
|
|
||||||
component.ngOnChanges(null).then(() => {
|
fixtureUrlTestComponent.detectChanges();
|
||||||
fixture.detectChanges();
|
|
||||||
fixture.whenStable().then(() => {
|
|
||||||
|
|
||||||
expect(component.displayPage).toBe(1);
|
fixtureUrlTestComponent.whenStable().then(() => {
|
||||||
nextPageButton.click();
|
expect(componentUrlTestComponent.pdfViewerComponent.displayPage).toBe(2);
|
||||||
fixture.detectChanges();
|
done();
|
||||||
expect(component.displayPage).toBe(2);
|
});
|
||||||
|
}, 5000);
|
||||||
|
|
||||||
|
it('should event RIGHT_ARROW keyboard change pages', (done) => {
|
||||||
|
EventMock.keyDown(RIGHT_ARROW);
|
||||||
|
|
||||||
|
fixtureUrlTestComponent.detectChanges();
|
||||||
|
|
||||||
|
fixtureUrlTestComponent.whenStable().then(() => {
|
||||||
|
expect(componentUrlTestComponent.pdfViewerComponent.displayPage).toBe(2);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
}, 5000);
|
||||||
|
|
||||||
|
it('should event LEFT_ARROW keyboard change pages', (done) => {
|
||||||
|
component.inputPage('2');
|
||||||
|
|
||||||
|
fixtureUrlTestComponent.detectChanges();
|
||||||
|
|
||||||
|
fixtureUrlTestComponent.whenStable().then(() => {
|
||||||
|
EventMock.keyDown(LEFT_ARROW);
|
||||||
|
|
||||||
|
fixtureUrlTestComponent.detectChanges();
|
||||||
|
|
||||||
|
fixtureUrlTestComponent.whenStable().then(() => {
|
||||||
|
expect(componentUrlTestComponent.pdfViewerComponent.displayPage).toBe(1);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
}, 5000);
|
||||||
|
|
||||||
it('should event keyboard change pages', (done) => {
|
|
||||||
component.ngOnChanges(null).then(() => {
|
|
||||||
fixture.detectChanges();
|
|
||||||
fixture.whenStable().then(() => {
|
|
||||||
|
|
||||||
expect(component.displayPage).toBe(1);
|
|
||||||
EventMock.keyDown(39);
|
|
||||||
EventMock.keyDown(39);
|
|
||||||
EventMock.keyDown(37);
|
|
||||||
fixture.detectChanges();
|
|
||||||
expect(component.displayPage).toBe(2);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should previous page move to the previous page', (done) => {
|
it('should previous page move to the previous page', (done) => {
|
||||||
let previousPageButton: any = element.querySelector('#viewer-previous-page-button');
|
let previousPageButton: any = elementUrlTestComponent.querySelector('#viewer-previous-page-button');
|
||||||
let nextPageButton: any = element.querySelector('#viewer-next-page-button');
|
let nextPageButton: any = elementUrlTestComponent.querySelector('#viewer-next-page-button');
|
||||||
|
|
||||||
component.ngOnChanges(null).then(() => {
|
nextPageButton.click();
|
||||||
fixture.detectChanges();
|
nextPageButton.click();
|
||||||
fixture.whenStable().then(() => {
|
previousPageButton.click();
|
||||||
|
fixtureUrlTestComponent.detectChanges();
|
||||||
|
|
||||||
expect(component.displayPage).toBe(1);
|
fixtureUrlTestComponent.whenStable().then(() => {
|
||||||
nextPageButton.click();
|
expect(componentUrlTestComponent.pdfViewerComponent.displayPage).toBe(2);
|
||||||
nextPageButton.click();
|
done();
|
||||||
previousPageButton.click();
|
|
||||||
fixture.detectChanges();
|
|
||||||
expect(component.displayPage).toBe(2);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
}, 5000);
|
||||||
|
|
||||||
it('should previous page not move to the previous page if is page 1', (done) => {
|
it('should previous page not move to the previous page if is page 1', (done) => {
|
||||||
component.ngOnChanges(null).then(() => {
|
component.previousPage();
|
||||||
fixture.detectChanges();
|
fixtureUrlTestComponent.detectChanges();
|
||||||
fixture.whenStable().then(() => {
|
|
||||||
|
|
||||||
expect(component.displayPage).toBe(1);
|
fixtureUrlTestComponent.whenStable().then(() => {
|
||||||
component.previousPage();
|
expect(componentUrlTestComponent.pdfViewerComponent.displayPage).toBe(1);
|
||||||
fixture.detectChanges();
|
done();
|
||||||
expect(component.displayPage).toBe(1);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
}, 5000);
|
||||||
|
|
||||||
it('should Input page move to the inserted page', (done) => {
|
it('should Input page move to the inserted page', (done) => {
|
||||||
component.ngOnChanges(null).then(() => {
|
componentUrlTestComponent.pdfViewerComponent.inputPage('2');
|
||||||
fixture.detectChanges();
|
fixtureUrlTestComponent.detectChanges();
|
||||||
fixture.whenStable().then(() => {
|
|
||||||
|
|
||||||
expect(component.displayPage).toBe(1);
|
fixtureUrlTestComponent.whenStable().then(() => {
|
||||||
component.inputPage('2');
|
expect(componentUrlTestComponent.pdfViewerComponent.displayPage).toBe(2);
|
||||||
fixture.detectChanges();
|
done();
|
||||||
expect(component.displayPage).toBe(2);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
}, 5000);
|
||||||
});
|
|
||||||
|
|
||||||
describe('Zoom', () => {
|
describe('Zoom', () => {
|
||||||
|
|
||||||
beforeEach(async(() => {
|
it('should zoom in increment the scale value', () => {
|
||||||
component.urlFile = require('../assets/fake-test-file.pdf');
|
let zoomInButton: any = elementUrlTestComponent.querySelector('#viewer-zoom-in-button');
|
||||||
fixture.detectChanges();
|
|
||||||
fixture.whenStable().then(() => {
|
|
||||||
component.inputPage('1');
|
|
||||||
component.currentScale = 1;
|
|
||||||
});
|
|
||||||
}));
|
|
||||||
|
|
||||||
it('should zoom in increment the scale value', (done) => {
|
let zoomBefore = componentUrlTestComponent.pdfViewerComponent.currentScale;
|
||||||
let zoomInButton: any = element.querySelector('#viewer-zoom-in-button');
|
|
||||||
|
|
||||||
component.ngOnChanges(null).then(() => {
|
|
||||||
let zoomBefore = component.currentScale;
|
|
||||||
zoomInButton.click();
|
zoomInButton.click();
|
||||||
expect(component.currentScaleMode).toBe('auto');
|
expect(componentUrlTestComponent.pdfViewerComponent.currentScaleMode).toBe('auto');
|
||||||
let currentZoom = component.currentScale;
|
let currentZoom = componentUrlTestComponent.pdfViewerComponent.currentScale;
|
||||||
expect(zoomBefore < currentZoom).toBe(true);
|
expect(zoomBefore < currentZoom).toBe(true);
|
||||||
done();
|
}, 5000);
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should zoom out decrement the scale value', (done) => {
|
it('should zoom out decrement the scale value', () => {
|
||||||
let zoomOutButton: any = element.querySelector('#viewer-zoom-out-button');
|
let zoomOutButton: any = elementUrlTestComponent.querySelector('#viewer-zoom-out-button');
|
||||||
|
|
||||||
component.ngOnChanges(null).then(() => {
|
let zoomBefore = componentUrlTestComponent.pdfViewerComponent.currentScale;
|
||||||
let zoomBefore = component.currentScale;
|
|
||||||
zoomOutButton.click();
|
zoomOutButton.click();
|
||||||
expect(component.currentScaleMode).toBe('auto');
|
expect(componentUrlTestComponent.pdfViewerComponent.currentScaleMode).toBe('auto');
|
||||||
let currentZoom = component.currentScale;
|
let currentZoom = componentUrlTestComponent.pdfViewerComponent.currentScale;
|
||||||
expect(zoomBefore > currentZoom).toBe(true);
|
expect(zoomBefore > currentZoom).toBe(true);
|
||||||
done();
|
}, 5000);
|
||||||
});
|
|
||||||
|
it('should it-in button toggle page-fit and auto scale mode', () => {
|
||||||
|
let itPage: any = elementUrlTestComponent.querySelector('#viewer-scale-page-button');
|
||||||
|
|
||||||
|
expect(componentUrlTestComponent.pdfViewerComponent.currentScaleMode).toBe('auto');
|
||||||
|
itPage.click();
|
||||||
|
expect(componentUrlTestComponent.pdfViewerComponent.currentScaleMode).toBe('page-fit');
|
||||||
|
itPage.click();
|
||||||
|
expect(componentUrlTestComponent.pdfViewerComponent.currentScaleMode).toBe('auto');
|
||||||
|
}, 5000);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fit-in button toggle page-fit and auto scale mode', (done) => {
|
describe('Resize interaction', () => {
|
||||||
let fitPage: any = element.querySelector('#viewer-scale-page-button');
|
|
||||||
|
|
||||||
component.ngOnChanges(null).then(() => {
|
it('should resize event trigger setScaleUpdatePages', () => {
|
||||||
expect(component.currentScaleMode).toBe('auto');
|
spyOn(componentUrlTestComponent.pdfViewerComponent, 'onResize');
|
||||||
fitPage.click();
|
EventMock.resizeMobileView();
|
||||||
expect(component.currentScaleMode).toBe('page-fit');
|
expect(componentUrlTestComponent.pdfViewerComponent.onResize).toHaveBeenCalled();
|
||||||
fitPage.click();
|
}, 5000);
|
||||||
expect(component.currentScaleMode).toBe('auto');
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
describe('Resize interaction', () => {
|
describe('Thumbnails', () => {
|
||||||
|
|
||||||
beforeEach(async(() => {
|
it('should have own context', () => {
|
||||||
component.urlFile = require('../assets/fake-test-file.pdf');
|
expect(componentUrlTestComponent.pdfViewerComponent.pdfThumbnailsContext.viewer).not.toBeNull();
|
||||||
fixture.detectChanges();
|
}, 5000);
|
||||||
fixture.whenStable().then(() => {
|
|
||||||
component.inputPage('1');
|
|
||||||
component.currentScale = 1;
|
|
||||||
});
|
|
||||||
}));
|
|
||||||
|
|
||||||
it('should resize event trigger setScaleUpdatePages', (done) => {
|
it('should open thumbnails panel', (done) => {
|
||||||
component.ngOnChanges(null).then(() => {
|
expect(elementUrlTestComponent.querySelector('.adf-pdf-viewer__thumbnails')).toBeNull();
|
||||||
fixture.detectChanges();
|
|
||||||
fixture.whenStable().then(() => {
|
|
||||||
|
|
||||||
spyOn(component, 'onResize');
|
componentUrlTestComponent.pdfViewerComponent.toggleThumbnails();
|
||||||
EventMock.resizeMobileView();
|
fixtureUrlTestComponent.detectChanges();
|
||||||
expect(component.onResize).toHaveBeenCalled();
|
|
||||||
|
fixtureUrlTestComponent.whenStable().then(() => {
|
||||||
|
expect(elementUrlTestComponent.querySelector('.adf-pdf-viewer__thumbnails')).not.toBeNull();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
}, 5000);
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('scroll interaction', () => {
|
|
||||||
|
|
||||||
beforeEach(async(() => {
|
|
||||||
component.urlFile = require('../assets/fake-test-file.pdf');
|
|
||||||
fixture.detectChanges();
|
|
||||||
fixture.whenStable().then(() => {
|
|
||||||
component.inputPage('1');
|
|
||||||
component.currentScale = 1;
|
|
||||||
});
|
|
||||||
}));
|
|
||||||
|
|
||||||
it('should scroll page return the current page', (done) => {
|
|
||||||
component.ngOnChanges(null).then(() => {
|
|
||||||
fixture.detectChanges();
|
|
||||||
fixture.whenStable().then(() => {
|
|
||||||
|
|
||||||
expect(component.displayPage).toBe(1);
|
|
||||||
|
|
||||||
component.inputPage('2');
|
|
||||||
fixture.detectChanges();
|
|
||||||
expect(component.displayPage).toBe(2);
|
|
||||||
|
|
||||||
component.pdfViewer.currentPageNumber = 6;
|
|
||||||
fixture.detectChanges();
|
|
||||||
expect(component.displayPage).toBe(6);
|
|
||||||
expect(component.page).toBe(6);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Thumbnails', () => {
|
|
||||||
beforeEach(async () => {
|
|
||||||
component.urlFile = require('../assets/fake-test-file.pdf');
|
|
||||||
component.showThumbnails = false;
|
|
||||||
fixture.detectChanges();
|
|
||||||
fixture.whenStable().then(() => {
|
|
||||||
component.inputPage('1');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have own context', (done) => {
|
describe('Viewer events', () => {
|
||||||
component.ngOnChanges(null).then(() => {
|
|
||||||
fixture.detectChanges();
|
|
||||||
fixture.whenStable().then(() => {
|
|
||||||
expect(component.pdfThumbnailsContext.viewer).not.toBeNull();
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should open thumbnails panel', (done) => {
|
|
||||||
expect(element.querySelector('.adf-pdf-viewer__thumbnails')).toBeNull();
|
|
||||||
|
|
||||||
component.ngOnChanges(null).then(() => {
|
|
||||||
fixture.detectChanges();
|
|
||||||
fixture.whenStable().then(() => {
|
|
||||||
component.toggleThumbnails();
|
|
||||||
fixture.detectChanges();
|
|
||||||
|
|
||||||
expect(element.querySelector('.adf-pdf-viewer__thumbnails')).not.toBeNull();
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Viewer events', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
component.urlFile = require('../assets/fake-test-file.pdf');
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should emit pagechange event', (done) => {
|
|
||||||
component.ngOnChanges(null).then(() => {
|
|
||||||
fixture.detectChanges();
|
|
||||||
return fixture.whenStable().then(() => {
|
|
||||||
expect(component.displayPage).toBe(1);
|
|
||||||
|
|
||||||
|
it('should react on the emit of pagechange event', (done) => {
|
||||||
|
fixtureUrlTestComponent.detectChanges();
|
||||||
|
fixtureUrlTestComponent.whenStable().then(() => {
|
||||||
const args = {
|
const args = {
|
||||||
pageNumber: 6,
|
pageNumber: 6,
|
||||||
source: {
|
source: {
|
||||||
container: component.documentContainer
|
container: componentUrlTestComponent.pdfViewerComponent.documentContainer
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
component.pdfViewer.eventBus.dispatch('pagechange', args);
|
componentUrlTestComponent.pdfViewerComponent.pdfViewer.eventBus.dispatch('pagechange', args);
|
||||||
fixture.detectChanges();
|
fixtureUrlTestComponent.detectChanges();
|
||||||
|
|
||||||
expect(component.displayPage).toBe(6);
|
fixtureUrlTestComponent.whenStable().then(() => {
|
||||||
expect(component.page).toBe(6);
|
expect(componentUrlTestComponent.pdfViewerComponent.displayPage).toBe(6);
|
||||||
done();
|
expect(componentUrlTestComponent.pdfViewerComponent.page).toBe(6);
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
}, 5000);
|
||||||
});
|
|
||||||
|
|
||||||
it('should emit pagesloaded event', (done) => {
|
it('should react on the emit of pagesloaded event', (done) => {
|
||||||
component.ngOnChanges(null).then(() => {
|
fixtureUrlTestComponent.detectChanges();
|
||||||
fixture.detectChanges();
|
fixtureUrlTestComponent.whenStable().then(() => {
|
||||||
return fixture.whenStable().then(() => {
|
expect(componentUrlTestComponent.pdfViewerComponent.isPanelDisabled = false;
|
||||||
expect(component.isPanelDisabled).toBe(true);
|
|
||||||
|
|
||||||
const args = {
|
const args = {
|
||||||
pagesCount: 10,
|
pagesCount: 10,
|
||||||
source: {
|
source: {
|
||||||
container: component.documentContainer
|
container: componentUrlTestComponent.pdfViewerComponent.documentContainer
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
component.pdfViewer.eventBus.dispatch('pagesloaded', args);
|
componentUrlTestComponent.pdfViewerComponent.pdfViewer.eventBus.dispatch('pagesloaded', args);
|
||||||
fixture.detectChanges();
|
fixtureUrlTestComponent.detectChanges();
|
||||||
|
|
||||||
expect(component.isPanelDisabled).toBe(false);
|
fixtureUrlTestComponent.whenStable().then(() => {
|
||||||
done();
|
expect(componentUrlTestComponent.pdfViewerComponent.isPanelDisabled).toBe(false);
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
}, 5000);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -15,7 +15,17 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, TemplateRef, HostListener, Input, OnChanges, OnDestroy, ViewEncapsulation } from '@angular/core';
|
import {
|
||||||
|
Component,
|
||||||
|
TemplateRef,
|
||||||
|
HostListener,
|
||||||
|
Output,
|
||||||
|
Input,
|
||||||
|
OnChanges,
|
||||||
|
OnDestroy,
|
||||||
|
ViewEncapsulation,
|
||||||
|
EventEmitter
|
||||||
|
} from '@angular/core';
|
||||||
import { LogService } from '../../services/log.service';
|
import { LogService } from '../../services/log.service';
|
||||||
import { RenderingQueueServices } from '../services/rendering-queue.services';
|
import { RenderingQueueServices } from '../services/rendering-queue.services';
|
||||||
|
|
||||||
@ -52,6 +62,13 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
|
|||||||
@Input()
|
@Input()
|
||||||
thumbnailsTemplate: TemplateRef<any> = null;
|
thumbnailsTemplate: TemplateRef<any> = null;
|
||||||
|
|
||||||
|
@Output()
|
||||||
|
rendered = new EventEmitter<any>();
|
||||||
|
|
||||||
|
@Output()
|
||||||
|
error = new EventEmitter<any>();
|
||||||
|
|
||||||
|
loadingTask: any;
|
||||||
currentPdfDocument: any;
|
currentPdfDocument: any;
|
||||||
page: number;
|
page: number;
|
||||||
displayPage: number;
|
displayPage: number;
|
||||||
@ -80,37 +97,39 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
|
|||||||
// needed to preserve "this" context
|
// needed to preserve "this" context
|
||||||
this.onPageChange = this.onPageChange.bind(this);
|
this.onPageChange = this.onPageChange.bind(this);
|
||||||
this.onPagesLoaded = this.onPagesLoaded.bind(this);
|
this.onPagesLoaded = this.onPagesLoaded.bind(this);
|
||||||
|
this.onPagerendered = this.onPagerendered.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes) {
|
ngOnChanges(changes) {
|
||||||
|
let blobFile = changes['blobFile'];
|
||||||
|
|
||||||
|
if (blobFile && blobFile.currentValue) {
|
||||||
|
let reader = new FileReader();
|
||||||
|
reader.onload = () => {
|
||||||
|
this.executePdf(reader.result);
|
||||||
|
};
|
||||||
|
reader.readAsArrayBuffer(blobFile.currentValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
let urlFile = changes['urlFile'];
|
||||||
|
if (urlFile && urlFile.currentValue) {
|
||||||
|
this.executePdf(urlFile.currentValue);
|
||||||
|
}
|
||||||
|
|
||||||
if (!this.urlFile && !this.blobFile) {
|
if (!this.urlFile && !this.blobFile) {
|
||||||
throw new Error('Attribute urlFile or blobFile is required');
|
throw new Error('Attribute urlFile or blobFile is required');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.urlFile) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
this.executePdf(this.urlFile, resolve, reject);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
let reader = new FileReader();
|
|
||||||
reader.onload = () => {
|
|
||||||
this.executePdf(reader.result, resolve, reject);
|
|
||||||
};
|
|
||||||
reader.readAsArrayBuffer(this.blobFile);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
executePdf(src, resolve, reject) {
|
executePdf(src) {
|
||||||
let loadingTask = this.getPDFJS().getDocument(src);
|
this.loadingTask = this.getPDFJS().getDocument(src);
|
||||||
|
|
||||||
loadingTask.onProgress = (progressData) => {
|
this.loadingTask.onProgress = (progressData) => {
|
||||||
let level = progressData.loaded / progressData.total;
|
let level = progressData.loaded / progressData.total;
|
||||||
this.loadingPercent = Math.round(level * 100);
|
this.loadingPercent = Math.round(level * 100);
|
||||||
};
|
};
|
||||||
|
|
||||||
loadingTask.then((pdfDocument) => {
|
this.loadingTask.then((pdfDocument) => {
|
||||||
this.currentPdfDocument = pdfDocument;
|
this.currentPdfDocument = pdfDocument;
|
||||||
this.totalPages = pdfDocument.numPages;
|
this.totalPages = pdfDocument.numPages;
|
||||||
this.page = 1;
|
this.page = 1;
|
||||||
@ -119,13 +138,12 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
|
|||||||
|
|
||||||
this.currentPdfDocument.getPage(1).then(() => {
|
this.currentPdfDocument.getPage(1).then(() => {
|
||||||
this.scalePage('auto');
|
this.scalePage('auto');
|
||||||
resolve();
|
|
||||||
}, (error) => {
|
}, (error) => {
|
||||||
reject(error);
|
this.error.emit();
|
||||||
});
|
});
|
||||||
|
|
||||||
}, (error) => {
|
}, (error) => {
|
||||||
reject(error);
|
this.error.emit();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,6 +163,7 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
|
|||||||
this.documentContainer = document.getElementById('viewer-pdf-viewer');
|
this.documentContainer = document.getElementById('viewer-pdf-viewer');
|
||||||
this.documentContainer.addEventListener('pagechange', this.onPageChange, true);
|
this.documentContainer.addEventListener('pagechange', this.onPageChange, true);
|
||||||
this.documentContainer.addEventListener('pagesloaded', this.onPagesLoaded, true);
|
this.documentContainer.addEventListener('pagesloaded', this.onPagesLoaded, true);
|
||||||
|
this.documentContainer.addEventListener('textlayerrendered', this.onPagerendered, true);
|
||||||
|
|
||||||
this.pdfViewer = new PDFJS.PDFViewer({
|
this.pdfViewer = new PDFJS.PDFViewer({
|
||||||
container: this.documentContainer,
|
container: this.documentContainer,
|
||||||
@ -163,6 +182,11 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
|
|||||||
if (this.documentContainer) {
|
if (this.documentContainer) {
|
||||||
this.documentContainer.removeEventListener('pagechange', this.onPageChange, true);
|
this.documentContainer.removeEventListener('pagechange', this.onPageChange, true);
|
||||||
this.documentContainer.removeEventListener('pagesloaded', this.onPagesLoaded, true);
|
this.documentContainer.removeEventListener('pagesloaded', this.onPagesLoaded, true);
|
||||||
|
this.documentContainer.removeEventListener('textlayerrendered', this.onPagerendered, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.loadingTask) {
|
||||||
|
this.loadingTask.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -373,6 +397,13 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
|
|||||||
this.displayPage = event.pageNumber;
|
this.displayPage = event.pageNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Page Rendered Event
|
||||||
|
*/
|
||||||
|
onPagerendered() {
|
||||||
|
this.rendered.emit();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pages Loaded Event
|
* Pages Loaded Event
|
||||||
*
|
*
|
||||||
|
@ -24,8 +24,6 @@ import {
|
|||||||
} from '../../services';
|
} from '../../services';
|
||||||
import { TxtViewerComponent } from './txtViewer.component';
|
import { TxtViewerComponent } from './txtViewer.component';
|
||||||
|
|
||||||
declare var require: any;
|
|
||||||
|
|
||||||
describe('Text View component', () => {
|
describe('Text View component', () => {
|
||||||
|
|
||||||
let component: TxtViewerComponent;
|
let component: TxtViewerComponent;
|
||||||
@ -54,7 +52,7 @@ describe('Text View component', () => {
|
|||||||
|
|
||||||
it('Should text container be present with urlfile', (done) => {
|
it('Should text container be present with urlfile', (done) => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
let urlFile = require('../assets/fake-test-file.txt');
|
let urlFile = './fake-test-file.txt';
|
||||||
let change = new SimpleChange(null, urlFile, true);
|
let change = new SimpleChange(null, urlFile, true);
|
||||||
|
|
||||||
component.ngOnChanges({ 'urlFile': change }).then(() => {
|
component.ngOnChanges({ 'urlFile': change }).then(() => {
|
||||||
|
@ -127,8 +127,6 @@ class ViewerWithCustomOpenWithComponent {}
|
|||||||
})
|
})
|
||||||
class ViewerWithCustomMoreActionsComponent {}
|
class ViewerWithCustomMoreActionsComponent {}
|
||||||
|
|
||||||
declare var require: any;
|
|
||||||
|
|
||||||
describe('ViewerComponent', () => {
|
describe('ViewerComponent', () => {
|
||||||
|
|
||||||
let component: ViewerComponent;
|
let component: ViewerComponent;
|
||||||
@ -593,7 +591,7 @@ describe('ViewerComponent', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
it('should extension file txt be loaded', async(() => {
|
it('should extension file txt be loaded', async(() => {
|
||||||
component.urlFile = require('../assets/fake-test-file.txt');
|
component.urlFile = 'fake-test-file.txt';
|
||||||
component.ngOnChanges(null);
|
component.ngOnChanges(null);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
@ -678,18 +676,18 @@ describe('ViewerComponent', () => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should display the txt viewer if the file identified by mimetype is a txt when the filename has wrong extension', async(() => {
|
it('should display the txt viewer if the file identified by mimetype is a txt when the filename has wrong extension', (done) => {
|
||||||
component.urlFile = 'content.bin';
|
component.urlFile = 'content.bin';
|
||||||
component.mimeType = 'text/plain';
|
component.mimeType = 'text/plain';
|
||||||
component.urlFile = require('../assets/fake-test-file.txt');
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
component.ngOnChanges(null);
|
component.ngOnChanges(null);
|
||||||
|
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(element.querySelector('adf-txt-viewer')).not.toBeNull();
|
expect(element.querySelector('adf-txt-viewer')).not.toBeNull();
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
}));
|
});
|
||||||
|
|
||||||
it('should display the media player if the file identified by mimetype is a media when the filename has no extension', async(() => {
|
it('should display the media player if the file identified by mimetype is a media when the filename has no extension', async(() => {
|
||||||
component.urlFile = 'content';
|
component.urlFile = 'content';
|
||||||
|
@ -57,6 +57,30 @@ export class FilterParamsModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class FilterParamRepresentationModel {
|
||||||
|
processDefinitionId: string;
|
||||||
|
processDefinitionKey: string;
|
||||||
|
name: string;
|
||||||
|
state: string;
|
||||||
|
sort: string;
|
||||||
|
assignment: string;
|
||||||
|
dueAfter: Date;
|
||||||
|
dueBefore: Date;
|
||||||
|
|
||||||
|
constructor(obj?: any) {
|
||||||
|
if (obj) {
|
||||||
|
this.processDefinitionId = obj.processDefinitionId || null;
|
||||||
|
this.processDefinitionKey = obj.processDefinitionKey || null;
|
||||||
|
this.name = obj.name || null;
|
||||||
|
this.state = obj.state || null;
|
||||||
|
this.sort = obj.sort || null;
|
||||||
|
this.assignment = obj.assignment || null;
|
||||||
|
this.dueAfter = obj.dueAfter || null;
|
||||||
|
this.dueBefore = obj.dueBefore || null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export class FilterRepresentationModel implements UserTaskFilterRepresentation {
|
export class FilterRepresentationModel implements UserTaskFilterRepresentation {
|
||||||
id: number;
|
id: number;
|
||||||
appId: number;
|
appId: number;
|
||||||
@ -83,30 +107,6 @@ export class FilterRepresentationModel implements UserTaskFilterRepresentation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class FilterParamRepresentationModel {
|
|
||||||
processDefinitionId: string;
|
|
||||||
processDefinitionKey: string;
|
|
||||||
name: string;
|
|
||||||
state: string;
|
|
||||||
sort: string;
|
|
||||||
assignment: string;
|
|
||||||
dueAfter: Date;
|
|
||||||
dueBefore: Date;
|
|
||||||
|
|
||||||
constructor(obj?: any) {
|
|
||||||
if (obj) {
|
|
||||||
this.processDefinitionId = obj.processDefinitionId || null;
|
|
||||||
this.processDefinitionKey = obj.processDefinitionKey || null;
|
|
||||||
this.name = obj.name || null;
|
|
||||||
this.state = obj.state || null;
|
|
||||||
this.sort = obj.sort || null;
|
|
||||||
this.assignment = obj.assignment || null;
|
|
||||||
this.dueAfter = obj.dueAfter || null;
|
|
||||||
this.dueBefore = obj.dueBefore || null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class TaskQueryRequestRepresentationModel implements TaskQueryRequestRepresentation {
|
export class TaskQueryRequestRepresentationModel implements TaskQueryRequestRepresentation {
|
||||||
appDefinitionId: string;
|
appDefinitionId: string;
|
||||||
processInstanceId: string;
|
processInstanceId: string;
|
||||||
|
@ -52,6 +52,7 @@ All the commands before can be used in combination
|
|||||||
| -u or --update | run the update of the node_modules packages on the demo shell |
|
| -u or --update | run the update of the node_modules packages on the demo shell |
|
||||||
| -c or --clean | clean the demo shell folder before starting it |
|
| -c or --clean | clean the demo shell folder before starting it |
|
||||||
| -t or --test | run the tests on the demo-shell |
|
| -t or --test | run the tests on the demo-shell |
|
||||||
|
| --e2e | execute e2e test |
|
||||||
| -r or --registry | Start the demo using an alternative npm registry |
|
| -r or --registry | Start the demo using an alternative npm registry |
|
||||||
| -v or --version | Use the version defined in the pacakge.json . Download from npm and Install a different version of the lib (this option is not compatible with -dev) |
|
| -v or --version | Use the version defined in the pacakge.json . Download from npm and Install a different version of the lib (this option is not compatible with -dev) |
|
||||||
| -si or --skipinstall | skip the install of the node_modules |
|
| -si or --skipinstall | skip the install of the node_modules |
|
||||||
|
@ -12,6 +12,7 @@ eval EXEC_GIT_NPM_INSTALL_JSAPI=false
|
|||||||
eval EXEC_VERSION_JSAPI=false
|
eval EXEC_VERSION_JSAPI=false
|
||||||
eval EXEC_START=true
|
eval EXEC_START=true
|
||||||
eval EXEC_TEST=false
|
eval EXEC_TEST=false
|
||||||
|
eval EXEC_E2E=false
|
||||||
eval JSAPI_VERSION=""
|
eval JSAPI_VERSION=""
|
||||||
eval NG2_COMPONENTS_VERSION=""
|
eval NG2_COMPONENTS_VERSION=""
|
||||||
eval GIT_ISH=""
|
eval GIT_ISH=""
|
||||||
@ -28,6 +29,7 @@ show_help() {
|
|||||||
echo "-dev or -develop start the demo shell using the relative lib folder to link the components"
|
echo "-dev or -develop start the demo shell using the relative lib folder to link the components"
|
||||||
echo "-dist create the disbuild the demo shell in dist mode"
|
echo "-dist create the disbuild the demo shell in dist mode"
|
||||||
echo "-t or -test execute test"
|
echo "-t or -test execute test"
|
||||||
|
echo "--e2e execute e2e test"
|
||||||
echo "-u or -update start the demo shell and update the dependencies"
|
echo "-u or -update start the demo shell and update the dependencies"
|
||||||
echo "-c or -clean clean the demo shell and reinstall the dependencies"
|
echo "-c or -clean clean the demo shell and reinstall the dependencies"
|
||||||
echo "-r or -registry to download the packages from an alternative npm registry example -registry 'http://npm.local.me:8080/' "
|
echo "-r or -registry to download the packages from an alternative npm registry example -registry 'http://npm.local.me:8080/' "
|
||||||
@ -57,7 +59,11 @@ disable_start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enable_test() {
|
enable_test() {
|
||||||
EXEC_TEST=false
|
EXEC_TEST=true
|
||||||
|
}
|
||||||
|
|
||||||
|
enable_e2e() {
|
||||||
|
EXEC_E2E=true
|
||||||
}
|
}
|
||||||
|
|
||||||
enable_js_api_git_link() {
|
enable_js_api_git_link() {
|
||||||
@ -113,6 +119,7 @@ while [[ $1 == -* ]]; do
|
|||||||
-u|--update) update; shift;;
|
-u|--update) update; shift;;
|
||||||
-c|--clean) clean; shift;;
|
-c|--clean) clean; shift;;
|
||||||
-t|--test) enable_test; shift;;
|
-t|--test) enable_test; shift;;
|
||||||
|
--e2e) enable_e2e; shift;;
|
||||||
-r|--registry) change_registry $2; shift 2;;
|
-r|--registry) change_registry $2; shift 2;;
|
||||||
-v|--version) version_component $2; shift 2;;
|
-v|--version) version_component $2; shift 2;;
|
||||||
-si|--skipinstall) install; shift;;
|
-si|--skipinstall) install; shift;;
|
||||||
@ -186,8 +193,13 @@ if $EXEC_VERSION_JSAPI == true; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if $EXEC_TEST == true; then
|
if $EXEC_TEST == true; then
|
||||||
echo "====== Demo shell Test====="
|
echo "====== Demo shell Test ====="
|
||||||
npm run test
|
npm install && npm run test
|
||||||
|
fi
|
||||||
|
|
||||||
|
if $EXEC_E2E == true; then
|
||||||
|
echo "====== Demo shell e2e ====="
|
||||||
|
npm run e2e
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if $EXEC_START == true; then
|
if $EXEC_START == true; then
|
||||||
|
@ -126,7 +126,6 @@
|
|||||||
"no-string-literal": false,
|
"no-string-literal": false,
|
||||||
"no-string-throw": true,
|
"no-string-throw": true,
|
||||||
"prefer-const": false,
|
"prefer-const": false,
|
||||||
"typeof-compare": true,
|
|
||||||
"unified-signatures": true,
|
"unified-signatures": true,
|
||||||
"whitespace": [
|
"whitespace": [
|
||||||
true,
|
true,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user