mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
renditions service test improvements
This commit is contained in:
@@ -60,6 +60,7 @@
|
|||||||
"@angular/platform-browser-dynamic": "2.0.0",
|
"@angular/platform-browser-dynamic": "2.0.0",
|
||||||
"@angular/router": "3.0.0",
|
"@angular/router": "3.0.0",
|
||||||
"@angular/upgrade": "2.0.0",
|
"@angular/upgrade": "2.0.0",
|
||||||
|
"@types/node": "^6.0.42",
|
||||||
"core-js": "^2.4.1",
|
"core-js": "^2.4.1",
|
||||||
"reflect-metadata": "^0.1.3",
|
"reflect-metadata": "^0.1.3",
|
||||||
"rxjs": "5.0.0-beta.12",
|
"rxjs": "5.0.0-beta.12",
|
||||||
|
@@ -27,7 +27,8 @@ import {
|
|||||||
AlfrescoTranslationLoader,
|
AlfrescoTranslationLoader,
|
||||||
AlfrescoTranslationService,
|
AlfrescoTranslationService,
|
||||||
AlfrescoAuthenticationService,
|
AlfrescoAuthenticationService,
|
||||||
AlfrescoContentService
|
AlfrescoContentService,
|
||||||
|
RenditionsService
|
||||||
} from './src/services/index';
|
} from './src/services/index';
|
||||||
|
|
||||||
import { MATERIAL_DESIGN_DIRECTIVES } from './src/components/material/index';
|
import { MATERIAL_DESIGN_DIRECTIVES } from './src/components/material/index';
|
||||||
@@ -44,6 +45,7 @@ export const ALFRESCO_CORE_PROVIDERS: any[] = [
|
|||||||
AlfrescoSettingsService,
|
AlfrescoSettingsService,
|
||||||
AlfrescoTranslationLoader,
|
AlfrescoTranslationLoader,
|
||||||
AlfrescoTranslationService,
|
AlfrescoTranslationService,
|
||||||
|
RenditionsService,
|
||||||
...CONTEXT_MENU_PROVIDERS
|
...CONTEXT_MENU_PROVIDERS
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@@ -15,7 +15,6 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
export class AlfrescoApiMock {
|
export class AlfrescoApiMock {
|
||||||
|
|
||||||
login(username: string, password: string) {
|
login(username: string, password: string) {
|
||||||
|
@@ -0,0 +1,81 @@
|
|||||||
|
/*!
|
||||||
|
* @license
|
||||||
|
* Copyright 2016 Alfresco Software, Ltd.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
export var fakeRedition = {
|
||||||
|
'entry': {
|
||||||
|
'id': 'pdf',
|
||||||
|
'content': {'mimeType': 'application/pdf', 'mimeTypeName': 'Adobe PDF Document'},
|
||||||
|
'status': 'NOT_CREATED'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export var fakeReditionCreated = {
|
||||||
|
'entry': {
|
||||||
|
'id': 'pdf',
|
||||||
|
'content': {'mimeType': 'application/pdf', 'mimeTypeName': 'Adobe PDF Document'},
|
||||||
|
'status': 'CREATED'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export var fakeReditionsList = {
|
||||||
|
'list': {
|
||||||
|
'pagination': {
|
||||||
|
'count': 6,
|
||||||
|
'hasMoreItems': false,
|
||||||
|
'totalItems': 6,
|
||||||
|
'skipCount': 0,
|
||||||
|
'maxItems': 100
|
||||||
|
},
|
||||||
|
'entries': [{
|
||||||
|
'entry': {
|
||||||
|
'id': 'avatar',
|
||||||
|
'content': {'mimeType': 'image/png', 'mimeTypeName': 'PNG Image'},
|
||||||
|
'status': 'NOT_CREATED'
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
'entry': {
|
||||||
|
'id': 'avatar32',
|
||||||
|
'content': {'mimeType': 'image/png', 'mimeTypeName': 'PNG Image'},
|
||||||
|
'status': 'NOT_CREATED'
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
'entry': {
|
||||||
|
'id': 'doclib',
|
||||||
|
'content': {'mimeType': 'image/png', 'mimeTypeName': 'PNG Image'},
|
||||||
|
'status': 'NOT_CREATED'
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
'entry': {
|
||||||
|
'id': 'imgpreview',
|
||||||
|
'content': {'mimeType': 'image/jpeg', 'mimeTypeName': 'JPEG Image'},
|
||||||
|
'status': 'NOT_CREATED'
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
'entry': {
|
||||||
|
'id': 'medium',
|
||||||
|
'content': {'mimeType': 'image/jpeg', 'mimeTypeName': 'JPEG Image'},
|
||||||
|
'status': 'NOT_CREATED'
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
'entry': {
|
||||||
|
'id': 'pdf',
|
||||||
|
'content': {'mimeType': 'application/pdf', 'mimeTypeName': 'Adobe PDF Document'},
|
||||||
|
'status': 'NOT_CREATED'
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
};
|
@@ -46,6 +46,4 @@ describe('AlfrescoSettingsService', () => {
|
|||||||
service.bpmHost = address;
|
service.bpmHost = address;
|
||||||
expect(service.bpmHost).toBe(address);
|
expect(service.bpmHost).toBe(address);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@@ -18,6 +18,11 @@
|
|||||||
import { ReflectiveInjector } from '@angular/core';
|
import { ReflectiveInjector } from '@angular/core';
|
||||||
import { AlfrescoApiService } from './AlfrescoApi.service';
|
import { AlfrescoApiService } from './AlfrescoApi.service';
|
||||||
import { RenditionsService } from './renditions.service';
|
import { RenditionsService } from './renditions.service';
|
||||||
|
import {
|
||||||
|
fakeRedition,
|
||||||
|
fakeReditionCreated,
|
||||||
|
fakeReditionsList
|
||||||
|
} from '../assets/renditionsService.mock';
|
||||||
|
|
||||||
declare let jasmine: any;
|
declare let jasmine: any;
|
||||||
declare let AlfrescoApi: any;
|
declare let AlfrescoApi: any;
|
||||||
@@ -25,62 +30,6 @@ declare let AlfrescoApi: any;
|
|||||||
describe('RenditionsService', () => {
|
describe('RenditionsService', () => {
|
||||||
let service, injector;
|
let service, injector;
|
||||||
|
|
||||||
let fakeRedition = {
|
|
||||||
'entry': {
|
|
||||||
'id': 'pdf',
|
|
||||||
'content': {'mimeType': 'application/pdf', 'mimeTypeName': 'Adobe PDF Document'},
|
|
||||||
'status': 'NOT_CREATED'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let fakeReditionsList = {
|
|
||||||
'list': {
|
|
||||||
'pagination': {
|
|
||||||
'count': 6,
|
|
||||||
'hasMoreItems': false,
|
|
||||||
'totalItems': 6,
|
|
||||||
'skipCount': 0,
|
|
||||||
'maxItems': 100
|
|
||||||
},
|
|
||||||
'entries': [{
|
|
||||||
'entry': {
|
|
||||||
'id': 'avatar',
|
|
||||||
'content': {'mimeType': 'image/png', 'mimeTypeName': 'PNG Image'},
|
|
||||||
'status': 'NOT_CREATED'
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
'entry': {
|
|
||||||
'id': 'avatar32',
|
|
||||||
'content': {'mimeType': 'image/png', 'mimeTypeName': 'PNG Image'},
|
|
||||||
'status': 'NOT_CREATED'
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
'entry': {
|
|
||||||
'id': 'doclib',
|
|
||||||
'content': {'mimeType': 'image/png', 'mimeTypeName': 'PNG Image'},
|
|
||||||
'status': 'NOT_CREATED'
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
'entry': {
|
|
||||||
'id': 'imgpreview',
|
|
||||||
'content': {'mimeType': 'image/jpeg', 'mimeTypeName': 'JPEG Image'},
|
|
||||||
'status': 'NOT_CREATED'
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
'entry': {
|
|
||||||
'id': 'medium',
|
|
||||||
'content': {'mimeType': 'image/jpeg', 'mimeTypeName': 'JPEG Image'},
|
|
||||||
'status': 'NOT_CREATED'
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
'entry': {
|
|
||||||
'id': 'pdf',
|
|
||||||
'content': {'mimeType': 'application/pdf', 'mimeTypeName': 'Adobe PDF Document'},
|
|
||||||
'status': 'NOT_CREATED'
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
};
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
injector = ReflectiveInjector.resolveAndCreate([
|
injector = ReflectiveInjector.resolveAndCreate([
|
||||||
AlfrescoApiService,
|
AlfrescoApiService,
|
||||||
@@ -98,9 +47,9 @@ describe('RenditionsService', () => {
|
|||||||
jasmine.Ajax.uninstall();
|
jasmine.Ajax.uninstall();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Get redition list service should call the server with the ID passed', (done) => {
|
it('Get redition list service should return the list', (done) => {
|
||||||
service.getRenditionsListByNodeId('fake-node-id').subscribe((res) => {
|
service.getRenditionsListByNodeId('fake-node-id').subscribe((res) => {
|
||||||
expect(jasmine.Ajax.requests.mostRecent().url).toBe('http://127.0.0.1:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/renditions');
|
expect(res.list.entries[0].entry.id).toBe('avatar');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -111,34 +60,6 @@ describe('RenditionsService', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Get redition service should call the server with the ID passed', (done) => {
|
|
||||||
service.getRendition('fake-node-id', 'pdf').subscribe((res) => {
|
|
||||||
expect(jasmine.Ajax.requests.mostRecent().url).toBe('http://127.0.0.1:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/renditions/pdf');
|
|
||||||
expect(res.entry.status).toBe('NOT_CREATED');
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
|
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
|
||||||
'status': 200,
|
|
||||||
contentType: 'application/json',
|
|
||||||
responseText: JSON.stringify(fakeRedition)
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('isRenditionsAvailable service should call the server with the ID passed and return false if is not created', (done) => {
|
|
||||||
service.isRenditionAvailable('fake-node-id', 'pdf').subscribe((res) => {
|
|
||||||
expect(jasmine.Ajax.requests.mostRecent().url).toBe('http://127.0.0.1:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/renditions/pdf');
|
|
||||||
expect(res).toBe(false);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
|
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
|
||||||
'status': 200,
|
|
||||||
contentType: 'application/json',
|
|
||||||
responseText: JSON.stringify(fakeRedition)
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Create redition service should call the server with the ID passed and the asked encoding', (done) => {
|
it('Create redition service should call the server with the ID passed and the asked encoding', (done) => {
|
||||||
service.createRendition('fake-node-id', 'pdf').subscribe((res) => {
|
service.createRendition('fake-node-id', 'pdf').subscribe((res) => {
|
||||||
expect(jasmine.Ajax.requests.mostRecent().url).toBe('http://127.0.0.1:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/renditions');
|
expect(jasmine.Ajax.requests.mostRecent().url).toBe('http://127.0.0.1:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/renditions');
|
||||||
@@ -165,5 +86,67 @@ describe('RenditionsService', () => {
|
|||||||
responseText: 'error'
|
responseText: 'error'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('isConversionPossible should return true if is possible convert', (done) => {
|
||||||
|
service.isConversionPossible('fake-node-id', 'pdf').subscribe((res) => {
|
||||||
|
expect(res).toBe(true);
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
|
'status': 200,
|
||||||
|
contentType: 'application/json',
|
||||||
|
responseText: JSON.stringify(fakeRedition)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('isConversionPossible should return false if is not possible to convert', (done) => {
|
||||||
|
service.isConversionPossible('fake-node-id', 'pdf').subscribe((res) => {
|
||||||
|
expect(res).toBe(false);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
|
'status': 403,
|
||||||
|
contentType: 'application/json'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('isRenditionsAvailable should return true if the conversion exist', (done) => {
|
||||||
|
service.isRenditionAvailable('fake-node-id', 'pdf').subscribe((res) => {
|
||||||
|
expect(res).toBe(true);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
|
'status': 200,
|
||||||
|
contentType: 'application/json',
|
||||||
|
responseText: JSON.stringify(fakeReditionCreated)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('isRenditionsAvailable should return false if the conversion not exist', (done) => {
|
||||||
|
service.isRenditionAvailable('fake-node-id', 'pdf').subscribe((res) => {
|
||||||
|
expect(res).toBe(false);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
|
'status': 200,
|
||||||
|
contentType: 'application/json',
|
||||||
|
responseText: JSON.stringify(fakeRedition)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('isRenditionsAvailable should return false if the conversion get error', (done) => {
|
||||||
|
service.isRenditionAvailable('fake-node-id', 'pdf').subscribe((res) => {
|
||||||
|
expect(res).toBe(false);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
|
'status': 400,
|
||||||
|
contentType: 'application/json'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
@@ -40,6 +40,21 @@ export class RenditionsService {
|
|||||||
}
|
}
|
||||||
observer.next(isAvailable);
|
observer.next(isAvailable);
|
||||||
observer.complete();
|
observer.complete();
|
||||||
|
}, () => {
|
||||||
|
observer.next(false);
|
||||||
|
observer.complete();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
isConversionPossible(nodeId: string, encoding: string) {
|
||||||
|
return Observable.create((observer) => {
|
||||||
|
this.getRendition(nodeId, encoding).subscribe(() => {
|
||||||
|
observer.next(true);
|
||||||
|
observer.complete();
|
||||||
|
}, () => {
|
||||||
|
observer.next(false);
|
||||||
|
observer.complete();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -55,7 +70,7 @@ export class RenditionsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createRendition(nodeId: string, encoding: string) {
|
createRendition(nodeId: string, encoding: string) {
|
||||||
return Observable.fromPromise(this.apiService.getInstance().core.renditionsApi.createRendition(nodeId, {id: 'pdf'}))
|
return Observable.fromPromise(this.apiService.getInstance().core.renditionsApi.createRendition(nodeId, {id: encoding}))
|
||||||
.catch(this.handleError);
|
.catch(this.handleError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -35,7 +35,7 @@
|
|||||||
"no-arg": true,
|
"no-arg": true,
|
||||||
"no-bitwise": false,
|
"no-bitwise": false,
|
||||||
"no-conditional-assignment": true,
|
"no-conditional-assignment": true,
|
||||||
"no-consecutive-blank-lines": false,
|
"no-consecutive-blank-lines": true,
|
||||||
"no-console": [
|
"no-console": [
|
||||||
true,
|
true,
|
||||||
"debug",
|
"debug",
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
"typings": "./dist/index.d.ts",
|
"typings": "./dist/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"clean": "rimraf dist node_modules",
|
"clean": "npm install rimraf && rimraf dist node_modules typings",
|
||||||
"build": "npm run tslint && rimraf dist && tsc && npm run copy-dist && license-check",
|
"build": "npm run tslint && rimraf dist && tsc && npm run copy-dist && license-check",
|
||||||
"build:w": "npm run tslint && rimraf dist && npm run watch-task",
|
"build:w": "npm run tslint && rimraf dist && npm run watch-task",
|
||||||
"watch-task": "concurrently \"npm run tsc:w\" \"npm run copy-dist:w\" \"license-check\"",
|
"watch-task": "concurrently \"npm run tsc:w\" \"npm run copy-dist:w\" \"license-check\"",
|
||||||
|
@@ -4,19 +4,19 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|||||||
|
|
||||||
for PACKAGE in \
|
for PACKAGE in \
|
||||||
ng2-activiti-analytics \
|
ng2-activiti-analytics \
|
||||||
ng2-activiti-form \
|
|
||||||
ng2-activiti-processlist \
|
|
||||||
ng2-activiti-tasklist \
|
|
||||||
ng2-alfresco-core \
|
ng2-alfresco-core \
|
||||||
ng2-alfresco-datatable \
|
ng2-alfresco-datatable \
|
||||||
ng2-alfresco-documentlist \
|
ng2-alfresco-documentlist \
|
||||||
|
ng2-activiti-form \
|
||||||
ng2-alfresco-login \
|
ng2-alfresco-login \
|
||||||
|
ng2-activiti-processlist \
|
||||||
ng2-alfresco-search \
|
ng2-alfresco-search \
|
||||||
|
ng2-activiti-tasklist \
|
||||||
ng2-alfresco-tag \
|
ng2-alfresco-tag \
|
||||||
ng2-alfresco-upload \
|
ng2-alfresco-upload \
|
||||||
|
ng2-alfresco-userinfo \
|
||||||
ng2-alfresco-viewer \
|
ng2-alfresco-viewer \
|
||||||
ng2-alfresco-webscript \
|
ng2-alfresco-webscript
|
||||||
ng2-alfresco-userinfo
|
|
||||||
do
|
do
|
||||||
echo "====== clean component: ${PACKAGE} ====="
|
echo "====== clean component: ${PACKAGE} ====="
|
||||||
cd "$DIR/../ng2-components/${PACKAGE}"
|
cd "$DIR/../ng2-components/${PACKAGE}"
|
||||||
|
@@ -56,27 +56,15 @@ npm link ng2-activiti-tasklist
|
|||||||
npm link
|
npm link
|
||||||
npm run build
|
npm run build
|
||||||
|
|
||||||
#LINK VIEWER
|
|
||||||
echo "====== linking component: ng2-alfresco-viewer ====="
|
|
||||||
cd "$DIR/../ng2-components/ng2-alfresco-viewer"
|
|
||||||
npm link ng2-alfresco-core
|
|
||||||
npm link
|
|
||||||
npm run build
|
|
||||||
|
|
||||||
#LINK TAG
|
|
||||||
echo "====== linking component: ng2-alfresco-tag ====="
|
|
||||||
cd "$DIR/../ng2-components/ng2-alfresco-tag"
|
|
||||||
npm link ng2-alfresco-core
|
|
||||||
npm link
|
|
||||||
npm run build
|
|
||||||
|
|
||||||
#LINK ALL THE OTHERS COMPONENTS
|
#LINK ALL THE OTHERS COMPONENTS
|
||||||
for PACKAGE in \
|
for PACKAGE in \
|
||||||
|
ng2-activiti-analytics \
|
||||||
ng2-alfresco-login \
|
ng2-alfresco-login \
|
||||||
ng2-alfresco-search \
|
ng2-alfresco-search \
|
||||||
|
ng2-alfresco-userinfo \
|
||||||
ng2-alfresco-upload \
|
ng2-alfresco-upload \
|
||||||
ng2-activiti-analytics \
|
ng2-alfresco-tag \
|
||||||
ng2-alfresco-userinfo
|
ng2-alfresco-viewer
|
||||||
do
|
do
|
||||||
DESTDIR="$DIR/../ng2-components/${PACKAGE}"
|
DESTDIR="$DIR/../ng2-components/${PACKAGE}"
|
||||||
echo "====== linking component: ${PACKAGE} ====="
|
echo "====== linking component: ${PACKAGE} ====="
|
||||||
|
Reference in New Issue
Block a user