diff --git a/angular.json b/angular.json index 61a58eb12f..3b79b6cd61 100644 --- a/angular.json +++ b/angular.json @@ -777,6 +777,41 @@ } } } + }, + "testing": { + "root": "lib/testing", + "sourceRoot": "lib/testing/src", + "projectType": "library", + "prefix": "adf", + "architect": { + "build": { + "builder": "@angular-devkit/build-ng-packagr:build", + "options": { + "tsConfig": "lib/testing/tsconfig.lib.json", + "project": "lib/testing/ng-package.json" + } + }, + "test": { + "builder": "@angular-devkit/build-angular:karma", + "options": { + "main": "lib/testing/src/test.ts", + "tsConfig": "lib/testing/tsconfig.spec.json", + "karmaConfig": "lib/testing/karma.conf.js" + } + }, + "lint": { + "builder": "@angular-devkit/build-angular:tslint", + "options": { + "tsConfig": [ + "lib/testing/tsconfig.lib.json", + "lib/testing/tsconfig.spec.json" + ], + "exclude": [ + "**/node_modules/**" + ] + } + } + } } }, "defaultProject": "dist" diff --git a/demo-shell/src/tsconfig.app.json b/demo-shell/src/tsconfig.app.json index 2cbf8b3b7f..66f72873a2 100644 --- a/demo-shell/src/tsconfig.app.json +++ b/demo-shell/src/tsconfig.app.json @@ -15,6 +15,9 @@ "@alfresco/adf-process-services-cloud": [ "../../lib/process-services-cloud" ], + "@alfresco/adf-testing": [ + "../../lib/testing" + ], "@alfresco/adf-content-services": [ "../../lib/content-services" ], diff --git a/demo-shell/src/tsconfig.dev.json b/demo-shell/src/tsconfig.dev.json index c136985665..908dbbceef 100644 --- a/demo-shell/src/tsconfig.dev.json +++ b/demo-shell/src/tsconfig.dev.json @@ -34,6 +34,9 @@ ], "@alfresco/adf-process-services-cloud": [ "../../lib/process-services-cloud" + ], + "@alfresco/adf-testing": [ + "../../lib/testing" ] } }, diff --git a/e2e/actions/APS-cloud/apiservice.ts b/e2e/actions/APS-cloud/apiservice.ts index 801bc0a6e6..6a354a8316 100644 --- a/e2e/actions/APS-cloud/apiservice.ts +++ b/e2e/actions/APS-cloud/apiservice.ts @@ -17,7 +17,6 @@ import AlfrescoApi = require('alfresco-js-api-node'); import TestConfig = require('../../test.config'); - export class ApiService { HOST_SSO = TestConfig.adf.hostSso; diff --git a/e2e/core/header-component.e2e.ts b/e2e/core/header-component.e2e.ts index 19e90a0658..73f57f96ab 100644 --- a/e2e/core/header-component.e2e.ts +++ b/e2e/core/header-component.e2e.ts @@ -17,7 +17,7 @@ import { LoginPage } from '../pages/adf/loginPage'; import { NavigationBarPage } from '../pages/adf/navigationBarPage'; -import { HeaderPage } from '../pages/adf/core/headerPage'; +import { HeaderPage } from '@alfresco/adf-testing'; import { SettingsPage } from '../pages/adf/settingsPage'; import TestConfig = require('../test.config'); diff --git a/e2e/pages/adf/loginSSOPage.ts b/e2e/pages/adf/loginSSOPage.ts index 2cf82d3ea6..9a060ea23e 100644 --- a/e2e/pages/adf/loginSSOPage.ts +++ b/e2e/pages/adf/loginSSOPage.ts @@ -17,7 +17,6 @@ import { Util } from '../../util/util'; import { element, by, browser, protractor } from 'protractor'; - export class LoginSSOPage { ssoButton = element(by.css(`[data-automation-id="login-button-sso"]`)); diff --git a/lib/testing/karma.conf.js b/lib/testing/karma.conf.js new file mode 100644 index 0000000000..4c5f8d03f9 --- /dev/null +++ b/lib/testing/karma.conf.js @@ -0,0 +1,31 @@ +// Karma configuration file, see link for more information +// https://karma-runner.github.io/1.0/config/configuration-file.html + +module.exports = function (config) { + config.set({ + basePath: '', + frameworks: ['jasmine', '@angular-devkit/build-angular'], + plugins: [ + require('karma-jasmine'), + require('karma-chrome-launcher'), + require('karma-jasmine-html-reporter'), + require('karma-coverage-istanbul-reporter'), + require('@angular-devkit/build-angular/plugins/karma') + ], + client: { + clearContext: false // leave Jasmine Spec Runner output visible in browser + }, + coverageIstanbulReporter: { + dir: require('path').join(__dirname, '../../coverage'), + reports: ['html', 'lcovonly'], + fixWebpackSourcePaths: true + }, + reporters: ['progress', 'kjhtml'], + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: true, + browsers: ['Chrome'], + singleRun: false + }); +}; diff --git a/lib/testing/ng-package.json b/lib/testing/ng-package.json new file mode 100644 index 0000000000..44fb5ca4a0 --- /dev/null +++ b/lib/testing/ng-package.json @@ -0,0 +1,7 @@ +{ + "$schema": "../../node_modules/ng-packagr/ng-package.schema.json", + "dest": "../dist/testing", + "lib": { + "entryFile": "src/public-api.ts" + } +} diff --git a/lib/testing/package.json b/lib/testing/package.json new file mode 100644 index 0000000000..a44278437d --- /dev/null +++ b/lib/testing/package.json @@ -0,0 +1,9 @@ +{ + "name": "@alfresco/adf-testing", + "version": "0.0.1", + "peerDependencies": { + "@angular/common": "^7.1.0", + "@angular/core": "^7.1.0", + "@alfresco/js-api": "3.0.0-delta18" + } +} diff --git a/lib/testing/src/lib/content-services/actions/example.action.ts b/lib/testing/src/lib/content-services/actions/example.action.ts new file mode 100644 index 0000000000..e3ebd14983 --- /dev/null +++ b/lib/testing/src/lib/content-services/actions/example.action.ts @@ -0,0 +1,20 @@ +/*! + * @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 class ExampleAction { + +} diff --git a/lib/testing/src/lib/content-services/actions/public-api.ts b/lib/testing/src/lib/content-services/actions/public-api.ts new file mode 100644 index 0000000000..c5eb261e15 --- /dev/null +++ b/lib/testing/src/lib/content-services/actions/public-api.ts @@ -0,0 +1,5 @@ +/* + * Public API Surface of testing + */ + +export * from './example.action'; diff --git a/lib/testing/src/lib/content-services/pages/example.page.ts b/lib/testing/src/lib/content-services/pages/example.page.ts new file mode 100644 index 0000000000..cb7bdb491f --- /dev/null +++ b/lib/testing/src/lib/content-services/pages/example.page.ts @@ -0,0 +1,20 @@ +/*! + * @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 class ExamplePage { + +} diff --git a/lib/testing/src/lib/content-services/pages/public-api.ts b/lib/testing/src/lib/content-services/pages/public-api.ts new file mode 100644 index 0000000000..12e314e7c7 --- /dev/null +++ b/lib/testing/src/lib/content-services/pages/public-api.ts @@ -0,0 +1,5 @@ +/* + * Public API Surface of testing + */ + +export * from './example.page'; diff --git a/lib/testing/src/lib/content-services/public-api.ts b/lib/testing/src/lib/content-services/public-api.ts new file mode 100644 index 0000000000..dcc70fb91a --- /dev/null +++ b/lib/testing/src/lib/content-services/public-api.ts @@ -0,0 +1,6 @@ +/* + * Public API Surface of testing + */ + +export * from './pages/public-api'; +export * from './actions/public-api'; diff --git a/lib/testing/src/lib/core/actions/public-api.ts b/lib/testing/src/lib/core/actions/public-api.ts new file mode 100644 index 0000000000..79b4ec75e2 --- /dev/null +++ b/lib/testing/src/lib/core/actions/public-api.ts @@ -0,0 +1,3 @@ +/* + * Public API Surface of testing + */ diff --git a/lib/testing/src/lib/core/browser-visibility.ts b/lib/testing/src/lib/core/browser-visibility.ts new file mode 100644 index 0000000000..2a3a297a19 --- /dev/null +++ b/lib/testing/src/lib/core/browser-visibility.ts @@ -0,0 +1,83 @@ +/*! + * @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. + */ + +import { browser, protractor } from 'protractor'; +let until = protractor.ExpectedConditions; + +const DEFAULT_TIMEOUT = 40000; + +export class BrowserVisibility { + + constructor() {} + + /* + * Wait for element is visible + */ + static waitUntilElementIsVisible(elementToCheck, waitTimeout: number = DEFAULT_TIMEOUT) { + let isDisplayed = false; + return browser.wait(() => { + browser.waitForAngularEnabled(); + + elementToCheck.isDisplayed().then( + () => { + isDisplayed = true; + }, + (err) => { + isDisplayed = false; + } + ); + return isDisplayed; + }, waitTimeout, 'Element is not visible ' + elementToCheck.locator()); + } + + /* + * Wait for element to be clickable + */ + static waitUntilElementIsClickable(elementToCheck, waitTimeout: number = DEFAULT_TIMEOUT) { + let isDisplayed = false; + return browser.wait(() => { + browser.waitForAngularEnabled(); + + elementToCheck.isDisplayed().then( + () => { + isDisplayed = true; + }, + (err) => { + isDisplayed = false; + } + ); + return isDisplayed; + }, waitTimeout, 'Element is not visible ' + elementToCheck.locator()); + } + + /* + * Wait for element to have value + */ + static waitUntilElementHasValue(elementToCheck, elementValue, waitTimeout: number = DEFAULT_TIMEOUT) { + browser.waitForAngularEnabled(); + + browser.wait(until.textToBePresentInElementValue(elementToCheck, elementValue), waitTimeout, 'Element doesn\'t have a value ' + elementToCheck.locator()); + } + + /* + * Wait for element to not be visible + */ + static waitUntilElementIsNotOnPage(elementToCheck, waitTimeout: number = DEFAULT_TIMEOUT) { + return browser.wait(until.not(until.visibilityOf(elementToCheck)), waitTimeout, 'Element is not in the page ' + elementToCheck.locator()); + } + +} diff --git a/lib/testing/src/lib/core/pages/header.page.ts b/lib/testing/src/lib/core/pages/header.page.ts new file mode 100644 index 0000000000..6914452431 --- /dev/null +++ b/lib/testing/src/lib/core/pages/header.page.ts @@ -0,0 +1,138 @@ +/*! + * @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. + */ + +import { element, by, protractor } from 'protractor'; +import { BrowserVisibility } from '../browser-visibility'; + +export class HeaderPage { + + checkBox = element(by.cssContainingText('.mat-checkbox-label', 'Show menu button')); + headerColor = element(by.css('option[value="primary"]')); + titleInput = element(by.css('input[name="title"]')); + iconInput = element(by.css('input[placeholder="URL path"]')); + hexColorInput = element(by.css('input[placeholder="hex color code"]')); + logoHyperlinkInput = element(by.css('input[placeholder="Redirect URL"]')); + logoTooltipInput = element(by.css('input[placeholder="Tooltip text"]')); + positionStart = element.all(by.css('mat-radio-button[value="start"]')).first(); + positionEnd = element.all(by.css('mat-radio-button[value="end"]')).first(); + sideBarPositionRight = element(by.css('mat-sidenav.mat-drawer.mat-sidenav.mat-drawer-end')); + sideBarPositionLeft = element(by.css('mat-sidenav.mat-drawer.mat-sidenav')); + + checkShowMenuCheckBoxIsDisplayed() { + return BrowserVisibility.waitUntilElementIsVisible(this.checkBox); + } + + checkChooseHeaderColourIsDisplayed() { + return BrowserVisibility.waitUntilElementIsVisible(this.headerColor); + } + + checkChangeTitleIsDisplayed() { + return BrowserVisibility.waitUntilElementIsVisible(this.titleInput); + } + + checkChangeUrlPathIsDisplayed() { + return BrowserVisibility.waitUntilElementIsVisible(this.iconInput); + } + + clickShowMenuButton() { + let checkBox = element.all(by.css('mat-checkbox')); + BrowserVisibility.waitUntilElementIsVisible(checkBox); + return checkBox.get(0).click(); + } + + changeHeaderColor(color) { + let headerColor = element(by.css('option[value="' + color + '"]')); + return headerColor.click(); + } + + checkAppTitle(name) { + let title = element(by.cssContainingText('.adf-app-title', name)); + return BrowserVisibility.waitUntilElementIsVisible(title); + } + + addTitle(title) { + BrowserVisibility.waitUntilElementIsVisible(this.titleInput); + this.titleInput.click(); + this.titleInput.sendKeys(title); + this.titleInput.sendKeys(protractor.Key.ENTER); + } + + checkIconIsDisplayed(url) { + let icon = element(by.css('img[src="' + url + '"]')); + BrowserVisibility.waitUntilElementIsVisible(icon); + } + + addIcon(url) { + BrowserVisibility.waitUntilElementIsVisible(this.iconInput); + this.iconInput.click(); + this.iconInput.sendKeys(url); + this.iconInput.sendKeys(protractor.Key.ENTER); + } + + checkHexColorInputIsDisplayed() { + return BrowserVisibility.waitUntilElementIsVisible(this.hexColorInput); + } + + checkLogoHyperlinkInputIsDisplayed() { + return BrowserVisibility.waitUntilElementIsVisible(this.logoHyperlinkInput); + } + + checkLogoTooltipInputIsDisplayed() { + return BrowserVisibility.waitUntilElementIsVisible(this.logoTooltipInput); + } + + addHexCodeColor(hexCode) { + BrowserVisibility.waitUntilElementIsVisible(this.hexColorInput); + this.hexColorInput.click(); + this.hexColorInput.sendKeys(hexCode); + return this.hexColorInput.sendKeys(protractor.Key.ENTER); + } + + addLogoHyperlink(hyperlink) { + BrowserVisibility.waitUntilElementIsVisible(this.logoHyperlinkInput); + BrowserVisibility.waitUntilElementIsClickable(this.logoHyperlinkInput); + this.logoHyperlinkInput.click(); + this.logoHyperlinkInput.sendKeys(hyperlink); + return this.logoHyperlinkInput.sendKeys(protractor.Key.ENTER); + } + + addLogoTooltip(tooltip) { + BrowserVisibility.waitUntilElementIsVisible(this.logoTooltipInput); + this.logoTooltipInput.click(); + this.logoTooltipInput.sendKeys(tooltip); + return this.logoTooltipInput.sendKeys(protractor.Key.ENTER); + } + + sideBarPositionStart() { + BrowserVisibility.waitUntilElementIsVisible(this.positionStart); + return this.positionStart.click(); + } + + sideBarPositionEnd() { + BrowserVisibility.waitUntilElementIsVisible(this.positionEnd); + return this.positionEnd.click(); + } + + checkSidebarPositionStart() { + return BrowserVisibility.waitUntilElementIsVisible(this.sideBarPositionLeft); + } + + checkSidebarPositionEnd() { + return BrowserVisibility.waitUntilElementIsVisible(this.sideBarPositionRight); + } + +} diff --git a/lib/testing/src/lib/core/pages/public-api.ts b/lib/testing/src/lib/core/pages/public-api.ts new file mode 100644 index 0000000000..0bf79d6110 --- /dev/null +++ b/lib/testing/src/lib/core/pages/public-api.ts @@ -0,0 +1,5 @@ +/* + * Public API Surface of testing + */ + +export * from './header.page'; diff --git a/lib/testing/src/lib/core/public-api.ts b/lib/testing/src/lib/core/public-api.ts new file mode 100644 index 0000000000..58347a10f2 --- /dev/null +++ b/lib/testing/src/lib/core/public-api.ts @@ -0,0 +1,6 @@ +/* + * Public API Surface of testing + */ + +export * from './browser-visibility'; +export * from './pages/public-api'; diff --git a/lib/testing/src/lib/process-services/pages/form-fields.page.ts b/lib/testing/src/lib/process-services/pages/form-fields.page.ts new file mode 100644 index 0000000000..f259e7aed9 --- /dev/null +++ b/lib/testing/src/lib/process-services/pages/form-fields.page.ts @@ -0,0 +1,169 @@ +/*! + * @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. + */ + +import { BrowserVisibility } from '../../core/browser-visibility'; +import { by, element } from 'protractor'; + +export class FormFieldsPage { + + formContent = element(by.css('adf-form')); + refreshButton = element(by.css('div[class*="form-reload-button"] mat-icon')); + saveButton = element(by.cssContainingText('mat-card-actions[class*="adf-for"] span', 'SAVE')); + valueLocator = by.css('input'); + labelLocator = by.css('label'); + noFormMessage = element(by.css('span[id*="no-form-message"]')); + completedTaskNoFormMessage = element(by.css('div[id*="completed-form-message"] p')); + attachFormButton = element(by.id('adf-no-form-attach-form-button')); + selectFormDropDownArrow = element.all(by.css('adf-attach-form div[class*="mat-select-arrow"]')).first(); + selectFormContent = element(by.css('div[class*="mat-select-panel"]')); + completeButton = element(by.id('adf-form-complete')); + errorMessage = by.css('.adf-error-text-container .adf-error-text'); + + setFieldValue(locator, field, value) { + let fieldElement: any = element(locator(field)); + BrowserVisibility.waitUntilElementIsVisible(fieldElement); + fieldElement.clear().sendKeys(value); + return this; + } + + checkWidgetIsVisible(fieldId) { + let fieldElement = element.all(by.css(`adf-form-field div[id='field-${fieldId}-container']`)).first(); + BrowserVisibility.waitUntilElementIsVisible(fieldElement); + } + + checkWidgetIsHidden(fieldId) { + let hiddenElement = element(by.css(`adf-form-field div[id='field-${fieldId}-container'][hidden]`)); + BrowserVisibility.waitUntilElementIsVisible(hiddenElement); + } + + getWidget(fieldId) { + let widget = element(by.css(`adf-form-field div[id='field-${fieldId}-container']`)); + BrowserVisibility.waitUntilElementIsVisible(widget); + return widget; + } + + getFieldValue(fieldId, valueLocatorParam) { + let value = this.getWidget(fieldId).element(valueLocatorParam || this.valueLocator); + BrowserVisibility.waitUntilElementIsVisible(value); + return value.getAttribute('value'); + } + + getFieldLabel(fieldId, labelLocatorParam) { + let label = this.getWidget(fieldId).all(labelLocatorParam || this.labelLocator).first(); + BrowserVisibility.waitUntilElementIsVisible(label); + return label.getText(); + } + + getFieldErrorMessage(fieldId) { + let error = this.getWidget(fieldId).element(this.errorMessage); + return error.getText(); + } + + getFieldText(fieldId, labelLocatorParam) { + let label = this.getWidget(fieldId).element(labelLocatorParam || this.labelLocator); + BrowserVisibility.waitUntilElementIsVisible(label); + return label.getText(); + } + + getFieldPlaceHolder(fieldId, locator = 'input') { + let placeHolderLocator = element(by.css(`${locator}#${fieldId}`)).getAttribute('placeholder'); + BrowserVisibility.waitUntilElementIsVisible(placeHolderLocator); + return placeHolderLocator; + } + + checkFieldValue(locator, field, val) { + BrowserVisibility.waitUntilElementHasValue(element(locator(field)), val); + return this; + } + + refreshForm() { + BrowserVisibility.waitUntilElementIsVisible(this.refreshButton); + this.refreshButton.click(); + return this; + } + + saveForm() { + BrowserVisibility.waitUntilElementIsVisible(this.saveButton); + BrowserVisibility.waitUntilElementIsClickable(this.saveButton); + this.saveButton.click(); + return this; + } + + noFormIsDisplayed() { + BrowserVisibility.waitUntilElementIsNotOnPage(this.formContent); + return this; + } + + checkFormIsDisplayed() { + BrowserVisibility.waitUntilElementIsVisible(this.formContent); + return this; + } + + getNoFormMessage() { + BrowserVisibility.waitUntilElementIsVisible(this.noFormMessage); + return this.noFormMessage.getText(); + } + + getCompletedTaskNoFormMessage() { + BrowserVisibility.waitUntilElementIsVisible(this.completedTaskNoFormMessage); + return this.completedTaskNoFormMessage.getText(); + } + + clickOnAttachFormButton() { + BrowserVisibility.waitUntilElementIsVisible(this.attachFormButton); + this.attachFormButton.click(); + return this; + } + + selectForm(formName) { + BrowserVisibility.waitUntilElementIsVisible(this.selectFormDropDownArrow); + this.selectFormDropDownArrow.click(); + BrowserVisibility.waitUntilElementIsVisible(this.selectFormContent); + this.selectFormFromDropDown(formName); + return this; + } + + selectFormFromDropDown(formName) { + let formNameElement = element(by.cssContainingText('span', formName)); + BrowserVisibility.waitUntilElementIsVisible(formNameElement); + formNameElement.click(); + } + + checkWidgetIsReadOnlyMode(fieldId) { + let widget = element(by.css(`adf-form-field div[id='field-${fieldId}-container']`)); + let widgetReadOnly = widget.element(by.css('div[class*="adf-readonly"]')); + BrowserVisibility.waitUntilElementIsVisible(widgetReadOnly); + return widgetReadOnly; + } + + completeForm() { + BrowserVisibility.waitUntilElementIsVisible(this.completeButton); + return this.completeButton.click(); + } + + setValueInInputById(fieldId, value) { + let input: any = element(by.id(fieldId)); + BrowserVisibility.waitUntilElementIsVisible(input); + input.clear().sendKeys(value); + return this; + } + + isCompleteFormButtonDisabled() { + BrowserVisibility.waitUntilElementIsVisible(this.completeButton); + return this.completeButton.getAttribute('disabled'); + } +} diff --git a/lib/testing/src/lib/process-services/pages/public-api.ts b/lib/testing/src/lib/process-services/pages/public-api.ts new file mode 100644 index 0000000000..0c89dd2d2c --- /dev/null +++ b/lib/testing/src/lib/process-services/pages/public-api.ts @@ -0,0 +1,5 @@ +/* + * Public API Surface of testing + */ + +export * from './form-fields.page'; diff --git a/lib/testing/src/lib/process-services/public-api.ts b/lib/testing/src/lib/process-services/public-api.ts new file mode 100644 index 0000000000..261612cbe7 --- /dev/null +++ b/lib/testing/src/lib/process-services/public-api.ts @@ -0,0 +1,5 @@ +/* + * Public API Surface of testing + */ + +export * from './pages/public-api'; diff --git a/lib/testing/src/lib/testing.module.ts b/lib/testing/src/lib/testing.module.ts new file mode 100644 index 0000000000..3129b50512 --- /dev/null +++ b/lib/testing/src/lib/testing.module.ts @@ -0,0 +1,9 @@ +import { NgModule } from '@angular/core'; + +@NgModule({ + declarations: [], + imports: [ + ], + exports: [] +}) +export class TestingModule { } diff --git a/lib/testing/src/lib/testing.service.spec.ts b/lib/testing/src/lib/testing.service.spec.ts new file mode 100644 index 0000000000..e2a2990f79 --- /dev/null +++ b/lib/testing/src/lib/testing.service.spec.ts @@ -0,0 +1,12 @@ +import { TestBed } from '@angular/core/testing'; + +import { TestingService } from './testing.service'; + +describe('TestingService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: TestingService = TestBed.get(TestingService); + expect(service).toBeTruthy(); + }); +}); diff --git a/lib/testing/src/lib/testing.service.ts b/lib/testing/src/lib/testing.service.ts new file mode 100644 index 0000000000..4fc1dd6233 --- /dev/null +++ b/lib/testing/src/lib/testing.service.ts @@ -0,0 +1,10 @@ +import { Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root' +}) +export class TestingService { + + constructor() { } + +} diff --git a/lib/testing/src/public-api.ts b/lib/testing/src/public-api.ts new file mode 100644 index 0000000000..f064dd3d68 --- /dev/null +++ b/lib/testing/src/public-api.ts @@ -0,0 +1,8 @@ +/* + * Public API Surface of testing + */ + +export * from './lib/core/public-api'; +export * from './lib/content-services/public-api'; +export * from './lib/process-services/public-api'; +export * from './lib/testing.module'; diff --git a/lib/testing/src/test.ts b/lib/testing/src/test.ts new file mode 100644 index 0000000000..e11ff1c97b --- /dev/null +++ b/lib/testing/src/test.ts @@ -0,0 +1,22 @@ +// This file is required by karma.conf.js and loads recursively all the .spec and framework files + +import 'core-js/es7/reflect'; +import 'zone.js/dist/zone'; +import 'zone.js/dist/zone-testing'; +import { getTestBed } from '@angular/core/testing'; +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting +} from '@angular/platform-browser-dynamic/testing'; + +declare const require: any; + +// First, initialize the Angular testing environment. +getTestBed().initTestEnvironment( + BrowserDynamicTestingModule, + platformBrowserDynamicTesting() +); +// Then we find all the tests. +const context = require.context('./', true, /\.spec\.ts$/); +// And load the modules. +context.keys().map(context); diff --git a/lib/testing/tsconfig.lib.json b/lib/testing/tsconfig.lib.json new file mode 100644 index 0000000000..3fe337fcf5 --- /dev/null +++ b/lib/testing/tsconfig.lib.json @@ -0,0 +1,32 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "../../out-tsc/lib", + "target": "es2015", + "module": "es2015", + "moduleResolution": "node", + "declaration": true, + "sourceMap": true, + "inlineSources": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "importHelpers": true, + "types": [], + "lib": [ + "dom", + "es2018" + ] + }, + "angularCompilerOptions": { + "annotateForClosureCompiler": true, + "skipTemplateCodegen": true, + "strictMetadataEmit": true, + "fullTemplateTypeCheck": true, + "strictInjectionParameters": true, + "enableResourceInlining": true + }, + "exclude": [ + "src/test.ts", + "**/*.spec.ts" + ] +} diff --git a/lib/testing/tsconfig.spec.json b/lib/testing/tsconfig.spec.json new file mode 100644 index 0000000000..16da33db07 --- /dev/null +++ b/lib/testing/tsconfig.spec.json @@ -0,0 +1,17 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "../../out-tsc/spec", + "types": [ + "jasmine", + "node" + ] + }, + "files": [ + "src/test.ts" + ], + "include": [ + "**/*.spec.ts", + "**/*.d.ts" + ] +} diff --git a/lib/testing/tslint.json b/lib/testing/tslint.json new file mode 100644 index 0000000000..124133f849 --- /dev/null +++ b/lib/testing/tslint.json @@ -0,0 +1,17 @@ +{ + "extends": "../../tslint.json", + "rules": { + "directive-selector": [ + true, + "attribute", + "lib", + "camelCase" + ], + "component-selector": [ + true, + "element", + "lib", + "kebab-case" + ] + } +} diff --git a/lib/tsconfig.json b/lib/tsconfig.json index 29ba508103..ae00dc34f5 100644 --- a/lib/tsconfig.json +++ b/lib/tsconfig.json @@ -22,6 +22,7 @@ "allowSyntheticDefaultImports": true, "paths": { "@alfresco/adf-process-services-cloud": ["./process-services-cloud/"], + "@alfresco/adf-testing": ["./testing/"], "@alfresco/adf-process-services": ["./process-services/"], "@alfresco/adf-content-services": ["./content-services/"], "@alfresco/adf-extensions": ["./extensions/"], diff --git a/nx.json b/nx.json index c09678e78d..1b037cd18a 100644 --- a/nx.json +++ b/nx.json @@ -34,6 +34,9 @@ }, "extensions": { "tags": [] + }, + "testing": { + "tags": [] } } } diff --git a/scripts/build-testing.sh b/scripts/build-testing.sh new file mode 100755 index 0000000000..3afa9b3fe6 --- /dev/null +++ b/scripts/build-testing.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +cd $DIR/.. + +echo "====== Testing ======" +echo "====== Build ======" +npm run ng-packagr -- -p ./lib/testing/ || exit 1 + +echo "====== Move to node_modules ======" +rm -rf ./node_modules/@alfresco/adf-testing/ && \ +mkdir -p ./node_modules/@alfresco/adf-testing/ && \ +cp -R ./lib/dist/testing/* ./node_modules/@alfresco/adf-testing/ diff --git a/scripts/npm-move-tag.sh b/scripts/npm-move-tag.sh index 25b7989a27..4b9f877a1a 100644 --- a/scripts/npm-move-tag.sh +++ b/scripts/npm-move-tag.sh @@ -7,6 +7,7 @@ eval projects=( "@alfresco/adf-core" "@alfresco/adf-insights" "@alfresco/adf-process-services" "@alfresco/adf-process-services-cloud" + "@alfresco/adf-testing" "@alfresco/adf-extensions" ) show_help() { diff --git a/scripts/test-dist.sh b/scripts/test-dist.sh index ba0cd67cf2..52909d5a04 100755 --- a/scripts/test-dist.sh +++ b/scripts/test-dist.sh @@ -43,6 +43,7 @@ mkdir -p $DIR/../node_modules/@alfresco/adf-core mkdir -p $DIR/../node_modules/@alfresco/adf-content-services mkdir -p $DIR/../node_modules/@alfresco/adf-process-services mkdir -p $DIR/../node_modules/@alfresco/adf-process-services-cloud +mkdir -p $DIR/../node_modules/@alfresco/adf-testing mkdir -p $DIR/../node_modules/@alfresco/adf-insights mkdir -p $DIR/../node_modules/@alfresco/adf-extensions @@ -50,6 +51,7 @@ cp -R $DIR/../lib/dist/core/* $DIR/../node_modules/@alfresco/adf-core cp -R $DIR/../lib/dist/content-services/* $DIR/../node_modules/@alfresco/adf-content-services cp -R $DIR/../lib/dist/process-services/* $DIR/../node_modules/@alfresco/adf-process-services cp -R $DIR/../lib/dist/process-services-cloud/* $DIR/../node_modules/@alfresco/adf-process-services-cloud +cp -R $DIR/../lib/dist/process-services-cloud/* $DIR/../node_modules/@alfresco/adf-testing cp -R $DIR/../lib/dist/insights/* $DIR/../node_modules/@alfresco/adf-insights cp -R $DIR/../lib/dist/extensions/* $DIR/../node_modules/@alfresco/adf-extensions diff --git a/tsconfig.json b/tsconfig.json index ba46113e45..b8e393d5a5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -18,7 +18,15 @@ "lib": [ "es2018", "dom" - ] + ], + "paths": { + "testing": [ + "dist/testing" + ], + "testing/*": [ + "dist/testing/*" + ] + } }, "exclude": [ "lib/config", @@ -28,4 +36,4 @@ "tools", "node_modules" ] -} +} \ No newline at end of file