mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4529] Enable form configuration from e2e tests (#4738)
* [ADF-4529] Enable form configuration from e2e tests * Improve linting * Move form methods to new file
This commit is contained in:
committed by
Eugenio Romano
parent
36faed0fab
commit
f2f08a5bf8
@@ -16,10 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, OnDestroy, OnInit } from '@angular/core';
|
import { Component, OnDestroy, OnInit } from '@angular/core';
|
||||||
import { FormFieldModel, NotificationService, FormRenderingService } from '@alfresco/adf-core';
|
import { FormFieldModel, NotificationService, FormRenderingService, CoreAutomationService } from '@alfresco/adf-core';
|
||||||
import { FormCloud, FormCloudService, UploadCloudWidgetComponent } from '@alfresco/adf-process-services-cloud';
|
import { FormCloud, FormCloudService, UploadCloudWidgetComponent } from '@alfresco/adf-process-services-cloud';
|
||||||
import { Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
import { formDefinition } from './demo-form';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: 'cloud-form-demo.component.html',
|
templateUrl: 'cloud-form-demo.component.html',
|
||||||
@@ -45,7 +44,8 @@ export class FormCloudDemoComponent implements OnInit, OnDestroy {
|
|||||||
constructor(
|
constructor(
|
||||||
private notificationService: NotificationService,
|
private notificationService: NotificationService,
|
||||||
private formRenderingService: FormRenderingService,
|
private formRenderingService: FormRenderingService,
|
||||||
private formService: FormCloudService) {
|
private formService: FormCloudService,
|
||||||
|
private automationService: CoreAutomationService) {
|
||||||
this.formRenderingService.setComponentTypeResolver('upload', () => UploadCloudWidgetComponent, true);
|
this.formRenderingService.setComponentTypeResolver('upload', () => UploadCloudWidgetComponent, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ export class FormCloudDemoComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.formConfig = formDefinition;
|
this.formConfig = this.automationService.forms.getFormCloudDefinition();
|
||||||
this.parseForm();
|
this.parseForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,96 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
export const formDefinition = `{
|
|
||||||
"formRepresentation": {
|
|
||||||
"id": "text-form",
|
|
||||||
"name": "test-start-form",
|
|
||||||
"version": 0,
|
|
||||||
"description": "",
|
|
||||||
"formDefinition": {
|
|
||||||
"tabs": [],
|
|
||||||
"fields": [
|
|
||||||
{
|
|
||||||
"id": "1511517333638",
|
|
||||||
"type": "container",
|
|
||||||
"fieldType": "ContainerRepresentation",
|
|
||||||
"name": "Label",
|
|
||||||
"tab": null,
|
|
||||||
"numberOfColumns": 2,
|
|
||||||
"fields": {
|
|
||||||
"1": [
|
|
||||||
{
|
|
||||||
"fieldType": "FormFieldRepresentation",
|
|
||||||
"id": "texttest",
|
|
||||||
"name": "texttest",
|
|
||||||
"type": "text",
|
|
||||||
"value": null,
|
|
||||||
"required": false,
|
|
||||||
"placeholder": "text",
|
|
||||||
"params": {
|
|
||||||
"existingColspan": 2,
|
|
||||||
"maxColspan": 6,
|
|
||||||
"inputMaskReversed": true,
|
|
||||||
"inputMask": "0#",
|
|
||||||
"inputMaskPlaceholder": "(0-9)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"2": [{
|
|
||||||
"fieldType": "AttachFileFieldRepresentation",
|
|
||||||
"id": "attachfiletest",
|
|
||||||
"name": "attachfiletest",
|
|
||||||
"type": "upload",
|
|
||||||
"required": true,
|
|
||||||
"colspan": 2,
|
|
||||||
"placeholder": "attachfile",
|
|
||||||
"params": {
|
|
||||||
"existingColspan": 2,
|
|
||||||
"maxColspan": 2,
|
|
||||||
"fileSource": {
|
|
||||||
"serviceId": "local-file",
|
|
||||||
"name": "Local File"
|
|
||||||
},
|
|
||||||
"multiple": true,
|
|
||||||
"link": false
|
|
||||||
},
|
|
||||||
"visibilityCondition": {
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"outcomes": [],
|
|
||||||
"metadata": {
|
|
||||||
"property1": "value1",
|
|
||||||
"property2": "value2"
|
|
||||||
},
|
|
||||||
"variables": [
|
|
||||||
{
|
|
||||||
"name": "variable1",
|
|
||||||
"type": "string",
|
|
||||||
"value": "value1"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "variable2",
|
|
||||||
"type": "string",
|
|
||||||
"value": "value2"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
`;
|
|
@@ -16,9 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, Inject, OnInit } from '@angular/core';
|
import { Component, Inject, OnInit } from '@angular/core';
|
||||||
import { FormModel, FormService, FormOutcomeEvent } from '@alfresco/adf-core';
|
import { FormModel, FormService, FormOutcomeEvent, CoreAutomationService } from '@alfresco/adf-core';
|
||||||
import { InMemoryFormService } from '../../services/in-memory-form.service';
|
import { InMemoryFormService } from '../../services/in-memory-form.service';
|
||||||
import { DemoForm } from './demo-form';
|
|
||||||
import { FakeFormService } from './fake-form.service';
|
import { FakeFormService } from './fake-form.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -37,7 +36,8 @@ export class FormLoadingComponent implements OnInit {
|
|||||||
radioButtonFieldValue = '';
|
radioButtonFieldValue = '';
|
||||||
formattedData = {};
|
formattedData = {};
|
||||||
|
|
||||||
constructor(@Inject(FormService) private formService: InMemoryFormService) {
|
constructor(@Inject(FormService) private formService: InMemoryFormService,
|
||||||
|
private automationService: CoreAutomationService) {
|
||||||
formService.executeOutcome.subscribe((formOutcomeEvent: FormOutcomeEvent) => {
|
formService.executeOutcome.subscribe((formOutcomeEvent: FormOutcomeEvent) => {
|
||||||
formOutcomeEvent.preventDefault();
|
formOutcomeEvent.preventDefault();
|
||||||
});
|
});
|
||||||
@@ -45,7 +45,7 @@ export class FormLoadingComponent implements OnInit {
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.formattedData = {};
|
this.formattedData = {};
|
||||||
const formDefinitionJSON: any = DemoForm.getSimpleFormDefinition();
|
const formDefinitionJSON: any = this.automationService.forms.getSimpleFormDefinition();
|
||||||
this.form = this.formService.parseForm(formDefinitionJSON);
|
this.form = this.formService.parseForm(formDefinitionJSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,9 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, Inject, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
import { Component, Inject, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
||||||
import { FormModel, FormFieldModel, FormService, FormOutcomeEvent, NotificationService } from '@alfresco/adf-core';
|
import { FormModel, FormFieldModel, FormService, FormOutcomeEvent, NotificationService, CoreAutomationService } from '@alfresco/adf-core';
|
||||||
import { InMemoryFormService } from '../../services/in-memory-form.service';
|
import { InMemoryFormService } from '../../services/in-memory-form.service';
|
||||||
import { DemoForm } from './demo-form';
|
|
||||||
import { Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -48,7 +47,8 @@ export class FormComponent implements OnInit, OnDestroy {
|
|||||||
};
|
};
|
||||||
|
|
||||||
constructor(@Inject(FormService) private formService: InMemoryFormService,
|
constructor(@Inject(FormService) private formService: InMemoryFormService,
|
||||||
private notificationService: NotificationService) {
|
private notificationService: NotificationService,
|
||||||
|
private automationService: CoreAutomationService) {
|
||||||
|
|
||||||
this.subscriptions.push(
|
this.subscriptions.push(
|
||||||
formService.executeOutcome.subscribe((formOutcomeEvent: FormOutcomeEvent) => {
|
formService.executeOutcome.subscribe((formOutcomeEvent: FormOutcomeEvent) => {
|
||||||
@@ -62,7 +62,7 @@ export class FormComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
const formDefinitionJSON: any = DemoForm.getDefinition();
|
const formDefinitionJSON: any = this.automationService.forms.getFormDefinition();
|
||||||
this.formConfig = JSON.stringify(formDefinitionJSON);
|
this.formConfig = JSON.stringify(formDefinitionJSON);
|
||||||
this.parseForm();
|
this.parseForm();
|
||||||
}
|
}
|
||||||
|
1827
lib/core/mock/form/demo-form.mock.ts
Normal file
1827
lib/core/mock/form/demo-form.mock.ts
Normal file
File diff suppressed because it is too large
Load Diff
@@ -20,11 +20,14 @@ import { AppConfigService } from '../app-config/app-config.service';
|
|||||||
import { AlfrescoApiService } from '../services/alfresco-api.service';
|
import { AlfrescoApiService } from '../services/alfresco-api.service';
|
||||||
import { StorageService } from './storage.service';
|
import { StorageService } from './storage.service';
|
||||||
import { UserPreferencesService } from './user-preferences.service';
|
import { UserPreferencesService } from './user-preferences.service';
|
||||||
|
import { DemoForms } from '../mock/form/demo-form.mock';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class CoreAutomationService {
|
export class CoreAutomationService {
|
||||||
|
forms = new DemoForms();
|
||||||
|
|
||||||
constructor(private appConfigService: AppConfigService,
|
constructor(private appConfigService: AppConfigService,
|
||||||
private alfrescoApiService: AlfrescoApiService,
|
private alfrescoApiService: AlfrescoApiService,
|
||||||
private userPreferencesService: UserPreferencesService,
|
private userPreferencesService: UserPreferencesService,
|
||||||
@@ -46,6 +49,14 @@ export class CoreAutomationService {
|
|||||||
this.userPreferencesService.set(key, data);
|
this.userPreferencesService.set(key, data);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
adfProxy.setFormInEditor = (json: string) => {
|
||||||
|
this.forms.formDefinition = JSON.parse(json);
|
||||||
|
};
|
||||||
|
|
||||||
|
adfProxy.setCloudFormInEditor = (json: string) => {
|
||||||
|
this.forms.cloudFormDefinition = JSON.parse(json);
|
||||||
|
};
|
||||||
|
|
||||||
adfProxy.clearStorage = () => {
|
adfProxy.clearStorage = () => {
|
||||||
this.storageService.clear();
|
this.storageService.clear();
|
||||||
};
|
};
|
||||||
|
@@ -56,3 +56,4 @@ export * from './download-zip.service';
|
|||||||
export * from './lock.service';
|
export * from './lock.service';
|
||||||
export * from './automation.service';
|
export * from './automation.service';
|
||||||
export * from './previous-route.service';
|
export * from './previous-route.service';
|
||||||
|
export * from './automation.service';
|
||||||
|
33
lib/testing/src/lib/core/utils/form.util.ts
Normal file
33
lib/testing/src/lib/core/utils/form.util.ts
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
/*!
|
||||||
|
* @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';
|
||||||
|
|
||||||
|
export class FormUtil {
|
||||||
|
|
||||||
|
static async setForm(value: string) {
|
||||||
|
await browser.executeScript(
|
||||||
|
'window.adf.setFormInEditor(`' + value + '`);'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static async setCloudForm(value: string) {
|
||||||
|
await browser.executeScript(
|
||||||
|
'window.adf.setCloudFormInEditor(`' + value + '`);'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@@ -21,3 +21,4 @@ export * from './string.util';
|
|||||||
export * from './protractor.util';
|
export * from './protractor.util';
|
||||||
export * from './local-storage.util';
|
export * from './local-storage.util';
|
||||||
export * from './file-browser.util';
|
export * from './file-browser.util';
|
||||||
|
export * from './form.util';
|
||||||
|
11
package.json
11
package.json
@@ -46,10 +46,12 @@
|
|||||||
"e2e": "./scripts/test-e2e-lib.sh -host 'localhost:4200' -dev --folder demo-shell",
|
"e2e": "./scripts/test-e2e-lib.sh -host 'localhost:4200' -dev --folder demo-shell",
|
||||||
"e2e-lib": "ng e2e lib-e2e-test --port=4200",
|
"e2e-lib": "ng e2e lib-e2e-test --port=4200",
|
||||||
"lite-server-e2e": "lite-server --baseDir='demo-shell/dist/' -c ./e2e/lite-server-proxy.js",
|
"lite-server-e2e": "lite-server --baseDir='demo-shell/dist/' -c ./e2e/lite-server-proxy.js",
|
||||||
|
"replace-cloud-config": "node appConfigReplace.cloud.js",
|
||||||
"06": "echo -------------------------------------------- Clean -----------------------------------------------",
|
"06": "echo -------------------------------------------- Clean -----------------------------------------------",
|
||||||
"06s": "",
|
"06s": "",
|
||||||
"clean": "rimraf dist ./node_modules typings",
|
"clean": "rimraf dist ./node_modules typings",
|
||||||
"clean-lock": "rimraf package-lock.json"
|
"clean-lock": "rimraf package-lock.json",
|
||||||
|
"lint:staged": "lint-staged"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -100,6 +102,7 @@
|
|||||||
"core-js": "^2.5.4",
|
"core-js": "^2.5.4",
|
||||||
"custom-event-polyfill": "0.3.0",
|
"custom-event-polyfill": "0.3.0",
|
||||||
"hammerjs": "2.0.8",
|
"hammerjs": "2.0.8",
|
||||||
|
"lint-staged": "^8.1.7",
|
||||||
"minimatch-browser": "1.0.0",
|
"minimatch-browser": "1.0.0",
|
||||||
"moment": "2.22.2",
|
"moment": "2.22.2",
|
||||||
"moment-es6": "^1.0.0",
|
"moment-es6": "^1.0.0",
|
||||||
@@ -230,9 +233,13 @@
|
|||||||
},
|
},
|
||||||
"module": "./index.js",
|
"module": "./index.js",
|
||||||
"typings": "./index.d.ts",
|
"typings": "./index.d.ts",
|
||||||
|
"lint-staged": {
|
||||||
|
"*.ts": "npm run lint-lib -- --fix",
|
||||||
|
"*.scss": "npm run stylelint --syntax scss"
|
||||||
|
},
|
||||||
"husky": {
|
"husky": {
|
||||||
"hooks": {
|
"hooks": {
|
||||||
"pre-commit": "npm run lint-lib -- --fix && npm run stylelint -- --fix"
|
"pre-commit": "npm run lint:staged"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user