mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
[ADF-3918] Fix translation issue (#4169)
This commit is contained in:
parent
9a70852985
commit
348bee9c6f
.travis.ymlprotractor.conf.js
demo-shell/src
e2e
content-services/document-list
core/viewer
pages/adf
resources/adf/allFileTypes
util
lib
core
app-config
datatable/data
mock
pagination
services
process-services-cloud/src/lib/process-list-cloud
@ -8,6 +8,9 @@ node_js:
|
||||
# Use the explicit NodeJS LTS version 8.9.4 to avoid any automatic upgrade of the version.
|
||||
- '8.9.4'
|
||||
|
||||
install:
|
||||
echo "no install"
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
|
@ -8,6 +8,7 @@
|
||||
"providers": "ALL",
|
||||
"contextRootBpm": "activiti-app",
|
||||
"authType" : "BASIC",
|
||||
"locale" : "en",
|
||||
"oauth2": {
|
||||
"host": "{protocol}//{hostname}{:port}/auth/realms/alfresco",
|
||||
"clientId": "alfresco",
|
||||
|
@ -112,7 +112,7 @@ describe('Document List Component', () => {
|
||||
it('[C279925] Should display translated message when accessing a file without permissions if language is changed', () => {
|
||||
loginPage.loginToContentServicesUsingUserModel(acsUser);
|
||||
navBar.openLanguageMenu();
|
||||
navBar.chooseLanguage('Italian');
|
||||
navBar.chooseLanguage('Italiano');
|
||||
browser.sleep(2000);
|
||||
browser.get(TestConfig.adf.url + '/files/' + privateSite.entry.guid);
|
||||
expect(errorPage.getErrorDescription()).toBe('Accesso alla risorsa sul server non consentito.');
|
||||
|
@ -24,9 +24,9 @@ import { ContentServicesPage } from '../../pages/adf/contentServicesPage';
|
||||
import { ContentListPage } from '../../pages/adf/dialog/contentListPage';
|
||||
import { ShareDialog } from '../../pages/adf/dialog/shareDialog';
|
||||
|
||||
import CONSTANTS = require('../../util/constants');
|
||||
import resources = require('../../util/resources');
|
||||
import { Util } from '../../util/util';
|
||||
import CONSTANTS = require('../../util/constants');
|
||||
|
||||
import { FileModel } from '../../models/ACS/fileModel';
|
||||
import { FolderModel } from '../../models/ACS/folderModel';
|
||||
@ -89,6 +89,11 @@ describe('Viewer', () => {
|
||||
'location': resources.Files.ADF_DOCUMENTS.IMG_FOLDER.folder_location
|
||||
});
|
||||
|
||||
let imgRenditionFolderInfo = new FolderModel({
|
||||
'name': resources.Files.ADF_DOCUMENTS.IMG_RENDITION_FOLDER.folder_name,
|
||||
'location': resources.Files.ADF_DOCUMENTS.IMG_RENDITION_FOLDER.folder_location
|
||||
});
|
||||
|
||||
beforeAll(async (done) => {
|
||||
|
||||
this.alfrescoJsApi = new AlfrescoApi({
|
||||
@ -340,14 +345,18 @@ describe('Viewer', () => {
|
||||
|
||||
describe('Image Folder Uploaded', () => {
|
||||
|
||||
let uploadedImages;
|
||||
let imgFolderUploaded;
|
||||
let uploadedImages, uploadedImgRenditionFolderInfo;
|
||||
let imgFolderUploaded, imgFolderRenditionUploaded;
|
||||
|
||||
beforeAll(async (done) => {
|
||||
imgFolderUploaded = await uploadActions.createFolder(this.alfrescoJsApi, imgFolderInfo.name, '-my-');
|
||||
|
||||
uploadedImages = await uploadActions.uploadFolder(this.alfrescoJsApi, imgFolderInfo.location, imgFolderUploaded.entry.id);
|
||||
|
||||
imgFolderRenditionUploaded = await uploadActions.createFolder(this.alfrescoJsApi, imgRenditionFolderInfo.name, imgFolderUploaded.entry.id);
|
||||
|
||||
uploadedImgRenditionFolderInfo = await uploadActions.uploadFolder(this.alfrescoJsApi, imgRenditionFolderInfo.location, imgFolderRenditionUploaded.entry.id);
|
||||
|
||||
loginPage.loginToContentServicesUsingUserModel(acsUser);
|
||||
contentServicesPage.goToDocumentList();
|
||||
|
||||
@ -363,6 +372,16 @@ describe('Viewer', () => {
|
||||
contentServicesPage.navigateToFolder('images');
|
||||
|
||||
uploadedImages.forEach((currentFile) => {
|
||||
if (currentFile.entry.name !== '.DS_Store') {
|
||||
contentServicesPage.doubleClickRow(currentFile.entry.name);
|
||||
viewerPage.checkImgViewerIsDisplayed();
|
||||
viewerPage.clickCloseButton();
|
||||
}
|
||||
});
|
||||
|
||||
contentServicesPage.navigateToFolder('images-rendition');
|
||||
|
||||
uploadedImgRenditionFolderInfo.forEach((currentFile) => {
|
||||
if (currentFile.entry.name !== '.DS_Store') {
|
||||
contentServicesPage.doubleClickRow(currentFile.entry.name);
|
||||
viewerPage.checkFileIsLoaded();
|
||||
@ -387,7 +406,7 @@ describe('Viewer', () => {
|
||||
|
||||
wordFileUploaded = await uploadActions.uploadFile(this.alfrescoJsApi, wordFileInfo.location, wordFileInfo.name, '-my-');
|
||||
|
||||
pngFileShared = await this.alfrescoJsApi.core.sharedlinksApi.addSharedLink({'nodeId': pngFileUploaded.entry.id});
|
||||
pngFileShared = await this.alfrescoJsApi.core.sharedlinksApi.addSharedLink({ 'nodeId': pngFileUploaded.entry.id });
|
||||
|
||||
done();
|
||||
});
|
||||
|
@ -352,8 +352,8 @@ export class ContentServicesPage {
|
||||
return this;
|
||||
}
|
||||
|
||||
doubleClickRow(folder) {
|
||||
this.contentList.doubleClickRow(folder);
|
||||
doubleClickRow(nodeName) {
|
||||
this.contentList.doubleClickRow(nodeName);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
Binary file not shown.
@ -489,6 +489,10 @@ exports.Files = {
|
||||
IMG_FOLDER: {
|
||||
folder_location: "/resources/adf/allFileTypes/images",
|
||||
folder_name: "images"
|
||||
},
|
||||
IMG_RENDITION_FOLDER: {
|
||||
folder_location: "/resources/adf/allFileTypes/images-rendition",
|
||||
folder_name: "images-rendition"
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -34,7 +34,9 @@ describe('AppConfigService', () => {
|
||||
},
|
||||
files: {
|
||||
'excluded': ['excluded']
|
||||
}
|
||||
},
|
||||
logLevel: 'silent',
|
||||
alfrescoRepositoryName: 'alfresco-1'
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
@ -127,6 +129,7 @@ describe('AppConfigService', () => {
|
||||
|
||||
it('should load external settings', () => {
|
||||
appConfigService.load().then((config) => {
|
||||
|
||||
expect(config).toEqual(mockResponse);
|
||||
});
|
||||
});
|
||||
|
@ -38,6 +38,13 @@ export enum AppConfigValues {
|
||||
LOGIN_ROUTE = 'loginRoute',
|
||||
DISABLECSRF = 'disableCSRF'
|
||||
}
|
||||
|
||||
export enum Status {
|
||||
INIT = 'init',
|
||||
LOADING = 'loading',
|
||||
LOADED = 'loaded'
|
||||
}
|
||||
|
||||
/* spellchecker: enable */
|
||||
|
||||
@Injectable({
|
||||
@ -55,7 +62,8 @@ export class AppConfigService {
|
||||
alfrescoRepositoryName: 'alfresco-1'
|
||||
};
|
||||
|
||||
private onLoadSubject: Subject<any>;
|
||||
status: Status = Status.INIT;
|
||||
protected onLoadSubject: Subject<any>;
|
||||
onLoad: Observable<any>;
|
||||
|
||||
constructor(private http: HttpClient) {
|
||||
@ -128,19 +136,29 @@ export class AppConfigService {
|
||||
* @returns Notification when loading is complete
|
||||
*/
|
||||
load(): Promise<any> {
|
||||
return new Promise((resolve) => {
|
||||
return new Promise(async (resolve) => {
|
||||
const configUrl = `app.config.json?v=${Date.now()}`;
|
||||
|
||||
this.http.get(configUrl).subscribe(
|
||||
(data: any) => {
|
||||
this.config = Object.assign({}, this.config, data || {});
|
||||
this.onLoadSubject.next(this.config);
|
||||
if (this.status === Status.INIT) {
|
||||
this.status = Status.LOADING;
|
||||
await this.http.get(configUrl).subscribe(
|
||||
(data: any) => {
|
||||
this.status = Status.LOADED;
|
||||
this.config = Object.assign({}, this.config, data || {});
|
||||
this.onLoadSubject.next(this.config);
|
||||
resolve(this.config);
|
||||
},
|
||||
() => {
|
||||
resolve(this.config);
|
||||
}
|
||||
);
|
||||
} else if (this.status === Status.LOADED) {
|
||||
resolve(this.config);
|
||||
} else if (this.status === Status.LOADING) {
|
||||
this.onLoad.subscribe(() => {
|
||||
resolve(this.config);
|
||||
},
|
||||
() => {
|
||||
resolve(this.config);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -54,8 +54,7 @@ export abstract class DataTableSchema {
|
||||
}
|
||||
|
||||
public mergeJsonAndHtmlSchema(): any {
|
||||
let customSchemaColumns = [];
|
||||
customSchemaColumns = this.getSchemaFromConfig(this.presetColumn).concat(this.getSchemaFromHtml(this.columnList));
|
||||
let customSchemaColumns = this.getSchemaFromConfig(this.presetColumn).concat(this.getSchemaFromHtml(this.columnList));
|
||||
if (customSchemaColumns.length === 0) {
|
||||
customSchemaColumns = this.getDefaultLayoutPreset();
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ export class AppConfigServiceMock extends AppConfigService {
|
||||
|
||||
load(): Promise<any> {
|
||||
return new Promise((resolve) => {
|
||||
this.onLoadSubject.next(this.config);
|
||||
resolve(this.config);
|
||||
});
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
<div *ngIf="pagination?.hasMoreItems || isLoading" class="adf-infinite-pagination">
|
||||
isLoading : {{isLoading}}
|
||||
<button mat-button
|
||||
*ngIf="!isLoading"
|
||||
class="adf-infinite-pagination-load-more"
|
||||
|
@ -27,7 +27,7 @@ import { PaginatedComponent } from './paginated-component.interface';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { PaginationComponentInterface } from './pagination-component.interface';
|
||||
import { PaginationModel } from '../models/pagination.model';
|
||||
import { UserPreferencesService } from '../services/user-preferences.service';
|
||||
import { UserPreferencesService, UserPreferenceValues } from '../services/user-preferences.service';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-infinite-pagination',
|
||||
@ -73,11 +73,14 @@ export class InfinitePaginationComponent implements OnInit, OnDestroy, Paginatio
|
||||
this.paginationSubscription = this.target.pagination.subscribe((pagination) => {
|
||||
this.isLoading = false;
|
||||
this.pagination = pagination;
|
||||
this.pageSize = this.pageSize || this.userPreferencesService.paginationSize;
|
||||
this.cdr.detectChanges();
|
||||
});
|
||||
}
|
||||
|
||||
this.userPreferencesService.select(UserPreferenceValues.PaginationSize).subscribe((pagSize) => {
|
||||
this.pageSize = this.pageSize || pagSize;
|
||||
});
|
||||
|
||||
if (!this.pagination) {
|
||||
this.pagination = InfinitePaginationComponent.DEFAULT_PAGINATION;
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ export class PaginationComponent implements OnInit, OnDestroy, PaginationCompone
|
||||
}
|
||||
|
||||
if (!this.supportedPageSizes) {
|
||||
this.supportedPageSizes = this.userPreferencesService.getDefaultPageSizes();
|
||||
this.supportedPageSizes = this.userPreferencesService.supportedPageSizes;
|
||||
}
|
||||
|
||||
if (this.target) {
|
||||
|
@ -23,7 +23,7 @@ import {
|
||||
SearchApi,
|
||||
Node
|
||||
} from '@alfresco/js-api';
|
||||
import { AlfrescoApiCompatibility } from '@alfresco/js-api';
|
||||
import { AlfrescoApiCompatibility, AlfrescoApiConfig } from '@alfresco/js-api';
|
||||
import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
|
||||
import { StorageService } from './storage.service';
|
||||
import { Subject } from 'rxjs';
|
||||
@ -42,6 +42,8 @@ export class AlfrescoApiService {
|
||||
|
||||
protected alfrescoApi: AlfrescoApiCompatibility;
|
||||
|
||||
lastConfig: AlfrescoApiConfig;
|
||||
|
||||
getInstance(): AlfrescoApiCompatibility {
|
||||
return this.alfrescoApi;
|
||||
}
|
||||
@ -126,11 +128,16 @@ export class AlfrescoApiService {
|
||||
oauth2: oauth
|
||||
};
|
||||
|
||||
if (this.alfrescoApi) {
|
||||
if (this.alfrescoApi && this.isDifferentConfig(this.lastConfig, config)) {
|
||||
this.lastConfig = config;
|
||||
this.alfrescoApi.configureJsApi(config);
|
||||
} else {
|
||||
this.lastConfig = config;
|
||||
this.alfrescoApi = new AlfrescoApiCompatibility(config);
|
||||
}
|
||||
}
|
||||
|
||||
isDifferentConfig(lastConfig: AlfrescoApiConfig, newConfig: AlfrescoApiConfig) {
|
||||
return JSON.stringify(lastConfig) !== JSON.stringify(newConfig);
|
||||
}
|
||||
}
|
||||
|
@ -52,8 +52,11 @@ export class TranslationService {
|
||||
}
|
||||
|
||||
userPreferencesService.select(UserPreferenceValues.Locale).subscribe((locale) => {
|
||||
this.userLang = locale;
|
||||
this.use(this.userLang); });
|
||||
if (locale) {
|
||||
this.userLang = locale;
|
||||
this.use(this.userLang);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,22 +19,25 @@ import { TestBed } from '@angular/core/testing';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { AppConfigService } from '../app-config/app-config.service';
|
||||
import { StorageService } from './storage.service';
|
||||
import { UserPreferencesService } from './user-preferences.service';
|
||||
import { UserPreferencesService, UserPreferenceValues } from './user-preferences.service';
|
||||
import { setupTestBed } from '../testing/setupTestBed';
|
||||
import { CoreTestingModule } from '../testing/core.testing.module';
|
||||
import { AppConfigServiceMock } from '../mock/app-config.service.mock';
|
||||
|
||||
describe('UserPreferencesService', () => {
|
||||
|
||||
const defaultPaginationSize: number = 25;
|
||||
const supportedPaginationSize = [5, 10, 15, 20];
|
||||
let preferences: UserPreferencesService;
|
||||
let storage: StorageService;
|
||||
let appConfig: AppConfigService;
|
||||
let appConfig: AppConfigServiceMock;
|
||||
let translate: TranslateService;
|
||||
let changeDisposable: any;
|
||||
|
||||
setupTestBed({
|
||||
imports: [CoreTestingModule]
|
||||
imports: [CoreTestingModule],
|
||||
providers: [
|
||||
{ provide: AppConfigService, useClass: AppConfigServiceMock }
|
||||
]
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
@ -56,13 +59,17 @@ describe('UserPreferencesService', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('should get default pagination from app config', () => {
|
||||
it('should get default pagination from app config', (done) => {
|
||||
appConfig.config.pagination.size = 0;
|
||||
expect(preferences.defaults.paginationSize).toBe(defaultPaginationSize);
|
||||
appConfig.load().then(() => {
|
||||
expect(preferences.paginationSize).toBe(0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return supported page sizes defined in the app config', () => {
|
||||
const supportedPages = preferences.getDefaultPageSizes();
|
||||
const supportedPages = preferences.supportedPageSizes;
|
||||
appConfig.load();
|
||||
expect(supportedPages).toEqual(supportedPaginationSize);
|
||||
});
|
||||
|
||||
@ -105,16 +112,6 @@ describe('UserPreferencesService', () => {
|
||||
expect(storage.getItem(propertyKey)).toBe('valueA');
|
||||
});
|
||||
|
||||
it('should store custom pagination settings for default prefix', () => {
|
||||
preferences.paginationSize = 5;
|
||||
expect(preferences.paginationSize).toBe(5);
|
||||
});
|
||||
|
||||
it('should return default paginationSize value', () => {
|
||||
preferences.set('PAGINATION_SIZE', 0);
|
||||
expect(preferences.paginationSize).toBe(defaultPaginationSize);
|
||||
});
|
||||
|
||||
it('should return as default locale the app.config locate as first', () => {
|
||||
appConfig.config.locale = 'fake-locate-config';
|
||||
spyOn(translate, 'getBrowserCultureLang').and.returnValue('fake-locate-browser');
|
||||
@ -141,7 +138,7 @@ describe('UserPreferencesService', () => {
|
||||
it('should stream the page size value when is set', (done) => {
|
||||
preferences.paginationSize = 5;
|
||||
changeDisposable = preferences.onChange.subscribe((userPreferenceStatus) => {
|
||||
expect(userPreferenceStatus.PAGINATION_SIZE).toBe(5);
|
||||
expect(userPreferenceStatus[UserPreferenceValues.PaginationSize]).toBe(5);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -23,8 +23,8 @@ import { StorageService } from './storage.service';
|
||||
import { distinctUntilChanged, map } from 'rxjs/operators';
|
||||
|
||||
export enum UserPreferenceValues {
|
||||
PaginationSize = 'PAGINATION_SIZE',
|
||||
Locale = 'LOCALE',
|
||||
PaginationSize = 'paginationSize',
|
||||
Locale = 'locale',
|
||||
SupportedPageSizes = 'supportedPageSizes'
|
||||
}
|
||||
|
||||
@ -52,9 +52,9 @@ export class UserPreferencesService {
|
||||
}
|
||||
|
||||
private initUserPreferenceStatus() {
|
||||
this.userPreferenceStatus[UserPreferenceValues.Locale] = this.locale || this.getDefaultLocale();
|
||||
this.userPreferenceStatus[UserPreferenceValues.PaginationSize] = this.appConfig.get('pagination.size', this.defaults.paginationSize);
|
||||
this.userPreferenceStatus[UserPreferenceValues.SupportedPageSizes] = this.appConfig.get('pagination.supportedPageSizes', this.defaults.supportedPageSizes);
|
||||
this.set(UserPreferenceValues.Locale, (this.locale || this.getDefaultLocale()));
|
||||
this.set(UserPreferenceValues.PaginationSize, this.paginationSize);
|
||||
this.set(UserPreferenceValues.SupportedPageSizes, JSON.stringify(this.supportedPageSizes));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -145,8 +145,18 @@ export class UserPreferencesService {
|
||||
* Gets an array containing the available page sizes.
|
||||
* @returns Array of page size values
|
||||
*/
|
||||
getDefaultPageSizes(): number[] {
|
||||
return this.userPreferenceStatus[UserPreferenceValues.SupportedPageSizes];
|
||||
get supportedPageSizes(): number[] {
|
||||
let supportedPageSizes = this.get(UserPreferenceValues.SupportedPageSizes);
|
||||
|
||||
if (supportedPageSizes) {
|
||||
return JSON.parse(supportedPageSizes);
|
||||
} else {
|
||||
return this.appConfig.get('pagination.supportedPageSizes', this.defaults.supportedPageSizes);
|
||||
}
|
||||
}
|
||||
|
||||
set supportedPageSizes(value: number[]) {
|
||||
this.set(UserPreferenceValues.SupportedPageSizes, JSON.stringify(value));
|
||||
}
|
||||
|
||||
/** Pagination size. */
|
||||
@ -155,12 +165,18 @@ export class UserPreferencesService {
|
||||
}
|
||||
|
||||
get paginationSize(): number {
|
||||
return Number(this.get(UserPreferenceValues.PaginationSize, this.userPreferenceStatus[UserPreferenceValues.PaginationSize])) || this.defaults.paginationSize;
|
||||
let paginationSize = this.get(UserPreferenceValues.PaginationSize);
|
||||
|
||||
if (paginationSize) {
|
||||
return Number(paginationSize);
|
||||
} else {
|
||||
return Number(this.appConfig.get('pagination.size', this.defaults.paginationSize));
|
||||
}
|
||||
}
|
||||
|
||||
/** Current locale setting. */
|
||||
get locale(): string {
|
||||
return this.get(UserPreferenceValues.Locale, this.userPreferenceStatus[UserPreferenceValues.Locale]);
|
||||
return this.get(UserPreferenceValues.Locale);
|
||||
}
|
||||
|
||||
set locale(value: string) {
|
||||
@ -172,7 +188,7 @@ export class UserPreferencesService {
|
||||
* @returns Default locale language code
|
||||
*/
|
||||
public getDefaultLocale(): string {
|
||||
return this.appConfig.get<string>('locale') || this.translate.getBrowserCultureLang() || 'en';
|
||||
return this.appConfig.get<string>(UserPreferenceValues.Locale) || this.translate.getBrowserCultureLang() || 'en';
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,22 +0,0 @@
|
||||
/*!
|
||||
* @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 * from './components/process-list-cloud.component';
|
||||
export * from './models/process-cloud-query-request.model';
|
||||
export * from './models/process-cloud-preset.model';
|
||||
export * from './models/process-list-sorting.model';
|
||||
export * from './process-list-cloud.module';
|
@ -6,7 +6,7 @@ const retry = require('protractor-retry').retry;
|
||||
|
||||
const AlfrescoApi = require('alfresco-js-api-node');
|
||||
const TestConfig = require('./e2e/test.config');
|
||||
var argv = require('yargs').argv;
|
||||
let argv = require('yargs').argv;
|
||||
|
||||
const fs = require('fs');
|
||||
const rimraf = require('rimraf');
|
||||
@ -16,21 +16,22 @@ const projectRoot = path.resolve(__dirname);
|
||||
const width = 1366;
|
||||
const height = 768;
|
||||
|
||||
var HOST = process.env.URL_HOST_ADF;
|
||||
var BROWSER_RUN = process.env.BROWSER_RUN;
|
||||
var FOLDER = process.env.FOLDER || '';
|
||||
var SELENIUM_SERVER = process.env.SELENIUM_SERVER || '';
|
||||
var DIRECT_CONNECCT = SELENIUM_SERVER ? false : true;
|
||||
var MAXINSTANCES = process.env.MAXINSTANCES || 1;
|
||||
var TIMEOUT = parseInt(process.env.TIMEOUT, 10);
|
||||
let HOST = process.env.URL_HOST_ADF;
|
||||
let BROWSER_RUN = process.env.BROWSER_RUN;
|
||||
let FOLDER = process.env.FOLDER || '';
|
||||
let SELENIUM_SERVER = process.env.SELENIUM_SERVER || '';
|
||||
let DIRECT_CONNECCT = SELENIUM_SERVER ? false : true;
|
||||
let MAXINSTANCES = process.env.MAXINSTANCES || 1;
|
||||
let TIMEOUT = parseInt(process.env.TIMEOUT, 10);
|
||||
let SAVE_SCREENSHOT = (process.env.SAVE_SCREENSHOT == 'true');
|
||||
|
||||
var specsToRun = './**/' + FOLDER + '**/*.e2e.ts';
|
||||
let specsToRun = './**/' + FOLDER + '**/*.e2e.ts';
|
||||
|
||||
if (process.env.NAME_TEST) {
|
||||
specsToRun = './e2e/**/' + process.env.NAME_TEST;
|
||||
}
|
||||
|
||||
var args_options = [];
|
||||
let args_options = [];
|
||||
|
||||
if (BROWSER_RUN === 'true') {
|
||||
args_options = ['--incognito', '--window-size=1366,768', '--disable-gpu'];
|
||||
@ -38,16 +39,111 @@ if (BROWSER_RUN === 'true') {
|
||||
args_options = ['--incognito', '--headless', '--window-size=1366,768', '--disable-gpu'];
|
||||
}
|
||||
|
||||
var downloadFolder = path.join(__dirname, 'e2e/downloads');
|
||||
let downloadFolder = path.join(__dirname, 'e2e/downloads');
|
||||
|
||||
var buildNumber = () => {
|
||||
let buildNumber = () => {
|
||||
let buildNumber = process.env.TRAVIS_BUILD_NUMBER;
|
||||
if (!buildNumber) {
|
||||
process.env.TRAVIS_BUILD_NUMBER = Date.now();
|
||||
}
|
||||
|
||||
return process.env.TRAVIS_BUILD_NUMBER;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
saveScreenshots = async function (alfrescoJsApi, retryCount) {
|
||||
let files = fs.readdirSync(path.join(__dirname, './e2e-output/screenshots'));
|
||||
|
||||
if (files && files.length > 0) {
|
||||
|
||||
let folder;
|
||||
|
||||
try {
|
||||
folder = await alfrescoJsApi.nodes.addNode('-my-', {
|
||||
'name': `retry-${retryCount}`,
|
||||
'relativePath': `Builds/${buildNumber()}/screenshot`,
|
||||
'nodeType': 'cm:folder'
|
||||
}, {}, {
|
||||
'overwrite': true
|
||||
});
|
||||
} catch (error) {
|
||||
folder = await alfrescoJsApi.nodes.getNode('-my-', {
|
||||
'relativePath': `Builds/${buildNumber()}/screenshot/retry-${retryCount}`,
|
||||
'nodeType': 'cm:folder'
|
||||
}, {}, {
|
||||
'overwrite': true
|
||||
});
|
||||
}
|
||||
|
||||
for (const fileName of files) {
|
||||
let pathFile = path.join(__dirname, './e2e-output/screenshots', fileName);
|
||||
let file = fs.createReadStream(pathFile);
|
||||
|
||||
let safeFileName = fileName.replace(new RegExp('"', 'g'), '');
|
||||
|
||||
try {
|
||||
await alfrescoJsApi.upload.uploadFile(
|
||||
file,
|
||||
'',
|
||||
folder.entry.id,
|
||||
null,
|
||||
{
|
||||
'name': safeFileName,
|
||||
'nodeType': 'cm:content',
|
||||
'autoRename': true
|
||||
}
|
||||
);
|
||||
}catch(error){
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
saveReport = async function (filenameReport, alfrescoJsApi) {
|
||||
let pathFile = path.join(__dirname, './e2e-output/junit-report/html', filenameReport + '.html');
|
||||
let reportFile = fs.createReadStream(pathFile);
|
||||
|
||||
let reportFolder;
|
||||
|
||||
try {
|
||||
reportFolder = await alfrescoJsApi.nodes.addNode('-my-', {
|
||||
'name': 'report',
|
||||
'relativePath': `Builds/${buildNumber()}`,
|
||||
'nodeType': 'cm:folder'
|
||||
}, {}, {
|
||||
'overwrite': true
|
||||
});
|
||||
} catch (error) {
|
||||
reportFolder = await alfrescoJsApi.nodes.getNode('-my-', {
|
||||
'relativePath': `Builds/${buildNumber()}/report`,
|
||||
'nodeType': 'cm:folder'
|
||||
}, {}, {
|
||||
'overwrite': true
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
await
|
||||
alfrescoJsApi.upload.uploadFile(
|
||||
reportFile,
|
||||
'',
|
||||
reportFolder.entry.id,
|
||||
null,
|
||||
{
|
||||
'name': reportFile.name,
|
||||
'nodeType': 'cm:content',
|
||||
'autoRename': true
|
||||
}
|
||||
);
|
||||
|
||||
} catch (error) {
|
||||
console.log('error' + error);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
exports.config = {
|
||||
allScriptsTimeout: TIMEOUT,
|
||||
@ -117,8 +213,8 @@ exports.config = {
|
||||
browser.manage().window().setSize(width, height);
|
||||
|
||||
jasmine.getEnv().addReporter(new SpecReporter({spec: {displayStacktrace: true}}));
|
||||
var generatedSuiteName = Math.random().toString(36).substr(2, 5);
|
||||
var junitReporter = new jasmineReporters.JUnitXmlReporter({
|
||||
let generatedSuiteName = Math.random().toString(36).substr(2, 5);
|
||||
let junitReporter = new jasmineReporters.JUnitXmlReporter({
|
||||
consolidateAll: true,
|
||||
savePath: `${projectRoot}/e2e-output/junit-report`,
|
||||
filePrefix: 'results.xml-' + generatedSuiteName,
|
||||
@ -128,7 +224,7 @@ exports.config = {
|
||||
return browser.driver.executeScript(disableCSSAnimation);
|
||||
|
||||
function disableCSSAnimation() {
|
||||
var css = '* {' +
|
||||
let css = '* {' +
|
||||
'-webkit-transition-duration: 0s !important;' +
|
||||
'transition-duration: 0s !important;' +
|
||||
'-webkit-animation-duration: 0s !important;' +
|
||||
@ -145,7 +241,7 @@ exports.config = {
|
||||
},
|
||||
|
||||
beforeLaunch: function () {
|
||||
var reportsFolder = `${projectRoot}/e2e-output/junit-report/`;
|
||||
let reportsFolder = `${projectRoot}/e2e-output/junit-report/`;
|
||||
|
||||
fs.exists(reportsFolder, function (exists, error) {
|
||||
if (exists) {
|
||||
@ -162,18 +258,14 @@ exports.config = {
|
||||
|
||||
afterLaunch: async function () {
|
||||
|
||||
let saveScreenshot = process.env.SAVE_SCREENSHOT;
|
||||
|
||||
if (saveScreenshot) {
|
||||
var retryCount = 1;
|
||||
if (SAVE_SCREENSHOT) {
|
||||
let retryCount = 1;
|
||||
if (argv.retry) {
|
||||
retryCount = ++argv.retry;
|
||||
}
|
||||
|
||||
let filenameReport = `ProtractorTestReport-${FOLDER.replace('/', '')}-${retryCount}`;
|
||||
|
||||
console.log(filenameReport);
|
||||
|
||||
let output = '';
|
||||
let savePath = `${projectRoot}/e2e-output/junit-report/`;
|
||||
let temporaryHtmlPath = savePath + 'html/temporaryHtml/';
|
||||
@ -195,16 +287,14 @@ exports.config = {
|
||||
lastFileName = testConfigReport.outputFilename;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
var lastHtmlFile = temporaryHtmlPath + lastFileName + '.html';
|
||||
let lastHtmlFile = temporaryHtmlPath + lastFileName + '.html';
|
||||
|
||||
if (!(fs.lstatSync(lastHtmlFile).isDirectory())) {
|
||||
output = output + fs.readFileSync(lastHtmlFile);
|
||||
}
|
||||
;
|
||||
|
||||
var fileName = savePath + 'html/' + filenameReport + '.html';
|
||||
let fileName = savePath + 'html/' + filenameReport + '.html';
|
||||
|
||||
fs.writeFileSync(fileName, output, 'utf8');
|
||||
|
||||
@ -214,107 +304,18 @@ exports.config = {
|
||||
});
|
||||
alfrescoJsApi.login(TestConfig.adf.adminEmail, TestConfig.adf.adminPassword);
|
||||
|
||||
if (saveScreenshot === 'true') {
|
||||
await saveScreenshots(alfrescoJsApi, retryCount);
|
||||
|
||||
let files = fs.readdirSync(path.join(__dirname, './e2e-output/screenshots'));
|
||||
await saveReport(filenameReport, alfrescoJsApi);
|
||||
|
||||
if (files && files.length > 0) {
|
||||
|
||||
try {
|
||||
folder = await
|
||||
alfrescoJsApi.nodes.addNode('-my-', {
|
||||
'name': `retry-${retryCount}`,
|
||||
'relativePath': `Builds/${buildNumber()}/screenshot`,
|
||||
'nodeType': 'cm:folder'
|
||||
}, {}, {
|
||||
'overwrite': true
|
||||
});
|
||||
} catch (error) {
|
||||
folder = await
|
||||
alfrescoJsApi.nodes.getNode('-my-', {
|
||||
'relativePath': `Builds/${buildNumber()}/screenshot/retry-${retryCount}`,
|
||||
'nodeType': 'cm:folder'
|
||||
}, {}, {
|
||||
'overwrite': true
|
||||
});
|
||||
}
|
||||
|
||||
for (const fileName of files) {
|
||||
|
||||
let pathFile = path.join(__dirname, './e2e-output/screenshots', fileName);
|
||||
let file = fs.createReadStream(pathFile);
|
||||
|
||||
await
|
||||
alfrescoJsApi.upload.uploadFile(
|
||||
file,
|
||||
'',
|
||||
folder.entry.id,
|
||||
null,
|
||||
{
|
||||
'name': file.name,
|
||||
'nodeType': 'cm:content',
|
||||
'autoRename': true
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let pathFile = path.join(__dirname, './e2e-output/junit-report/html', filenameReport + '.html');
|
||||
let reportFile = fs.createReadStream(pathFile);
|
||||
|
||||
let reportFolder;
|
||||
|
||||
try {
|
||||
reportFolder = await
|
||||
alfrescoJsApi.nodes.addNode('-my-', {
|
||||
'name': 'report',
|
||||
'relativePath': `Builds/${buildNumber()}`,
|
||||
'nodeType': 'cm:folder'
|
||||
}, {}, {
|
||||
'overwrite': true
|
||||
});
|
||||
} catch (error) {
|
||||
reportFolder = await
|
||||
alfrescoJsApi.nodes.getNode('-my-', {
|
||||
'relativePath': `Builds/${buildNumber()}/report`,
|
||||
'nodeType': 'cm:folder'
|
||||
}, {}, {
|
||||
'overwrite': true
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
await
|
||||
alfrescoJsApi.upload.uploadFile(
|
||||
reportFile,
|
||||
'',
|
||||
reportFolder.entry.id,
|
||||
null,
|
||||
{
|
||||
'name': reportFile.name,
|
||||
'nodeType': 'cm:content',
|
||||
'autoRename': true
|
||||
}
|
||||
);
|
||||
|
||||
} catch (error) {
|
||||
console.log('error' + error);
|
||||
|
||||
}
|
||||
|
||||
if (saveScreenshot === 'true') {
|
||||
rimraf(`${projectRoot}/e2e-output/screenshots/`, function () {
|
||||
console.log('done delete screenshot');
|
||||
});
|
||||
}
|
||||
rimraf(`${projectRoot}/e2e-output/screenshots/`, function () {
|
||||
console.log('done delete screenshot');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return retry.afterLaunch(3);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user