Refactor e2e's ApiService (#7101)

* Refactor e2e's ApiService

* Fix bits here and there

* [ci:force] Remove unused imports

* [ci:force] Extract shared part from adf-testing

* [ci:force] Extract StringUtils as well

* Make protractor's Logger not have duplicated code

* [ci:force]
This commit is contained in:
Popovics András
2021-06-19 23:03:17 +02:00
committed by GitHub
parent 2d61a2941c
commit 1ecc14f184
354 changed files with 1699 additions and 1843 deletions

View File

@@ -14,4 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** @deprecated */
// TODO: We need to split adf-testing into smaller chunks
export * from './src/public-api';

View File

@@ -1,41 +0,0 @@
/*!
* @license
* Copyright 2019 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.
*/
import { browser } from 'protractor';
import { ApiService } from './api.service';
export abstract class Api {
public api: ApiService;
constructor() {
this.api = this.configureApi();
}
private configureApi(): ApiService {
return new ApiService({
provider: 'BPM',
authType: browser.params.testConfig.appConfig.authType,
oauth2: browser.params.testConfig.appConfig.oauth2,
hostBpm: browser.params.testConfig.appConfig.bpmHost
});
}
abstract setUp(): Promise<Api>;
abstract tearDown();
}

View File

@@ -1,77 +0,0 @@
/*!
* @license
* Copyright 2019 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.
*/
import { Api } from '../../core/actions/api';
import { Project } from './project';
import { Logger } from '../../core/utils/logger';
import { browser } from 'protractor';
import { NodeEntry, ResultSetPaging } from '@alfresco/js-api';
export class ModelingAPI extends Api {
public project: Project;
constructor() {
super();
}
async setUp(): Promise<ModelingAPI> {
await this.login();
this.project = new Project(this.api);
return this;
}
async tearDown(): Promise<void> {
await this.api.apiService.logout();
}
private async login(): Promise<void> {
try {
await this.api.login(
browser.params.adminapp.modeler,
browser.params.adminapp.modeler_password
);
} catch (error) {
Logger.error(error);
}
}
async createProject(): Promise<NodeEntry> {
const project = await this.project.create();
return project;
}
async releaseProject(project: any): Promise<NodeEntry> {
const releasedProject = await this.project.release(project.entry.id);
return releasedProject;
}
async getProjectRelease(projectId: string): Promise<ResultSetPaging> {
const releasedProject = await this.project.getProjectRelease(projectId);
return releasedProject;
}
async importAndReleaseProject(absoluteFilePath: string): Promise<NodeEntry> {
const project = await this.project.import(absoluteFilePath);
const releasedProject = await this.project.release(project.entry.id);
return releasedProject;
}
async getProjects(): Promise<ResultSetPaging> {
const projects = await this.project.searchProjects();
return projects;
}
}

View File

@@ -1,444 +0,0 @@
{
"CANDIDATE_BASE_APP": {
"name": "candidatebaseapp",
"file_location": "https://github.com/Alfresco/alfresco-ng2-components/blob/develop/e2e/resources/activiti7/candidatebaseapp.zip?raw=true",
"processes": {
"candidateUserProcess": "candidateuserprocess",
"candidateGroupProcess": "candidategroupprocess",
"anotherCandidateGroupProcess": "anothercandidategroup",
"uploadFileProcess": "uploadfileprocess",
"processwithstarteventform": "processwithstarteventform",
"processwithjsonfilemapping": "processwithjsonfilemapping",
"assigneeProcess": "assigneeprocess",
"candidateusersgroups": "candidateusersgroups",
"paralleltasks": "paralleltasks",
"errorStartEventProcess": {
"process_name": "errorstartevent",
"error_id": "Error_END_EVENT",
"error_code": "123"
},
"errorBoundaryEventProcess": {
"process_name": "errorboundaryevent",
"error_id": "Error_END_EVENT",
"error_code": "567"
},
"errorExclusiveGateProcess": {
"process_name": "errorexclusivegate",
"error_id": "Error_OK",
"error_code": "200"
}
},
"processVariables": {
"processWithStartEventForm": {
"processJson": { "test": "ciao" }
}
},
"forms": {
"starteventform": "starteventform",
"formtotestvalidations": "formtotestvalidations",
"uploadfileform": "uploadfileform",
"inputForm": {
"name": "inputform",
"widgets": {
"inputJsonId": "inputjson",
"inputFile": "inputfile"
}
},
"outputForm": {
"name": "outputform",
"widgets": {
"outputJson": "outputjson",
"outputFile": "outputfile"
}
}
},
"security": [
{
"role": "ACTIVITI_ADMIN",
"groups": [],
"users": ["superadminuser", "processadminuser"]
},
{
"role": "ACTIVITI_USER",
"groups": ["hr", "testgroup"],
"users": ["hruser", "salesuser"]
}
],
"tasks": {
"uploadFileTask": "UploadFileTask",
"candidateUserTask": "candidateUserTask",
"salesUserTask": "salesuser task",
"hrUserTask": "hruser task",
"firstTaskMapping": "firsttaskmapping",
"secondTaskMapping": "secondtaskmapping"
}
},
"SIMPLE_APP": {
"name": "simpleapp",
"file_location": "https://github.com/Alfresco/alfresco-ng2-components/blob/develop/e2e/resources/activiti7/simpleapp.zip?raw=true",
"processes": {
"processwithvariables": "processwithvariables",
"simpleProcess": "simpleprocess",
"dropdownOptionsProcess": "dropdownoptionsprocess",
"multilingualprocess": "multilingualprocess",
"processWithTabVisibility": "processwithtabvisibility",
"startmessageevent": "start-message-event",
"intermediatemessageevent": "intermediate-message-event",
"intboundaryevent": "int-boundary-event",
"nonintboundaryevent": "nonint-boundary-event",
"intboundarysubprocess": "int-boundary-subprocess",
"intstartmessageevent": "int-start-message-event",
"nonintstartmessageevent": "nonint-start-message-event",
"siblingtaskprocess": "siblingtaskprocess",
"startTaskVisibilityForm": "start-task-visibility-form",
"startVisibilityForm": "start-visibility-form",
"processstring": "processstring",
"processinteger": "processinteger",
"processboolean": "processboolean",
"processdate": "processdate",
"multiprocess": "multiprocess",
"terminateexclusive": "terminate-exclusive",
"terminatesubprocess": "terminate-subprocess",
"multiinstancedmnparallel": "multiinstance-dmnparallel",
"multiinstancecallactivity": "multiinstance-callactivity",
"multiinstancecollection": "multiinstance-collection",
"multiinstancecompletion": "multiinstance-completion",
"multiinstancesequential": "multiinstance-sequential",
"multiinstanceservicetask": "multiinstance-servicetask",
"multiinstanceusertask": "multiinstance-usertask",
"multiinstancedmnsequence": "multiinstance-dmnsequence",
"multiinstancemanualtask": "multiinstance-manualtask",
"multiinstancesubprocess": "multiinstance-subprocess",
"calledprocess": "calledprocess",
"booleanvisibilityprocess": "booleanvisibilityprocess",
"numbervisibilityprocess": "numbervisibilityprocess",
"processformoutcome": "outcomebuttons",
"uploadSingleMultipleFiles": "upload-single-multiple-pro",
"processDisplayRestJson": "process-display-rest-json",
"poolStartEndMessageThrow": "pool-start-end-mess-throw",
"poolStartEndMessageCatch": "pool-start-end-mess-catch",
"poolProcessCalled": "pool-process-called",
"poolProcessCalling": "pool-process-calling",
"poolNonIntBoundaryThrown": "pool-nonint-boundary-throw",
"poolNonIntBoundaryCatch": "pool-nonint-boundary-catch",
"poolIntermediateMessageThrow": "pool-interm-message-throw",
"poolIntermediateMessageCatch": "pool-interm-message-catch",
"poolInterruptingBoundarySubprocessThrow": "pool-int-bound-subpr-throw",
"poolInterruptingBoundarySubprocessCatch": "pool-int-bound-subpr-catch",
"poolInterruptingBoundaryThrow": "pool-int-boundary-throw",
"poolInterruptingBoundaryCatch": "pool-int-boundary-catch",
"attachFilesProcess": "attach-files-process",
"attachFileVisible": "attach-file-visible",
"attachFileInvisible": "attach-file-invisible",
"attachLocalFile": "attach-local-file",
"attachLocalFileOnTask": "attach-local-file-on-task",
"attachSingleMultiple": "attach-single-multiple",
"attachMultipleSingle": "attach-multiple-single",
"attachMultipleMultiple": "attach-multiple-multiple",
"intermediateDateProcessVarTimer": "interm-date-provar-timer",
"callActivityExpressionSimple":"call-activity-exp-simple",
"callActivityExpressionFromPool":"call-activity-expression-2",
"calledSimple":"called-simple",
"calledInPool":"called-in-pool",
"paralleltasks": "paralleltasks",
"candidateUsersGroup": "candidateusersgroup",
"candidateUserProcess": "candidateuserprocess",
"outputVariablesMapping": "output-variables-mapping",
"outcomeVisibilityProcess": "outcome-visib-process",
"restConnectorProcess": "rest-connector-process"
},
"forms": {
"tabVisibilityFields": {
"name": "tabvisibilitywithfields"
},
"formWithSingleInput": {
"name": "form-with-single-input"
},
"tabVisibilityVars": {
"name": "tabvisibilitywithvars",
"tabs": {
"tabWithFields": "tabWithFields",
"tabVarVar": "tabBasicVarVar",
"tabBasicVarField": "tabBasicVarField"
},
"widgets": {
"textOneId": "TextOne",
"textThreeId": "TextThree",
"numberOneId": "NumberOne"
}
},
"usertaskform": {
"name": "usertaskform"
},
"dropdownform": {
"name": "dropdownform"
},
"formVisibility": {
"name": "form-visibility",
"widgets": {
"textOneId": "Text",
"textTwoId": "Multilinetext"
}
},
"multilingualform": {
"name": "multilingualform"
},
"inputform": {
"name": "inputform",
"widgets": {
"inputText": "inputText",
"inputNumber": "inputNumber",
"inputDate": "inputDate",
"inputCheckbox": "inputCheckbox",
"outputText": "outputText",
"outputNumber": "outputNumber",
"outputDate": "outputDate",
"outputCheckbox": "outputCheckbox"
}
},
"outputform": {
"name": "outputform"
},
"exclusiveconditionform": {
"name": "exclusive-condition-form",
"widgets": {
"exclusiveCondition": "exclusiveCondition"
}
},
"uploadlocalfileform": {
"name": "upload-localfile-form"
},
"booleanvisibility": {
"name": "booleanvisibility"
},
"requirednumbervisibility": {
"name": "requirednumbervisibility"
},
"mealform": {
"name": "mealform",
"widgets": {
"inputMeal": "meal"
}
},
"resultcollectionform": {
"name": "resultcollectionform",
"widgets": {
"resultCollection1": "result1",
"resultCollection2": "result2",
"resultCollection3": "result3"
}
},
"uploadSingleMultiple": {
"name": "upload-single-multiple",
"widgets": {
"contentMultipleAttachFileId": "UploadMultipleFileFromContentId",
"contentSingleAttachFileId": "UploadSingleFileFromContentId"
}
},
"formWithJsonWidget": {
"name": "form-with-json-widget",
"widgets": {
"displayJsonWidgetId": "DisplayJsonWidgetId"
}
},
"formWithAllWidgets": {
"name": "form-with-all-widgets"
},
"poolForm": {
"name": "pool-usertaskform",
"widgets": {
"string": "Text0rfn8p"
}
},
"attachFilesForm": {
"name": "attach-files",
"attachFileWidget1": "Attachfile09lgsk",
"attachFileWidget2": "Attachfile0wopvy"
},
"attachFileVisible": {
"name": "attach-file-visible",
"textField": "Text0t9anw",
"attachFileWidget1": "Attachfile0tccnd",
"attachFileWidget2": "Attachfile08cfo7"
},
"attachFileInvisible": {
"name": "attach-file-invisible",
"textField": "Text0nmwr7",
"attachFileWidget1": "Attachfile0l72dj",
"attachFileWidget2": "Attachfile0lccsg"
},
"attachLocalFile": {
"name": "attach-local-file",
"attachFileWidget1": "Attachfile0ku0bu",
"attachFileWidget2": "Attachfile04mfeb",
"attachFileLocalChildFolder": "Attachfilelocalchildfolder",
"attachFileContentServices": "Attachfilecontentservices",
"attachFileLocalMultiple": "Attachfilelocalmultiple"
},
"attachSingleMultiple": {
"name": "attach-single-multiple",
"attachFileWidget1": "Attachfile0ciulc",
"attachFileWidget2": "Attachfile006uf2"
},
"attachMultipleSingle": {
"name": "attach-multiple-single",
"attachFileWidget1": "Attachfile0whgiz",
"attachFileWidget2": "Attachfile0jpfi9"
},
"attachMultipleMultiple": {
"name": "attach-multiple-multiple",
"attachFileWidget1": "Attachfile07sqao",
"attachFileWidget2": "Attachfile018wvc"
},
"dateTimerForm": {
"name": "date-timer-form"
},
"callActivityUserTaskForm": {
"name": "call-activ-user-task-form"
},
"calledForm": {
"name": "called-form"
},
"outcomeVisibilityForm": {
"name": "outcome-visibility",
"textWidget": "TextForOutcome",
"validAnswerOutcome": "Valid answer",
"invalidAnswerOutcome": "Invalid answer",
"answerTheQuestion": "You should answer the question"
},
"dropdownWithOptions": {
"name": "dropdown-options",
"options": [
{
"id": "empty",
"name": "Choose one..."
},
{
"id": "option_1",
"name": "option1"
},
{
"id": "option_2",
"name": "option2"
},
{
"id": "option_3",
"name": "option3"
}
]
},
"correlationKey": {
"name": "correlation-key-form",
"widgets": {
"setCorrelationKey": "correlationKey"
}
}
},
"tasks": {
"processstring": "inputtask",
"uploadSingleMultipleFiles": "UploadSingleMultipleFiles",
"candidateusersandgrouptask": "candidate users and group",
"candidateUserTask": "candidateUserTask",
"salesUserTask": "salesuser task",
"hrUserTask": "hruser task",
"attachLocalFile": "attach local file",
"userTaskToShowRestResult": "UserTaskToShowRestResult",
"conditionTask": "ConditionTask",
"userTask": "UserTask",
"terminateTask": "TerminateTask",
"mainTask": "MainTask",
"followingTask": "FollowingTask",
"catchTask": "catchtask",
"calledTask": "calledtask",
"throwTask": "throwtask",
"interruptingBoundaryTask": "int-boundary-task",
"nonInterruptingBoundaryTask": "nonint-boundary-task",
"subprocessInterruptingTask": "subprocess-task",
"finalTask": "final-task",
"finalTaskUnited": "finaltask"
},
"security": [
{
"role": "ACTIVITI_ADMIN",
"groups": [],
"users": ["superadminuser", "processadminuser"]
},
{
"role": "ACTIVITI_USER",
"groups": ["hr", "sales", "testgroup"],
"users": ["hruser"]
}
],
"infrastructure": { "connectors": { "restconnector": {} }, "bridges": {} },
"connectors": {
"restConnector": {
"response": {
"userId": 1,
"id": 1,
"title": "delectus aut autem",
"completed": false
}
}
}
},
"SUB_PROCESS_APP": {
"name": "subprocessapp",
"file_location": "https://github.com/Alfresco/alfresco-ng2-components/blob/develop/e2e/resources/activiti7/subprocessapp.zip?raw=true",
"processes": {
"processchild": "processchild",
"processparent": "processparent"
},
"contentModels": {
"contentmodelalltypes": {
"name": "contentmodelalltypes",
"singleCustomType": {
"name": "singleCustomType",
"properties": {
"textProperty": "customtypetext",
"longProperty": "customtypelong",
"intProperty": "customtypeint",
"mltextProperty": "customtypemltext",
"booleanProperty": "customtypeboolean",
"floatProperty": "customtypefloat",
"doubleProperty": "customtypedouble",
"dateProperty": "customtypedate",
"datetimeProperty": "customtypedatetime"
}
},
"singleCustomAspect": {
"name": "singleCustomAspect",
"properties": {
"textProperty": "aspecttext",
"longProperty": "aspectlong",
"intProperty": "aspectint",
"mltextProperty": "aspectmltext",
"booleanProperty": "aspectboolean",
"floatProperty": "aspectfloat",
"doubleProperty": "aspectdouble",
"dateProperty": "aspectdate",
"datetimeProperty": "aspectdatetime"
}
}
},
"contentmodelonlytypes": {
"name": "contentmodelonlytypes",
"customType1": {
"name": "customType",
"properties": {
"textProperty": "text",
"dateProperty": "date",
"datetimeProperty": "datetime"
}
}
}
},
"security": [
{ "role": "ACTIVITI_ADMIN", "groups": [], "users": ["superadminuser"] },
{
"role": "ACTIVITI_USER",
"groups": ["hr", "testgroup"],
"users": ["hruser"]
}
]
}
}

View File

@@ -16,8 +16,8 @@
*/
import { CustomModel, CustomModelApi, CustomModelProperty, CustomType, TypePaging, TypesApi } from '@alfresco/js-api';
import { ApiService } from '../../core/actions/api.service';
import { ApiUtil } from '../../core/actions/api.util';
import { ApiService } from '../../../shared/api/api.service';
import { ApiUtil } from '../../../shared/api/api.util';
import { Logger } from '../../core/utils/logger';
export class ModelActions {

View File

@@ -16,7 +16,7 @@
*/
import { NodeEntry, NodeBodyUpdate, NodesApi } from '@alfresco/js-api';
import { ApiService } from '../../core/actions/api.service';
import { ApiService } from '../../../shared/api/api.service';
export class PermissionActions {
api: ApiService;

View File

@@ -18,9 +18,9 @@
import * as path from 'path';
import * as fs from 'fs';
import { NodeEntry, UploadApi, NodesApi } from '@alfresco/js-api';
import { ApiUtil } from '../../core/actions/api.util';
import { ApiUtil } from '../../../shared/api/api.util';
import { Logger } from '../../core/utils/logger';
import { ApiService } from '../../core/actions/api.service';
import { ApiService } from '../../../shared/api/api.service';
export class UploadActions {

View File

@@ -0,0 +1,47 @@
/*!
* @license
* Copyright 2019 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.
*/
import { AlfrescoApiConfig } from '@alfresco/js-api';
import { ApiService } from '../../../shared/api/api.service';
import { Logger } from '../utils/logger';
import { browser } from 'protractor';
export function createApiService(
/** @deprecated */
appConfigOverride: Partial<AlfrescoApiConfig> = {}
) {
const patchedAppConfig = {
...browser.params.testConfig.appConfig,
oauth2: {
...browser.params.testConfig.appConfig.oauth2,
// For some reason protractor e2es must have this value hardcoded
implicitFlow: false
},
// Legacy debt...
hostEcm: browser.params.testConfig.appConfig.ecmHost,
hostBpm: browser.params.testConfig.appConfig.bpmHost,
...appConfigOverride
};
return new ApiService(
{
appConfig: new AlfrescoApiConfig(patchedAppConfig),
users: browser.params.testConfig.users
},
Logger
);
}

View File

@@ -15,9 +15,9 @@
* limitations under the License.
*/
import { ApiService } from '../api.service';
import { StringUtil } from '../../utils/string.util';
import { ApiUtil } from '../../actions/api.util';
import { ApiService } from '../../../../shared/api/api.service';
import { StringUtil } from '../../../../shared/utils/string.util';
import { ApiUtil } from '../../../../shared/api/api.util';
import { Logger } from '../../utils/logger';
import { browser } from 'protractor';

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { ApiService } from '../api.service';
import { ApiService } from '../../../../shared/api/api.service';
import { UserModel } from '../../models/user.model';
import { RolesService } from './roles.service';
import { Logger } from '../../utils/logger';

View File

@@ -15,9 +15,9 @@
* limitations under the License.
*/
import { ApiService } from '../api.service';
import { ApiService } from '../../../../shared/api/api.service';
import { Logger } from '../../utils/logger';
import { ApiUtil } from '../../actions/api.util';
import { ApiUtil } from '../../../../shared/api/api.util';
export type TaskStatus = 'COMPLETED' | 'CREATED' | 'ASSIGNED' | 'SUSPENDED' | 'CANCELLED' | 'RUNNING';

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { ApiService } from '../api.service';
import { ApiService } from '../../../../shared/api/api.service';
export class RolesService {

View File

@@ -16,10 +16,7 @@
*/
export * from './identity/public-api';
export * from './api.service';
export * from './api.service.factory';
export * from './drop.actions';
export * from './users.actions';
export * from './api';
export * from './api.util';
export * from './e2e-request-api.helper';
export * from './search.service';

View File

@@ -15,10 +15,10 @@
* limitations under the License.
*/
import { ApiService } from './api.service';
import { ApiService } from '../../../shared/api/api.service';
import { ResultSetPaging, SearchApi } from '@alfresco/js-api';
import { Logger } from '../utils/logger';
import { ApiUtil } from './api.util';
import { ApiUtil } from '../../../shared/api/api.util';
import { UserModel } from '../models/user.model';
export class SearchService {

View File

@@ -29,7 +29,7 @@ import {
} from '@alfresco/js-api';
import { IdentityService } from './identity/identity.service';
import { UserModel } from '../models/user.model';
import { ApiService } from './api.service';
import { ApiService } from '../../../shared/api/api.service';
import { Logger } from '../utils/logger';
import { Tenant } from '../models/tenant';

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { StringUtil } from '../utils/string.util';
import { StringUtil } from '../../../shared/utils/string.util';
export class FileModel {

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { StringUtil } from '../utils/string.util';
import { StringUtil } from '../../../shared/utils/string.util';
/**
* Create tenant JSON Object

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { StringUtil } from '../utils/string.util';
import { StringUtil } from '../../../shared/utils/string.util';
import { browser } from 'protractor';
import { UserRepresentation } from '@alfresco/js-api';

Some files were not shown because too many files have changed in this diff Show More