From fcaa033a57578097a3d957e6961080bafff5b2e3 Mon Sep 17 00:00:00 2001 From: Eugenio Romano Date: Wed, 11 Jul 2018 23:00:27 +0100 Subject: [PATCH] [ADF-3330] Create automated tests for Uploader component (#3581) * Upload button e2e * improve test organization * add dev option in test run * Create desktop.ini * upload component automation final step * remove fdescribe * ignore downloads folder * exclude pagination --- .gitignore | 1 + .travis.yml | 2 +- .../app/components/files/files.component.html | 2 +- e2e/actions/drop.actions.ts | 84 ++++ e2e/data-table-component-selection.e2e.ts | 2 +- e2e/data-table-component.e2e.ts | 2 +- e2e/document_list_component.e2e.ts | 2 +- e2e/document_list_pagination.e2e.ts | 4 +- e2e/login_component.e2e.ts | 2 +- e2e/pages/adf/activiti/appsPage.js | 382 ------------------ e2e/pages/adf/contentServicesPage.js | 63 +-- e2e/pages/adf/dialog/contentList.js | 2 +- e2e/pages/adf/dialog/uploadDialog.js | 6 + e2e/pages/adf/dialog/uploadToggles.js | 5 + e2e/pages/adf/loginPage.js | 113 +++--- e2e/pages/adf/notificationPage.js | 28 ++ ...ination_processlist_addingProcesses.e2e.ts | 2 +- e2e/processlist_pagination.e2e.ts | 2 +- e2e/resources/adf/allFileTypes/desktop.ini | 1 + e2e/resources/adf/folderExcluded/a_file.txt | 0 e2e/resources/adf/folderTwo/a_file.txt | 0 e2e/search_component.e2e.ts | 2 +- e2e/search_page_component.e2e.ts | 2 +- e2e/theming_component.e2e.ts | 2 +- e2e/upload/excluded_file.e2e.ts | 109 +++++ e2e/{ => upload}/uploader_component.e2e.ts | 111 +++-- e2e/upload/user_permission.e2e.ts | 249 ++++++++++++ e2e/user_info_component.e2e.ts | 2 +- e2e/util/resources.js | 17 +- e2e/viewer_content_services_component.e2e.ts | 2 +- protractor.conf.js | 2 +- scripts/README.md | 1 + scripts/test-e2e-lib.sh | 36 +- 33 files changed, 726 insertions(+), 514 deletions(-) create mode 100644 e2e/actions/drop.actions.ts delete mode 100644 e2e/pages/adf/activiti/appsPage.js create mode 100644 e2e/pages/adf/notificationPage.js create mode 100644 e2e/resources/adf/allFileTypes/desktop.ini create mode 100644 e2e/resources/adf/folderExcluded/a_file.txt create mode 100644 e2e/resources/adf/folderTwo/a_file.txt create mode 100644 e2e/upload/excluded_file.e2e.ts rename e2e/{ => upload}/uploader_component.e2e.ts (77%) create mode 100644 e2e/upload/user_permission.e2e.ts diff --git a/.gitignore b/.gitignore index e54d6df3e0..d0cff6e218 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ workspace.xml .idea/ dist/ e2e-output/ +e2e/downloads/ ng2-components/coverage/ !systemjs.config.js demo-shell-ng2/app/components/router/ diff --git a/.travis.yml b/.travis.yml index 4c069c96b8..3514157460 100644 --- a/.travis.yml +++ b/.travis.yml @@ -87,7 +87,7 @@ jobs: if: tag =~ .*beta.* script: ./scripts/update-project.sh -gnu -t $GITHUB_TOKEN -n alfresco-modeler-app - stage: e2e Test - script: ./scripts/test-e2e-lib.sh -host localhost:4200 -proxy $E2E_HOST -u $E2E_USERNAME -p $E2E_PASSWORD -e $E2E_EMAIL -save + script: ./scripts/test-e2e-lib.sh -host localhost:4200 -proxy $E2E_HOST -u $E2E_USERNAME -p $E2E_PASSWORD -e $E2E_EMAIL -b -save -dev - stage: Deploy PR script: node ./scripts/pr-deploy.js -n $TRAVIS_BUILD_NUMBER -u $RANCHER_TOKEN -p $RANCHER_SECRET -s $REPO_RANCHER --image "docker:$REPO_DOCKER/adf/demo-shell:$TRAVIS_BUILD_NUMBER" --env $ENVIRONMENT_NAME -r $ENVIRONMENT_URL || exit 1 diff --git a/demo-shell/src/app/components/files/files.component.html b/demo-shell/src/app/components/files/files.component.html index 00fdc41e8b..2506dac4ae 100644 --- a/demo-shell/src/app/components/files/files.component.html +++ b/demo-shell/src/app/components/files/files.component.html @@ -572,7 +572,7 @@
- + {{'DOCUMENT_LIST.DESCRIPTION_UPLOAD' | translate}}
diff --git a/e2e/actions/drop.actions.ts b/e2e/actions/drop.actions.ts new file mode 100644 index 0000000000..fb8db8f81e --- /dev/null +++ b/e2e/actions/drop.actions.ts @@ -0,0 +1,84 @@ +import fs = require('fs'); +import path = require('path'); +import TestConfig = require('../test.config'); + +let JS_BIND_INPUT = function (target) { + let input = document.createElement('input'); + input.type = 'file'; + input.style.display = 'none'; + input.addEventListener('change', function (event) { + target.scrollIntoView(true); + + let rect = target.getBoundingClientRect(); + let x = rect.left + (rect.width >> 1); + let y = rect.top + (rect.height >> 1); + let data = { files: input.files }; + + ['dragenter', 'dragover', 'drop'].forEach(function (name) { + let mouseEvent = document.createEvent('MouseEvent'); + mouseEvent.initMouseEvent(name, !0, !0, window, 0, 0, 0, x, y, !1, !1, !1, !1, 0, null); + mouseEvent.dataTransfer = data; + target.dispatchEvent(mouseEvent); + }); + + document.body.removeChild(input); + }, false); + + document.body.appendChild(input); + return input; +}; + +let JS_BIND_INPUT_FOLDER = function (target) { + let input = document.createElement('input'); + input.type = 'file'; + input.style.display = 'none'; + input.multiple = 'multiple'; + input.webkitdirectory = true; + input.addEventListener('change', function (event) { + target.scrollIntoView(true); + + let rect = target.getBoundingClientRect(); + let x = rect.left + (rect.width >> 1); + let y = rect.top + (rect.height >> 1); + let data = { files: input.files }; + + ['dragenter', 'dragover', 'drop'].forEach(function (name) { + let mouseEvent = document.createEvent('MouseEvent'); + mouseEvent.initMouseEvent(name, !0, !0, window, 0, 0, 0, x, y, !1, !1, !1, !1, 0, null); + mouseEvent.dataTransfer = data; + target.dispatchEvent(mouseEvent); + }); + + document.body.removeChild(input); + }, false); + + document.body.appendChild(input); + return input; +}; + +export class DropActions { + + dropFile(dropArea, filePath) { + let absolutePath = path.resolve(path.join(TestConfig.main.rootPath, filePath)); + + fs.accessSync(absolutePath, fs.F_OK); + return dropArea.getWebElement().then((element) => { + browser.executeScript(JS_BIND_INPUT, element).then((input) => { + input.sendKeys(absolutePath); + + }); + }); + } + + dropFolder(dropArea, folderPath) { + let absolutePath = path.resolve(path.join(TestConfig.main.rootPath, folderPath)); + fs.accessSync(absolutePath, fs.F_OK); + + return dropArea.getWebElement().then((element) => { + browser.executeScript(JS_BIND_INPUT_FOLDER, element).then((input) => { + input.sendKeys(absolutePath); + + }); + }); + } +} diff --git a/e2e/data-table-component-selection.e2e.ts b/e2e/data-table-component-selection.e2e.ts index f8225c7304..4e881d99c4 100644 --- a/e2e/data-table-component-selection.e2e.ts +++ b/e2e/data-table-component-selection.e2e.ts @@ -22,7 +22,7 @@ import TestConfig = require('./test.config'); import AcsUserModel = require('./models/ACS/acsUserModel'); import AlfrescoApi = require('alfresco-js-api-node'); -describe('Test Datatable component - selection', () => { +describe('Datatable component - selection', () => { let dataTablePage = new DataTablePage(); let loginPage = new LoginPage(); diff --git a/e2e/data-table-component.e2e.ts b/e2e/data-table-component.e2e.ts index 07f2180809..2fb099dfee 100644 --- a/e2e/data-table-component.e2e.ts +++ b/e2e/data-table-component.e2e.ts @@ -22,7 +22,7 @@ import TestConfig = require('./test.config.js'); import AlfrescoApi = require('alfresco-js-api-node'); -describe('Test Datatable component', () => { +describe('Datatable component', () => { let dataTablePage = new DataTablePage(); let loginPage = new LoginPage(); diff --git a/e2e/document_list_component.e2e.ts b/e2e/document_list_component.e2e.ts index 334b3164ca..1a7f737d48 100644 --- a/e2e/document_list_component.e2e.ts +++ b/e2e/document_list_component.e2e.ts @@ -29,7 +29,7 @@ import Util = require('./util/util'); import AlfrescoApi = require('alfresco-js-api-node'); import { UploadActions } from './actions/ACS/upload.actions'; -describe('Test DocumentList component', () => { +describe('DocumentList component', () => { let loginPage = new LoginPage(); let contentServicesPage = new ContentServicesPage(); diff --git a/e2e/document_list_pagination.e2e.ts b/e2e/document_list_pagination.e2e.ts index 9e49ffc165..c327e7c5da 100644 --- a/e2e/document_list_pagination.e2e.ts +++ b/e2e/document_list_pagination.e2e.ts @@ -29,7 +29,7 @@ import Util = require('./util/util'); import AlfrescoApi = require('alfresco-js-api-node'); import { UploadActions } from './actions/ACS/upload.actions'; -describe('Test Document List - Pagination', function () { +describe('Document List - Pagination', function () { let pagination = { base: 'newFile', secondSetBase: 'secondSet', @@ -256,7 +256,7 @@ describe('Test Document List - Pagination', function () { expect(paginationPage.getCurrentItemsPerPage()).toEqual(itemsPerPage.fifteen); }); - it('[C91320] Pagination when the content is sorted', function () { + xit('[C91320] Pagination when the content is sorted', function () { contentServicesPage.goToDocumentList(); contentServicesPage.navigateToFolder(newFolderModel.name); contentServicesPage.checkAcsContainer(); diff --git a/e2e/login_component.e2e.ts b/e2e/login_component.e2e.ts index 5c1c341623..c171fdacdb 100644 --- a/e2e/login_component.e2e.ts +++ b/e2e/login_component.e2e.ts @@ -25,7 +25,7 @@ import AcsUserModel = require('./models/ACS/acsUserModel'); import AdfSettingsPage = require('./pages/adf/settingsPage'); -describe('Test Login component', () => { +describe('Login component', () => { let adfSettingsPage = new AdfSettingsPage(); let processServicesPage = new ProcessServicesPage(); diff --git a/e2e/pages/adf/activiti/appsPage.js b/e2e/pages/adf/activiti/appsPage.js deleted file mode 100644 index 58f8c37fae..0000000000 --- a/e2e/pages/adf/activiti/appsPage.js +++ /dev/null @@ -1,382 +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. - */ - -var Page = require('astrolabe').Page; -var Util = require('../../../util/util'); - -/** - * Provides activiti - * @module pages - * @submodule share - * @class pages.share.LoginPage - */ -module.exports = Page.create({ - - /** - * Provides the task App - * @property taskApp - * @type protractor.Element - */ - taskApp: { - get: function () { - return element(by.cssContainingText("h1[class*='mdl-card__title-text']", "Task App")); - } - }, - - /** - * clicks the activiti option - * @property clickActiviti - * */ - clickActiviti: { - value: function() { - var activitiButton = element(by.css("a[data-automation-id='activiti']")); - Util.waitUntilElementIsVisible(activitiButton); - activitiButton.click(); - } - }, - - /** - * Provides the wait required for the page - * @property waitForElements - * @type protractor.Element - * */ - waitForElements: { - value: function () { - Util.waitUntilElementIsVisible(this.taskApp); - Util.waitUntilElementIsVisible(element(by.css("i[class='material-icons']"))); - } - }, - - /** - * Fills the username input - * @method enterUsername - * @param {String} username - */ - enterUsername: { - value: function (username) { - Util.waitUntilElementIsVisible(this.txtUsername); - this.txtUsername.clear(); - this.txtUsername.sendKeys(username); - } - }, - - /** - * Fills the password input - * @method enterPassword - * @param {String} password - */ - enterPassword: { - value: function (password) { - Util.waitUntilElementIsVisible(this.txtPassword); - this.txtPassword.clear(); - this.txtPassword.sendKeys(password); - } - }, - - /** - * Logs into adf - * @method login - * @param {String} username, {String} password - */ - login: { - value: function (username, password) { - this.waitForElements(); - this.enterUsername(username); - this.enterPassword(password); - Util.waitUntilElementIsVisible(element(by.css("ol[data-automation-id='breadcrumb']"))); - } - }, - - /** - * Logs out - * @method logout - */ - logout: { - value: function () { - var menuButton = element(by.css("button[data-automation-id='right-action-menu']")); - var logoutOption = element(by.cssContainingText("li[class*='mdl-menu__item'] > label", "Logout")); - - Util.waitUntilElementIsVisible(menuButton); - menuButton.click(); - Util.waitUntilElementIsVisible(logoutOption); - logoutOption.click(); - this.waitForElements(); - } - }, - - - - /** - * Enable ECM - * @method enableECM - */ - enableECM: { - value: function () { - Util.waitUntilElementIsVisible(this.ecmSwitch); - this.ecmSwitch.click(); - Util.waitUntilElementIsVisible(element(by.css("label[class*='is-checked'][for='switch1']"))); - - element(by.css("label[class*='is-checked'][for='switch2']")).isPresent().then(function(check) { - if(check) { - Util.waitUntilElementIsVisible(element(by.css("alfresco-login[ng-reflect-providers*='ALL']"))); - } - else { - Util.waitUntilElementIsVisible(element(by.css("alfresco-login[ng-reflect-providers='ECM']"))); - } - }); - } - }, - - /** - * Disable ECM - * @method enableECM - */ - disableECM: { - value: function () { - Util.waitUntilElementIsVisible(this.ecmSwitch); - this.ecmSwitch.click(); - - element(by.css("label[class*='is-checked'][for='switch2']")).isPresent().then(function(check) { - if(check) { - Util.waitUntilElementIsVisible(element(by.css("alfresco-login[ng-reflect-providers*='BPM']"))); - } - else { - Util.waitUntilElementIsVisible(element(by.css("alfresco-login[ng-reflect-providers='']"))); - } - }); - } - }, - - /** - * Enable BPM - * @method enableBPM - */ - enableBPM: { - value: function () { - Util.waitUntilElementIsVisible(this.bpmSwitch); - this.bpmSwitch.click(); - Util.waitUntilElementIsVisible(element(by.css("label[class*='is-checked'][for='switch2']"))); - - element(by.css("label[class*='is-checked'][for='switch1']")).isPresent().then(function(check) { - if(check) { - Util.waitUntilElementIsVisible(element(by.css("alfresco-login[ng-reflect-providers*='ALL']"))); - } - else { - Util.waitUntilElementIsVisible(element(by.css("alfresco-login[ng-reflect-providers='BPM']"))); - } - }); - } - }, - - /** - * Disable BPM - * @method enableBPM - */ - disableBPM: { - value: function () { - Util.waitUntilElementIsVisible(this.bpmSwitch); - this.bpmSwitch.click(); - - element(by.css("label[class*='is-checked'][for='switch1']")).isPresent().then(function(check) { - if(check) { - Util.waitUntilElementIsVisible(element(by.css("alfresco-login[ng-reflect-providers*='ECM']"))); - } - else { - Util.waitUntilElementIsVisible(element(by.css("alfresco-login[ng-reflect-providers='']"))); - } - }); - } - }, - - /** - * Enable CSRF - * @method enableBPM - */ - enableCSRF: { - value: function () { - Util.waitUntilElementIsVisible(this.csrfSwitch); - this.csrfSwitch.click(); - Util.waitUntilElementIsVisible(element(by.css("label[class*='is-checked'][for='switch3']"))); - } - }, - - /** - * Disable BPM - * @method enableBPM - */ - disableBPM: { - value: function () { - Util.waitUntilElementIsVisible(this.bpmSwitch); - this.bpmSwitch.click(); - Util.waitUntilElementIsVisible(element(by.css("alfresco-login[ng-reflect-disable-csrf='true']"))); - - } - }, - - /** - * clears the username input - * @method clearUsername - */ - clearUsername: { - value: function () { - Util.waitUntilElementIsVisible(this.txtUsername); - this.txtUsername.clear(); - } - }, - - /** - * Check username tooltip - * @method checkUsernameTooltip - * @param {String} message - */ - checkUsernameTooltip: { - value: function (message) { - Util.waitUntilElementIsPresent(element(by.css("span[data-automation-id='username-error']"))); - Util.waitUntilElementIsPresent(element(by.cssContainingText("span[data-automation-id='username-error']"), message)); - } - }, - - /** - * Check username tooltip not visible - * @method checkUsernameTooltipNotVisible - */ - checkUsernameTooltipNotVisible: { - value: function () { - var error = "span[data-automation-id='username-error']"; - Util.waitUntilElementIsNotVisible(element(by.css(error))); - } - }, - - /** - * Check sign in button disabled - * @method checkSignInButtonIsDisabled - */ - checkSignInButtonIsDisabled: { - value: function () { - Util.waitUntilElementIsVisible(element(by.css("button[data-automation-id='login-button'][ng-reflect-disabled='true']"))); - } - }, - - /** - * Check sign in button enabled - * @method checkSignInButtonIsEnabled - */ - checkSignInButtonIsEnabled: { - value: function () { - Util.waitUntilElementIsNotVisible(element(by.css("button[data-automation-id='login-button'][ng-reflect-disabled='true']"))); - } - }, - - /** - * Click sign in button - * @method clickSignInButton - */ - clickSignInButton: { - value: function () { - Util.waitUntilElementIsVisible(this.signInButton); - this.signInButton.click(); - } - }, - - /** - * Check login error - * @method checkLoginError - * * @param {String} message - */ - checkLoginError: { - value: function (message) { - Util.waitUntilElementIsVisible(element(by.cssContainingText("div[data-automation-id='login-error']", message))); - } - }, - - /** - * Check password is hidden - * @method checkPasswordIsHidden - */ - checkPasswordIsHidden: { - value: function () { - Util.waitUntilElementIsVisible(element(by.css("input[data-automation-id='password'][type='password']"))); - } - }, - - /** - * Click show password - * @method showPassword - */ - showPassword: { - value: function () { - Util.waitUntilElementIsVisible(element(by.css("i[data-automation-id='show_password']"))); - element(by.css("i[data-automation-id='show_password']")).click(); - } - }, - - /** - * Click hide password - * @method hidePassword - */ - hidePassword: { - value: function () { - Util.waitUntilElementIsVisible(element(by.css("i[data-automation-id='hide_password']"))); - element(by.css("i[data-automation-id='hide_password']")).click(); - } - }, - - /** - * Check password is shown - * @method checkPasswordIsShown - * @param {String} password - */ - checkPasswordIsShown: { - value: function (password) { - var passwordText = element(by.css("input[data-automation-id='password']")); - - passwordText.getAttribute('value').then(function (text) { - expect(passwordText.getAttribute('value')).toEqual(password); - }); - } - }, - - /** - * Check 'Remember' is displayed - * @method checkRememberIsDisplayed - */ - checkRememberIsDisplayed: { - value: function () { - Util.waitUntilElementIsVisible(element(by.css("span[id='login-remember']"))); - } - }, - - /** - * Check 'Need Help' is displayed - * @method checkNeedHelpIsDisplayed - */ - checkNeedHelpIsDisplayed: { - value: function () { - Util.waitUntilElementIsVisible(element(by.css("div[id='login-action-help']"))); - } - }, - - /** - * Check 'Register' is displayed - * @method checkRegisterDisplayed - */ - checkRegisterDisplayed: { - value: function () { - Util.waitUntilElementIsVisible(element(by.css("div[id='login-action-register']"))); - } - }, -}); diff --git a/e2e/pages/adf/contentServicesPage.js b/e2e/pages/adf/contentServicesPage.js index a62323a2ca..d44e756e67 100644 --- a/e2e/pages/adf/contentServicesPage.js +++ b/e2e/pages/adf/contentServicesPage.js @@ -21,7 +21,7 @@ var CreateFolderDialog = require('./dialog/createFolderDialog'); var path = require('path'); var TestConfig = require('../../test.config'); -var ContentServicesPage = function (){ +var ContentServicesPage = function () { var contentList = new ContentList(); var createFolderDialog = new CreateFolderDialog(); @@ -40,17 +40,18 @@ var ContentServicesPage = function (){ var contentServicesURL = TestConfig.adf.url + TestConfig.adf.port + "/files"; var loadMoreButton = element(by.css("button[data-automation-id='adf-infinite-pagination-button']")); var emptyPagination = element(by.css("adf-pagination[class*='adf-pagination__empty']")); + var dragAndDrop = element(by.css("adf-upload-drag-area div")); /** * Check Document List is displayed * @method checkAcsContainer */ - this.checkAcsContainer = function (){ + this.checkAcsContainer = function () { Util.waitUntilElementIsVisible(uploadBorder); return this; }; - this.waitForTableBody = function (){ + this.waitForTableBody = function () { Util.waitUntilElementIsVisible(tableBody); }; @@ -58,14 +59,14 @@ var ContentServicesPage = function (){ * Go to Document List Page * @method goToDocumentList * */ - this.goToDocumentList = function() { + this.goToDocumentList = function () { Util.waitUntilElementIsVisible(contentServices); Util.waitUntilElementIsClickable(contentServices); contentServices.click(); this.checkAcsContainer(); }; - this.navigateToDocumentList = function() { + this.navigateToDocumentList = function () { browser.driver.get(contentServicesURL); this.checkAcsContainer(); }; @@ -74,7 +75,7 @@ var ContentServicesPage = function (){ return contentList.getAllDisplayedRows(); }; - this.currentFolderName = function() { + this.currentFolderName = function () { var deferred = protractor.promise.defer(); Util.waitUntilElementIsVisible(currentFolder); currentFolder.getText().then(function (result) { @@ -88,7 +89,7 @@ var ContentServicesPage = function (){ }; this.getBreadcrumbTooltip = function (content) { - return element(by.css("nav[data-automation-id='breadcrumb'] div[title='" +content +"']")).getAttribute('title'); + return element(by.css("nav[data-automation-id='breadcrumb'] div[title='" + content + "']")).getAttribute('title'); }; this.getAllRowsNameColumn = function () { @@ -130,7 +131,7 @@ var ContentServicesPage = function (){ this.sortAndCheckListIsOrderedByName = function (sortOrder) { this.sortByName(sortOrder); var deferred = protractor.promise.defer(); - contentList.checkListIsOrderedByNameColumn(sortOrder).then(function(result) { + contentList.checkListIsOrderedByNameColumn(sortOrder).then(function (result) { deferred.fulfill(result); }); return deferred.promise; @@ -145,7 +146,7 @@ var ContentServicesPage = function (){ this.sortAndCheckListIsOrderedByAuthor = function (sortOrder) { this.sortByAuthor(sortOrder); var deferred = protractor.promise.defer(); - contentList.checkListIsOrderedByAuthorColumn(sortOrder).then(function(result) { + contentList.checkListIsOrderedByAuthorColumn(sortOrder).then(function (result) { deferred.fulfill(result); }); return deferred.promise; @@ -160,7 +161,7 @@ var ContentServicesPage = function (){ this.sortAndCheckListIsOrderedByCreated = function (sortOrder) { this.sortByCreated(sortOrder); var deferred = protractor.promise.defer(); - contentList.checkListIsOrderedByCreatedColumn(sortOrder).then(function(result) { + contentList.checkListIsOrderedByCreatedColumn(sortOrder).then(function (result) { deferred.fulfill(result); }); return deferred.promise; @@ -195,7 +196,7 @@ var ContentServicesPage = function (){ }; this.checkContentsAreDisplayed = function (content) { - for( i=0; i < content.length; i++) { + for (i = 0; i < content.length; i++) { this.checkContentIsDisplayed(content[i]); } return this; @@ -207,7 +208,7 @@ var ContentServicesPage = function (){ }; this.checkContentsAreNotDisplayed = function (content) { - for( i=0; i < content.length; i++) { + for (i = 0; i < content.length; i++) { this.checkContentIsNotDisplayed(content[i]); } return this; @@ -220,7 +221,7 @@ var ContentServicesPage = function (){ this.navigateToFolderViaBreadcrumbs = function (folder) { contentList.tableIsLoaded(); - var breadcrumb = element(by.css("a[data-automation-id='breadcrumb_"+ folder +"']")); + var breadcrumb = element(by.css("a[data-automation-id='breadcrumb_" + folder + "']")); Util.waitUntilElementIsVisible(breadcrumb); breadcrumb.click(); contentList.tableIsLoaded(); @@ -232,7 +233,7 @@ var ContentServicesPage = function (){ return activeBreadcrumb.getAttribute("title"); }; - this.getCurrentFolderID = function() { + this.getCurrentFolderID = function () { Util.waitUntilElementIsVisible(folderID); return folderID.getText(); }; @@ -252,9 +253,10 @@ var ContentServicesPage = function (){ this.uploadMultipleFile = function (files) { Util.waitUntilElementIsVisible(uploadMultipleFileButton); var allFiles = path.resolve(path.join(TestConfig.main.rootPath, files[0])); - for(var i =1; i< files.length; i++) { + for (var i = 1; i < files.length; i++) { allFiles = allFiles + "\n" + path.resolve(path.join(TestConfig.main.rootPath, files[i])); - }; + } + ; uploadMultipleFileButton.sendKeys(allFiles); Util.waitUntilElementIsVisible(uploadMultipleFileButton); return this; @@ -282,11 +284,15 @@ var ContentServicesPage = function (){ return uploadFolderButton.getAttribute("title"); }; - this.checkUploadButton = function () { - Util.waitUntilElementIsVisible(uploadFileButton); - Util.waitUntilElementIsClickable(uploadFileButton); - return this; - }; + this.checkUploadButton = function () { + Util.waitUntilElementIsVisible(uploadFileButton); + Util.waitUntilElementIsClickable(uploadFileButton); + return this; + }; + + this.uploadButtonIsEnabled = function () { + return uploadFileButton.isEnabled() + }; this.deleteContent = function (content) { contentList.deleteContent(content); @@ -294,17 +300,18 @@ var ContentServicesPage = function (){ }; this.deleteContents = function (content) { - for( i=0; i{ - Util.waitUntilElementIsVisible(txtPassword).then(()=>{ + Util.waitUntilElementIsVisible(txtUsername).then(() => { + Util.waitUntilElementIsVisible(txtPassword).then(() => { deferred.fulfill(); - },()=>{ + }, () => { deferred.rejected(); }) }); @@ -68,7 +68,7 @@ var LoginPage = function (){ * @method enterUsername * @param {String} username */ - this.enterUsername = function (username){ + this.enterUsername = function (username) { Util.waitUntilElementIsVisible(txtUsername); txtUsername.sendKeys(''); txtUsername.clear(); @@ -81,7 +81,7 @@ var LoginPage = function (){ * @method enterPassword * @param {String} password */ - this.enterPassword = function (password){ + this.enterPassword = function (password) { Util.waitUntilElementIsVisible(txtPassword); browser.driver.sleep(500); txtPassword.clear(); @@ -93,7 +93,7 @@ var LoginPage = function (){ * @method clearUsername * @param {String} username */ - this.clearUsername = function(){ + this.clearUsername = function () { Util.waitUntilElementIsVisible(txtUsername); txtUsername.click().clear(); }; @@ -103,12 +103,12 @@ var LoginPage = function (){ * @method clearPassword * @param {String} password */ - this.clearPassword = function (){ + this.clearPassword = function () { Util.waitUntilElementIsVisible(txtPassword); - txtPassword.getAttribute('value').then(function (value){ + txtPassword.getAttribute('value').then(function (value) { for (var i = value.length; i >= 0; i--) { txtPassword.sendKeys(protractor.Key.BACK_SPACE); - } + } }); }; @@ -117,7 +117,7 @@ var LoginPage = function (){ * @method checkUsernameTooltip * @param {String} message */ - this.checkUsernameTooltip = function (message){ + this.checkUsernameTooltip = function (message) { Util.waitUntilElementIsVisible(usernameTooltip); }; @@ -126,7 +126,7 @@ var LoginPage = function (){ * @method checkPasswordTooltip * @param {String} message */ - this.checkPasswordTooltip = function (message){ + this.checkPasswordTooltip = function (message) { Util.waitUntilElementIsVisible(passwordTooltip); }; @@ -135,7 +135,7 @@ var LoginPage = function (){ * @method checkLoginError * @param {String} message */ - this.checkLoginError = function (message){ + this.checkLoginError = function (message) { Util.waitUntilElementIsVisible(loginTooltip); expect(loginTooltip.getText()).toEqual(message); }; @@ -144,23 +144,23 @@ var LoginPage = function (){ * checks username field is inactive * @method checkUsernameInactive */ - this.checkUsernameInactive = function (){ + this.checkUsernameInactive = function () { Util.waitUntilElementIsVisible(usernameInactive); }, - /** - * checks password field is inactive - * @method checkPasswordInactive - */ - this.checkPasswordInactive = function (){ - Util.waitUntilElementIsVisible(passwordInactive); - }; + /** + * checks password field is inactive + * @method checkPasswordInactive + */ + this.checkPasswordInactive = function () { + Util.waitUntilElementIsVisible(passwordInactive); + }; /** * checks username field is highlighted * @method checkUsernameHighlighted */ - this.checkUsernameHighlighted = function (){ + this.checkUsernameHighlighted = function () { adfLogo.click(); Util.waitUntilElementIsVisible(usernameHighlighted); }; @@ -169,7 +169,7 @@ var LoginPage = function (){ * checks password field is highlighted * @method checkPasswordHighlighted */ - this.checkPasswordHighlighted = function (){ + this.checkPasswordHighlighted = function () { adfLogo.click(); Util.waitUntilElementIsVisible(passwordHighlighted); }; @@ -178,7 +178,7 @@ var LoginPage = function (){ * check Username tooltip is not visible * @method checkUsernameTooltipIsNotVisible */ - this.checkUsernameTooltipIsNotVisible = function (){ + this.checkUsernameTooltipIsNotVisible = function () { Util.waitUntilElementIsNotVisible(usernameTooltip); }; @@ -186,7 +186,7 @@ var LoginPage = function (){ * checks password tooltip is not visible * @method checkPasswordTooltipIsNotVisible */ - this.checkPasswordTooltipIsNotVisible = function (){ + this.checkPasswordTooltipIsNotVisible = function () { Util.waitUntilElementIsNotVisible(passwordTooltip); }; @@ -194,7 +194,7 @@ var LoginPage = function (){ * checks sign in button is enabled * @method checkSignInButtonIsEnabled */ - this.checkSignInButtonIsEnabled = function (){ + this.checkSignInButtonIsEnabled = function () { Util.waitUntilElementIsVisible(signInButton); expect(signInButton.isEnabled()).toBe(true); }; @@ -203,7 +203,7 @@ var LoginPage = function (){ * Logs into adf using default host config * @method defaultLogin */ - this.defaultLogin = function (){ + this.defaultLogin = function () { browser.driver.get(TestConfig.adf.url + TestConfig.adf.login); this.login(TestConfig.adf.adminEmail, TestConfig.adf.adminPassword); }; @@ -212,7 +212,7 @@ var LoginPage = function (){ * Logs into adf using userModel * @method loginUsingUserModel */ - this.loginUsingUserModel = function (userModel){ + this.loginUsingUserModel = function (userModel) { browser.driver.get(TestConfig.adf.url + TestConfig.adf.login); this.waitForElements(); this.login(userModel.getId(), userModel.getPassword()); @@ -222,14 +222,14 @@ var LoginPage = function (){ * Logs into ADF using userModel - only Process Services enabled * @method loginUsingUserModel */ - this.loginToProcessServicesUsingUserModel = function (userModel){ + this.loginToProcessServicesUsingUserModel = function (userModel) { adfSettingsPage.setProviderBpm(); this.waitForElements(); this.login(userModel.email, userModel.password); }; - this.loginToProcessServicesUsingDefaultUser = function (){ + this.loginToProcessServicesUsingDefaultUser = function () { adfSettingsPage.setProviderBpm(); this.waitForElements(); this.login(TestConfig.adf.adminEmail, TestConfig.adf.adminPassword); @@ -242,19 +242,26 @@ var LoginPage = function (){ this.login(userModel.getId(), userModel.getPassword()); }; + this.loginToContentServices = function (username, password) { + adfSettingsPage.setProviderEcm(); + this.waitForElements(); + + this.login(username, password); + }; + /**
 * Go to adf login page
 * @method goToLoginPage
 */ - 
this.goToLoginPage = function (){
 - browser.driver.get(TestConfig.adf.url + TestConfig.adf.port+'/login'); - }; + this.goToLoginPage = function () { + browser.driver.get(TestConfig.adf.url + TestConfig.adf.port + '/login'); + }; /** * checks sign in button is disabled * @method checkSignInButtonIsDisabled */ - this.checkSignInButtonIsDisabled = function (){ + this.checkSignInButtonIsDisabled = function () { Util.waitUntilElementIsVisible(signInButton); expect(signInButton.isEnabled()).toBe(false); }; @@ -263,7 +270,7 @@ var LoginPage = function (){ * clicks the sign in button * @method clickSignInButton */ - this.clickSignInButton = function (){ + this.clickSignInButton = function () { Util.waitUntilElementIsVisible(signInButton); signInButton.click(); }; @@ -272,12 +279,12 @@ var LoginPage = function (){ * clicks icon to show password * @method showPassword */ - this.showPassword = function (){ + this.showPassword = function () { Util.waitUntilElementIsVisible(showPassword); showPassword.click(); }; - this.getShowPasswordIconColor = function (){ + this.getShowPasswordIconColor = function () { var deferred = protractor.promise.defer(); Util.waitUntilElementIsVisible(showPassword); @@ -288,7 +295,7 @@ var LoginPage = function (){ return deferred.promise; }; - this.getSignInButtonColor = function (){ + this.getSignInButtonColor = function () { var deferred = protractor.promise.defer(); Util.waitUntilElementIsVisible(signInButton); @@ -299,7 +306,7 @@ var LoginPage = function (){ return deferred.promise; }; - this.getBackgroundColor = function (){ + this.getBackgroundColor = function () { var deferred = protractor.promise.defer(); Util.waitUntilElementIsVisible(cardBackground); @@ -314,7 +321,7 @@ var LoginPage = function (){ * clicks icon to hide password * @method hidePassword */ - this.hidePassword = function (){ + this.hidePassword = function () { Util.waitUntilElementIsVisible(hidePassword); hidePassword.click(); }; @@ -324,7 +331,7 @@ var LoginPage = function (){ * @method checkPasswordIsShown * @param password */ - this.checkPasswordIsShown = function (password){ + this.checkPasswordIsShown = function (password) { txtPassword.getAttribute('value').then(function (text) { expect(text).toEqual(password); }); @@ -334,7 +341,7 @@ var LoginPage = function (){ * checks if password is hidden * @method checkPasswordIsHidden */ - this.checkPasswordIsHidden = function (){ + this.checkPasswordIsHidden = function () { Util.waitUntilElementIsVisible(txtPassword); }; @@ -342,7 +349,7 @@ var LoginPage = function (){ * checks 'Remember me' is displayed * @method checkRememberIsDisplayed */ - this.checkRememberIsDisplayed = function (){ + this.checkRememberIsDisplayed = function () { Util.waitUntilElementIsVisible(rememberMe); }; @@ -350,7 +357,7 @@ var LoginPage = function (){ * checks 'Remember me' is not displayed * @method checkRememberIsNotDisplayed */ - this.checkRememberIsNotDisplayed = function (){ + this.checkRememberIsNotDisplayed = function () { Util.waitUntilElementIsNotVisible(rememberMe); }; @@ -358,7 +365,7 @@ var LoginPage = function (){ * checks 'Need help' is Displayed * @method checkNeedHelpIsDisplayed */ - this.checkNeedHelpIsDisplayed = function (){ + this.checkNeedHelpIsDisplayed = function () { Util.waitUntilElementIsVisible(needHelp); }; @@ -366,7 +373,7 @@ var LoginPage = function (){ * checks 'Need Help' is not displayed * @method checkNeedHelpIsNotDisplayed */ - this.checkNeedHelpIsNotDisplayed = function (){ + this.checkNeedHelpIsNotDisplayed = function () { Util.waitUntilElementIsNotVisible(needHelp); }; @@ -374,7 +381,7 @@ var LoginPage = function (){ * checks 'Register' is displayed * @method checkRegisterDisplayed */ - this.checkRegisterDisplayed = function (){ + this.checkRegisterDisplayed = function () { Util.waitUntilElementIsVisible(register); }; @@ -382,7 +389,7 @@ var LoginPage = function (){ * checks 'Register' is not displayed * @method checkRegisterIsNotDisplayed */ - this.checkRegisterIsNotDisplayed = function (){ + this.checkRegisterIsNotDisplayed = function () { Util.waitUntilElementIsNotVisible(register); }; @@ -390,10 +397,10 @@ var LoginPage = function (){ * enables footer switch * @method enableFooter */ - this.enableFooter = function (){ + this.enableFooter = function () { Util.waitUntilElementIsVisible(footerSwitch); footerSwitch.getAttribute('class').then(function (check) { - if (check === 'mat-slide-toggle mat-primary'){ + if (check === 'mat-slide-toggle mat-primary') { footerSwitch.click(); expect(footerSwitch.getAttribute('class')).toEqual('mat-slide-toggle mat-primary mat-checked'); } @@ -404,10 +411,10 @@ var LoginPage = function (){ * disables footer switch * @method disableFooter */ - this.disableFooter = function (){ + this.disableFooter = function () { Util.waitUntilElementIsVisible(footerSwitch); footerSwitch.getAttribute('class').then(function (check) { - if (check ==='mat-slide-toggle mat-primary mat-checked'){ + if (check === 'mat-slide-toggle mat-primary mat-checked') { footerSwitch.click(); expect(footerSwitch.getAttribute('class')).toEqual('mat-slide-toggle mat-primary'); } diff --git a/e2e/pages/adf/notificationPage.js b/e2e/pages/adf/notificationPage.js new file mode 100644 index 0000000000..1489bb470f --- /dev/null +++ b/e2e/pages/adf/notificationPage.js @@ -0,0 +1,28 @@ +/*! + * @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. + */ + +var Util = require('../../util/util'); + +var NotificationPage = function () { + + this.checkNotifyContains = function (message) { + Util.waitUntilElementIsVisible(element(by.cssContainingText('simple-snack-bar', message))); + return this; + }; + +}; +module.exports = NotificationPage; diff --git a/e2e/pagination_processlist_addingProcesses.e2e.ts b/e2e/pagination_processlist_addingProcesses.e2e.ts index ea23e395c1..1f0a2467fd 100644 --- a/e2e/pagination_processlist_addingProcesses.e2e.ts +++ b/e2e/pagination_processlist_addingProcesses.e2e.ts @@ -28,7 +28,7 @@ import AlfrescoApi = require('alfresco-js-api-node'); import { AppsActions } from './actions/APS/apps.actions'; import { UsersActions } from './actions/users.actions'; -describe('Test Process List - Pagination when adding processes', () => { +describe('Process List - Pagination when adding processes', () => { let itemsPerPage = { fifteen: '15', diff --git a/e2e/processlist_pagination.e2e.ts b/e2e/processlist_pagination.e2e.ts index 70f5ad7d2f..f2a21eb35a 100644 --- a/e2e/processlist_pagination.e2e.ts +++ b/e2e/processlist_pagination.e2e.ts @@ -31,7 +31,7 @@ import AlfrescoApi = require('alfresco-js-api-node'); import { AppsActions } from './actions/APS/apps.actions'; import { UsersActions } from './actions/users.actions'; -describe('Test Process List - Pagination', function () { +describe('Process List - Pagination', function () { let itemsPerPage = { five: '5', diff --git a/e2e/resources/adf/allFileTypes/desktop.ini b/e2e/resources/adf/allFileTypes/desktop.ini new file mode 100644 index 0000000000..5f1cfce266 --- /dev/null +++ b/e2e/resources/adf/allFileTypes/desktop.ini @@ -0,0 +1 @@ +example file diff --git a/e2e/resources/adf/folderExcluded/a_file.txt b/e2e/resources/adf/folderExcluded/a_file.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/e2e/resources/adf/folderTwo/a_file.txt b/e2e/resources/adf/folderTwo/a_file.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/e2e/search_component.e2e.ts b/e2e/search_component.e2e.ts index 0daa3e6250..8cf325193c 100644 --- a/e2e/search_component.e2e.ts +++ b/e2e/search_component.e2e.ts @@ -32,7 +32,7 @@ import Util = require('./util/util'); import AlfrescoApi = require('alfresco-js-api-node'); import { UploadActions } from './actions/ACS/upload.actions'; -describe('Test Search component - Search Bar', () => { +describe('Search component - Search Bar', () => { let search = { inactive: { diff --git a/e2e/search_page_component.e2e.ts b/e2e/search_page_component.e2e.ts index 1b86e6453c..55efa39e82 100644 --- a/e2e/search_page_component.e2e.ts +++ b/e2e/search_page_component.e2e.ts @@ -32,7 +32,7 @@ import resources = require('./util/resources'); import AlfrescoApi = require('alfresco-js-api-node'); import { UploadActions } from './actions/ACS/upload.actions'; -describe('Test Search component - Search Page', () => { +describe('Search component - Search Page', () => { let search = { active: { base: Util.generateRandomString(3), diff --git a/e2e/theming_component.e2e.ts b/e2e/theming_component.e2e.ts index ffc4e9d166..15534d69fa 100644 --- a/e2e/theming_component.e2e.ts +++ b/e2e/theming_component.e2e.ts @@ -25,7 +25,7 @@ import CONSTANTS = require('./util/constants'); import AlfrescoApi = require('alfresco-js-api-node'); -describe('Test Theming component', () => { +describe('Theming component', () => { let navigationBarPage = new NavigationBarPage(); let loginPage = new LoginPage(); diff --git a/e2e/upload/excluded_file.e2e.ts b/e2e/upload/excluded_file.e2e.ts new file mode 100644 index 0000000000..ad21aeea84 --- /dev/null +++ b/e2e/upload/excluded_file.e2e.ts @@ -0,0 +1,109 @@ +/*! + * @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 LoginPage = require('../pages/adf/loginPage'); +import ContentServicesPage = require('../pages/adf/contentServicesPage'); +import UploadDialog = require('../pages/adf/dialog/uploadDialog'); +import UploadToggles = require('../pages/adf/dialog/uploadToggles'); + +import AcsUserModel = require('../models/ACS/acsUserModel'); +import FileModel = require('../models/ACS/fileModel'); +import FolderModel = require('../models/ACS/folderModel'); + +import TestConfig = require('../test.config'); +import resources = require('../util/resources'); + +import AlfrescoApi = require('alfresco-js-api-node'); +import { UploadActions } from '../actions/ACS/upload.actions'; +import { DropActions } from '../actions/drop.actions'; + +import path = require('path'); + +describe('Upload component - Excluded Files', () => { + + let contentServicesPage = new ContentServicesPage(); + let uploadDialog = new UploadDialog(); + let uploadToggles = new UploadToggles(); + let loginPage = new LoginPage(); + let acsUser = new AcsUserModel(); + + let iniExcludedFile = new FileModel({ + 'name': resources.Files.ADF_DOCUMENTS.INI.file_name, + 'location': resources.Files.ADF_DOCUMENTS.INI.file_location + }); + + let folderWithExcludedFile = new FolderModel({ + 'name': resources.Files.ADF_DOCUMENTS.FOLDER_EXCLUDED.folder_name, + 'location': resources.Files.ADF_DOCUMENTS.FOLDER_EXCLUDED.folder_location + }); + + let emptyFile = new FileModel({ + 'name': resources.Files.ADF_DOCUMENTS.TXT_0B.file_name, + 'location': resources.Files.ADF_DOCUMENTS.TXT_0B.file_location + }); + + beforeAll(async (done) => { + let uploadActions = new UploadActions(); + + this.alfrescoJsApi = new AlfrescoApi({ + provider: 'ECM', + hostEcm: TestConfig.adf.url + }); + + await this.alfrescoJsApi.login(TestConfig.adf.adminEmail, TestConfig.adf.adminPassword); + + await this.alfrescoJsApi.core.peopleApi.addPerson(acsUser); + + await this.alfrescoJsApi.login(acsUser.id, acsUser.password); + + loginPage.loginToContentServicesUsingUserModel(acsUser); + + contentServicesPage.goToDocumentList(); + + done(); + }); + + it('[C279914] Should not allow upload default excluded files using D&D', () => { + contentServicesPage.checkDandDIsDisplayed(); + + let dragAndDropArea = element(by.css('adf-upload-drag-area div')); + + let dragAndDrop = new DropActions(); + + dragAndDrop.dropFile(dragAndDropArea, iniExcludedFile.location); + + browser.driver.sleep(2000); + + uploadDialog.dialogIsNotDisplayed(); + + contentServicesPage.checkContentIsNotDisplayed(iniExcludedFile.name); + }); + + it('[C260122] Should not allow upload default excluded files using Upload button', () => { + contentServicesPage + .uploadFile(iniExcludedFile.location) + .checkContentIsNotDisplayed(iniExcludedFile.name); + }); + + it('[C260125] Should not upload excluded file when they are in a Folder', () => { + uploadToggles.enableFolderUpload(); + + contentServicesPage.uploadFolder(folderWithExcludedFile.location).checkContentIsDisplayed(folderWithExcludedFile.name); + + contentServicesPage.doubleClickRow(folderWithExcludedFile.name).checkContentIsNotDisplayed(iniExcludedFile.name).checkContentIsDisplayed('a_file.txt'); + }); +}); diff --git a/e2e/uploader_component.e2e.ts b/e2e/upload/uploader_component.e2e.ts similarity index 77% rename from e2e/uploader_component.e2e.ts rename to e2e/upload/uploader_component.e2e.ts index cea00d6eae..e291209e9d 100644 --- a/e2e/uploader_component.e2e.ts +++ b/e2e/upload/uploader_component.e2e.ts @@ -15,22 +15,23 @@ * limitations under the License. */ -import LoginPage = require('./pages/adf/loginPage'); -import ContentServicesPage = require('./pages/adf/contentServicesPage'); -import UploadDialog = require('./pages/adf/dialog/uploadDialog'); -import UploadToggles = require('./pages/adf/dialog/uploadToggles'); +import LoginPage = require('../pages/adf/loginPage'); +import ContentServicesPage = require('../pages/adf/contentServicesPage'); +import UploadDialog = require('../pages/adf/dialog/uploadDialog'); +import UploadToggles = require('../pages/adf/dialog/uploadToggles'); -import AcsUserModel = require('./models/ACS/acsUserModel'); -import FileModel = require('./models/ACS/fileModel'); -import FolderModel = require('./models/ACS/folderModel'); +import AcsUserModel = require('../models/ACS/acsUserModel'); +import FileModel = require('../models/ACS/fileModel'); +import FolderModel = require('../models/ACS/folderModel'); -import TestConfig = require('./test.config'); -import resources = require('./util/resources'); +import TestConfig = require('../test.config'); +import resources = require('../util/resources'); import AlfrescoApi = require('alfresco-js-api-node'); -import { UploadActions } from './actions/ACS/upload.actions'; +import { UploadActions } from '../actions/ACS/upload.actions'; +import { DropActions } from '../actions/drop.actions'; -describe('Test Uploader component', () => { +describe('Upload component', () => { let contentServicesPage = new ContentServicesPage(); let uploadDialog = new UploadDialog(); @@ -70,7 +71,12 @@ describe('Test Uploader component', () => { 'name': resources.Files.ADF_DOCUMENTS.FOLDER_ONE.folder_name, 'location': resources.Files.ADF_DOCUMENTS.FOLDER_ONE.folder_location }); + let folderTwo = new FolderModel({ + 'name': resources.Files.ADF_DOCUMENTS.FOLDER_TWO.folder_name, + 'location': resources.Files.ADF_DOCUMENTS.FOLDER_TWO.folder_location + }); let uploadedFileInFolder = new FileModel({ 'name': resources.Files.ADF_DOCUMENTS.FILE_INSIDE_FOLDER_ONE.file_name }); + let uploadedFileInFolderTwo = new FileModel({ 'name': resources.Files.ADF_DOCUMENTS.FILE_INSIDE_FOLDER_TWO.file_name }); let filesLocation = [pdfFileModel.location, docxFileModel.location, pngFileModel.location, firstPdfFileModel.location]; let filesName = [pdfFileModel.name, docxFileModel.name, pngFileModel.name, firstPdfFileModel.name]; @@ -99,7 +105,7 @@ describe('Test Uploader component', () => { done(); }); - it('1. Upload Button is visible on the page', () => { + it('[C272788] Upload Button is visible on the page', () => { expect(contentServicesPage.getSingleFileButtonTooltip()).toEqual('Custom tooltip'); contentServicesPage @@ -111,7 +117,7 @@ describe('Test Uploader component', () => { .checkContentIsNotDisplayed(pdfFileModel.name); }); - it('2. Upload a pdf file', () => { + it('[C272789] Upload a pdf file', () => { contentServicesPage .uploadFile(pdfFileModel.location) .checkContentIsDisplayed(pdfFileModel.name); @@ -125,7 +131,7 @@ describe('Test Uploader component', () => { .checkContentIsNotDisplayed(pdfFileModel.name); }); - it('3. Upload a text file', () => { + it('[C272790] Upload a text file', () => { contentServicesPage .uploadFile(docxFileModel.location) .checkContentIsDisplayed(docxFileModel.name); @@ -138,7 +144,7 @@ describe('Test Uploader component', () => { .checkContentIsNotDisplayed(docxFileModel.name); }); - it('4. Upload a png file', () => { + it('[C260141] Upload a png file', () => { contentServicesPage .uploadFile(pngFileModel.location) .checkContentIsDisplayed(pngFileModel.name); @@ -151,7 +157,7 @@ describe('Test Uploader component', () => { .checkContentIsNotDisplayed(pngFileModel.name); }); - it('5. Minimize and maximize the upload dialog box', () => { + it('[C260143] Minimize and maximize the upload dialog box', () => { contentServicesPage .uploadFile(docxFileModel.location) .checkContentIsDisplayed(docxFileModel.name); @@ -172,7 +178,7 @@ describe('Test Uploader component', () => { contentServicesPage.deleteContent(docxFileModel.name).checkContentIsNotDisplayed(docxFileModel.name); }); - it('6. Cancel the uploaded file through the upload dialog icon', () => { + it('[C260168] Cancel the uploaded file through the upload dialog icon', () => { contentServicesPage.uploadFile(pdfFileModel.location) .checkContentIsDisplayed(pdfFileModel.name); uploadDialog.removeUploadedFile(pdfFileModel.name).fileIsCancelled(pdfFileModel.name); @@ -181,7 +187,7 @@ describe('Test Uploader component', () => { contentServicesPage.checkContentIsNotDisplayed(pdfFileModel.name); }); - xit('7. Cancel a big file through the upload dialog icon before the upload to be done', () => { + xit('[C272792] Cancel a big file through the upload dialog icon before the upload to be done', () => { contentServicesPage.uploadFile(largeFile.location); uploadDialog.removeFileWhileUploading(largeFile.name).fileIsCancelled(largeFile.name); @@ -191,7 +197,7 @@ describe('Test Uploader component', () => { contentServicesPage.checkContentIsNotDisplayed(largeFile.name); }); - xit('8. Cancel a big file through the cancel uploads button', () => { + xit('[C260169] Cancel a big file through the cancel uploads button', () => { contentServicesPage.uploadFile(largeFile.location); uploadDialog.cancelUploads(); expect(uploadDialog.getTitleText()).toEqual('Uploading 0 / 1'); @@ -203,7 +209,7 @@ describe('Test Uploader component', () => { contentServicesPage.checkContentIsNotDisplayed(largeFile.name); }); - xit('9. Cancel uploading multiple files', () => { + xit('[C272793] Cancel uploading multiple files', () => { uploadToggles.enableMultipleFileUpload(); contentServicesPage.uploadMultipleFile([pngFileModel.location, largeFile.location]); uploadDialog.cancelUploads(); @@ -216,13 +222,13 @@ describe('Test Uploader component', () => { uploadToggles.disableMultipleFileUpload(); }); - it('10. Tooltip of uploading multiple files button', () => { + it('[C272794] Tooltip of uploading multiple files button', () => { uploadToggles.enableMultipleFileUpload(); expect(contentServicesPage.getMultipleFileButtonTooltip()).toEqual('Custom tooltip'); uploadToggles.disableMultipleFileUpload(); }); - it('11. Enable extension filter', () => { + it('[C260171] Should upload only the extension filter allowed when Enable extension filter is enabled', () => { uploadToggles.enableExtensionFilter().addExtension('.docx'); contentServicesPage.uploadFile(docxFileModel.location).checkContentIsDisplayed(docxFileModel.name); uploadDialog.removeUploadedFile(docxFileModel.name).fileIsCancelled(docxFileModel.name); @@ -232,7 +238,25 @@ describe('Test Uploader component', () => { uploadToggles.disableExtensionFilter(); }); - it('12. Upload same file twice', () => { + it('[C274687] Should upload with drag and drop only the extension filter allowed when Enable extension filter is enabled', () => { + uploadToggles.enableExtensionFilter().addExtension('.docx'); + + let dragAndDrop = new DropActions(); + let dragAndDropArea = element(by.css('adf-upload-drag-area div')); + + dragAndDrop.dropFile(dragAndDropArea, docxFileModel.location); + contentServicesPage.checkContentIsDisplayed(docxFileModel.name); + + uploadDialog.removeUploadedFile(docxFileModel.name).fileIsCancelled(docxFileModel.name); + uploadDialog.clickOnCloseButton().dialogIsNotDisplayed(); + + dragAndDrop.dropFile(dragAndDropArea, largeFile.location); + contentServicesPage.checkContentIsNotDisplayed(largeFile.name); + uploadDialog.dialogIsNotDisplayed(); + uploadToggles.disableExtensionFilter(); + }); + + it('[C279920] Upload same file twice', () => { contentServicesPage.uploadFile(pdfFileModel.location).checkContentIsDisplayed(pdfFileModel.name); pdfFileModel.setVersion('1'); contentServicesPage.uploadFile(pdfFileModel.location).checkContentIsDisplayed(pdfFileModel.getVersionName()); @@ -242,7 +266,7 @@ describe('Test Uploader component', () => { pdfFileModel.setVersion(''); }); - it('13. Enable versioning', () => { + it('[C260172] Enable versioning', () => { uploadToggles.enableVersioning(); contentServicesPage.uploadFile(pdfFileModel.location).checkContentIsDisplayed(pdfFileModel.name); pdfFileModel.setVersion('1'); @@ -255,7 +279,7 @@ describe('Test Uploader component', () => { uploadToggles.disableVersioning(); }); - xit('14. Enable folder upload', () => { + xit('[C260173] Enable folder upload', () => { uploadToggles.enableFolderUpload(); contentServicesPage.uploadFolder(folderOne.location).checkContentIsDisplayed(folderOne.name); expect(contentServicesPage.getFolderButtonTooltip()).toEqual('Custom tooltip'); @@ -266,7 +290,7 @@ describe('Test Uploader component', () => { uploadToggles.disableFolderUpload(); }); - xit('16. The files uploaded before closing the upload dialog box are not displayed anymore in the upload box', () => { + xit('[C260176] The files uploaded before closing the upload dialog box are not displayed anymore in the upload box', () => { contentServicesPage.uploadFile(docxFileModel.location).checkContentIsDisplayed(docxFileModel.name); uploadDialog.fileIsUploaded(docxFileModel.name); @@ -285,7 +309,7 @@ describe('Test Uploader component', () => { .checkContentsAreNotDisplayed([docxFileModel.name, pngFileModel.name, pdfFileModel.name]); }); - xit('18. Upload files on the same time', () => { + xit('[C260170] Upload files on the same time', () => { contentServicesPage.goToDocumentList(); contentServicesPage.checkAcsContainer(); @@ -304,7 +328,7 @@ describe('Test Uploader component', () => { uploadToggles.disableMultipleFileUpload(); }); - xit('19. Enable max size and set it to 400', () => { + xit('[C279919] Enable max size and set it to 400', () => { contentServicesPage.goToDocumentList(); contentServicesPage.checkAcsContainer(); uploadToggles.enableMaxSize().addMaxSize('400'); @@ -321,7 +345,7 @@ describe('Test Uploader component', () => { uploadToggles.disableMaxSize(); }); - xit('20. Enable max size and set it to 0', () => { + xit('[C272796] Enable max size and set it to 0', () => { contentServicesPage.goToDocumentList(); contentServicesPage.checkAcsContainer(); uploadToggles.enableMaxSize().addMaxSize('0'); @@ -334,10 +358,37 @@ describe('Test Uploader component', () => { uploadToggles.disableMaxSize(); }); - xit('21. Set max size to 1 and disable it', () => { + xit('[C272797] Set max size to 1 and disable it', () => { uploadToggles.enableMaxSize().addMaxSize('1'); uploadToggles.disableMaxSize(); contentServicesPage.uploadFile(fileWithSpecificSize.location).checkContentIsDisplayed(fileWithSpecificSize.name); uploadDialog.fileIsUploaded(fileWithSpecificSize.name).clickOnCloseButton().dialogIsNotDisplayed(); }); + + it('[C91318] Should Enable/Disable upload button when change the disable property', () => { + uploadToggles.clickCheckboxDisableUpload(); + expect(contentServicesPage.uploadButtonIsEnabled()).toBeFalsy(); + + uploadToggles.clickCheckboxDisableUpload(); + expect(contentServicesPage.uploadButtonIsEnabled()).toBeTruthy(); + }); + + it('[C279882] Should be possible Upload a folder in a folder', () => { + uploadToggles.enableFolderUpload(); + contentServicesPage.uploadFolder(folderOne.location).checkContentIsDisplayed(folderOne.name); + uploadDialog.fileIsUploaded(uploadedFileInFolder.name); + + uploadDialog.clickOnCloseButton().dialogIsNotDisplayed(); + contentServicesPage.doubleClickRow(folderOne.name).checkContentIsDisplayed(uploadedFileInFolder.name); + + uploadToggles.enableFolderUpload(); + contentServicesPage.uploadFolder(folderTwo.location).checkContentIsDisplayed(folderTwo.name); + uploadDialog.fileIsUploaded(uploadedFileInFolderTwo.name); + + uploadDialog.clickOnCloseButton().dialogIsNotDisplayed(); + contentServicesPage.doubleClickRow(folderTwo.name).checkContentIsDisplayed(uploadedFileInFolderTwo.name); + + uploadToggles.disableFolderUpload(); + }); + }); diff --git a/e2e/upload/user_permission.e2e.ts b/e2e/upload/user_permission.e2e.ts new file mode 100644 index 0000000000..ec487ee7cd --- /dev/null +++ b/e2e/upload/user_permission.e2e.ts @@ -0,0 +1,249 @@ +/*! + * @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 LoginPage = require('../pages/adf/loginPage'); +import ContentServicesPage = require('../pages/adf/contentServicesPage'); +import UploadDialog = require('../pages/adf/dialog/uploadDialog'); +import UploadToggles = require('../pages/adf/dialog/uploadToggles'); +import NavigationBarPage = require('../pages/adf/navigationBarPage'); +import NotificationPage = require('../pages/adf/notificationPage'); + +import AcsUserModel = require('../models/ACS/acsUserModel'); +import FileModel = require('../models/ACS/fileModel'); +import FolderModel = require('../models/ACS/folderModel'); + +import TestConfig = require('../test.config'); +import resources = require('../util/resources'); + +import AlfrescoApi = require('alfresco-js-api-node'); +import { UploadActions } from '../actions/ACS/upload.actions'; +import { DropActions } from '../actions/drop.actions'; + +import path = require('path'); + +describe('Upload - User permission', () => { + + let contentServicesPage = new ContentServicesPage(); + let uploadDialog = new UploadDialog(); + let uploadToggles = new UploadToggles(); + let loginPage = new LoginPage(); + let acsUser; + let acsUserTwo; + let navigationBarPage = new NavigationBarPage(); + let notificationPage = new NotificationPage(); + + let emptyFile = new FileModel({ + 'name': resources.Files.ADF_DOCUMENTS.TXT_0B.file_name, + 'location': resources.Files.ADF_DOCUMENTS.TXT_0B.file_location + }); + + let pngFile = new FileModel({ + 'name': resources.Files.ADF_DOCUMENTS.PNG.file_name, + 'location': resources.Files.ADF_DOCUMENTS.PNG.file_location + }); + + let pdfFile = new FileModel({ + 'name': resources.Files.ADF_DOCUMENTS.PDF.file_name, + 'location': resources.Files.ADF_DOCUMENTS.PDF.file_location + }); + + let folder = new FolderModel({ + 'name': resources.Files.ADF_DOCUMENTS.FOLDER_ONE.folder_name, + 'location': resources.Files.ADF_DOCUMENTS.FOLDER_ONE.folder_location + }); + + beforeAll(() => { + let uploadActions = new UploadActions(); + + this.alfrescoJsApi = new AlfrescoApi({ + provider: 'ECM', + hostEcm: TestConfig.adf.url + }); + }); + + beforeEach(async (done) => { + acsUser = new AcsUserModel(); + + await this.alfrescoJsApi.login(TestConfig.adf.adminEmail, TestConfig.adf.adminPassword); + + await this.alfrescoJsApi.core.peopleApi.addPerson(acsUser); + + loginPage.loginToContentServicesUsingUserModel(acsUser); + + done(); + }); + + describe('limited permissions', () => { + + beforeEach(async (done) => { + contentServicesPage.goToDocumentList(); + + done(); + }); + + it('[C212861] Should not be allowed to Drag and drop a file/folder in a restricted user folder with limited permissions', () => { + contentServicesPage.checkDandDIsDisplayed(); + + let dragAndDrop = new DropActions(); + let dragAndDropArea = element(by.css('adf-upload-drag-area div')); + + dragAndDrop.dropFile(dragAndDropArea, emptyFile.location); + dragAndDrop.dropFolder(dragAndDropArea, folder.location); + + contentServicesPage.checkContentIsDisplayed(emptyFile.name); + contentServicesPage.checkContentIsDisplayed(folder.name); + + contentServicesPage.navigateToFolderViaBreadcrumbs('User Homes'); + + dragAndDrop.dropFile(dragAndDropArea, emptyFile.location); + dragAndDrop.dropFolder(dragAndDropArea, folder.location); + + let fileInTheUploadedFolder = 'share_profile_pic.png'; + + uploadDialog.fileIsError(emptyFile.name); + uploadDialog.fileIsError(fileInTheUploadedFolder); + + contentServicesPage.checkContentIsNotDisplayed(emptyFile.name); + contentServicesPage.checkContentIsNotDisplayed(folder.name); + }); + + it('[C279915] Should not be allowed to upload a file in a restricted user folder with limited permissions', () => { + navigationBarPage.clickLoginButton(); + + loginPage.loginToContentServicesUsingUserModel(acsUser); + + contentServicesPage.goToDocumentList(); + + contentServicesPage.uploadFile(emptyFile.location).checkContentIsDisplayed(emptyFile.name); + + uploadDialog.fileIsUploaded(emptyFile.name); + + uploadDialog.clickOnCloseButton().dialogIsNotDisplayed(); + + contentServicesPage.navigateToFolderViaBreadcrumbs('User Homes'); + + contentServicesPage.uploadFile(emptyFile.location); + + notificationPage.checkNotifyContains('You don\'t have the create permission to upload the content'); + }); + + it('[C279916] Should not be allowed to upload a folder in a restricted user folder with limited permissions', () => { + uploadToggles.enableFolderUpload(); + + contentServicesPage.uploadFolder(folder.location).checkContentIsDisplayed(folder.name); + + let fileInTheUploadedFolder = 'share_profile_pic.png'; + + uploadDialog.fileIsUploaded(fileInTheUploadedFolder); + + uploadDialog.clickOnCloseButton().dialogIsNotDisplayed(); + + contentServicesPage.navigateToFolderViaBreadcrumbs('User Homes'); + + uploadToggles.enableFolderUpload(); + + contentServicesPage.uploadFolder(folder.location); + + notificationPage.checkNotifyContains('You don\'t have the create permission to upload the content'); + }); + }); + + describe('full permissions', () => { + + beforeEach(async (done) => { + loginPage.loginToContentServices(TestConfig.adf.adminEmail, TestConfig.adf.adminPassword); + + contentServicesPage.goToDocumentList(); + + done(); + }); + + it('[C260130] Should be allowed to Drag and drop a file/folder in a restricted user folder with full permissions', () => { + contentServicesPage.checkDandDIsDisplayed(); + + let dragAndDrop = new DropActions(); + + let dragAndDropArea = element(by.css('adf-upload-drag-area div')); + + dragAndDrop.dropFile(dragAndDropArea, emptyFile.location); + dragAndDrop.dropFolder(dragAndDropArea, folder.location); + + let fileInTheUploadedFolder = 'share_profile_pic.png'; + + uploadDialog.fileIsUploaded(emptyFile.name); + uploadDialog.fileIsUploaded(fileInTheUploadedFolder); + }); + + it('[C279917] Should be allowed to upload a file in a restricted user folder with full permissions', () => { + contentServicesPage.uploadFile(emptyFile.location); + + uploadDialog.fileIsUploaded(emptyFile.name); + }); + + it('[C279918] Should be allowed to upload a folder in a restricted user folder with full permissions', () => { + uploadToggles.enableFolderUpload(); + + contentServicesPage.uploadFolder(folder.location); + + let fileInTheUploadedFolder = 'share_profile_pic.png'; + + uploadDialog.fileIsUploaded(fileInTheUploadedFolder); + }); + }); + + describe('multiple users', () => { + + beforeEach(async (done) => { + acsUserTwo = new AcsUserModel(); + + await this.alfrescoJsApi.core.peopleApi.addPerson(acsUserTwo); + + contentServicesPage.goToDocumentList(); + + done(); + }); + + it('[C260175] Should two different user upload files in the proper User Home', () => { + contentServicesPage.uploadFile(emptyFile.location); + + uploadDialog.fileIsUploaded(emptyFile.name); + + contentServicesPage.checkContentIsDisplayed(emptyFile.name); + + navigationBarPage.clickLoginButton(); + loginPage.loginToContentServicesUsingUserModel(acsUserTwo); + contentServicesPage.goToDocumentList(); + + contentServicesPage.checkContentIsNotDisplayed(emptyFile.name); + + contentServicesPage.uploadFile(pngFile.location); + + contentServicesPage.checkContentIsDisplayed(pngFile.name); + + navigationBarPage.clickLoginButton(); + loginPage.loginToContentServicesUsingUserModel(acsUser); + contentServicesPage.goToDocumentList(); + + contentServicesPage.checkContentIsNotDisplayed(pngFile.name); + + contentServicesPage.uploadFile(pdfFile.location); + + contentServicesPage.checkContentIsDisplayed(pdfFile.name); + }); + }); + +}); diff --git a/e2e/user_info_component.e2e.ts b/e2e/user_info_component.e2e.ts index 508ff2f625..b40ee94d75 100644 --- a/e2e/user_info_component.e2e.ts +++ b/e2e/user_info_component.e2e.ts @@ -30,7 +30,7 @@ import resources = require('./util/resources'); import AlfrescoApi = require('alfresco-js-api-node'); import { UsersActions } from './actions/users.actions'; -describe('Test User Info component', () => { +describe('User Info component', () => { let adfSettingsPage = new AdfSettingsPage(); let loginPage = new LoginPage(); diff --git a/e2e/util/resources.js b/e2e/util/resources.js index 42df39a60d..85d44f5e7c 100644 --- a/e2e/util/resources.js +++ b/e2e/util/resources.js @@ -137,10 +137,22 @@ exports.Files = { folder_location: "/resources/adf/folderOne", folder_name: "folderOne" }, + FOLDER_TWO: { + folder_location: "/resources/adf/folderTwo", + folder_name: "folderTwo" + }, + FOLDER_EXCLUDED: { + folder_location: "/resources/adf/folderExcluded", + folder_name: "folderExcluded" + }, FILE_INSIDE_FOLDER_ONE: { file_location: "/resources/adf/folderOne/share_profile_pic.png", file_name: "share_profile_pic.png" }, + FILE_INSIDE_FOLDER_TWO: { + file_location: "/resources/adf/folderOne/a_file.txt", + file_name: "a_file.txt" + }, JPG: { file_location: "/resources/adf/allFileTypes/a_jpg_file.jpg", file_name: "a_jpg_file.jpg" @@ -178,11 +190,14 @@ exports.Files = { file_location: "/resources/adf/allFileTypes/a_zip_file.mp4.zip", file_name: "a_zip_file.mp4.zip" }, - PAGES:{ file_location: "/resources/adf/allFileTypes/file_unsupported.pages", file_name: "file_unsupported.pages" }, + INI:{ + file_location: "/resources/adf/allFileTypes/desktop.ini", + file_name: "desktop.ini" + }, }, PROFILE_IMAGES: { diff --git a/e2e/viewer_content_services_component.e2e.ts b/e2e/viewer_content_services_component.e2e.ts index 3dff569feb..df6d3174db 100644 --- a/e2e/viewer_content_services_component.e2e.ts +++ b/e2e/viewer_content_services_component.e2e.ts @@ -31,7 +31,7 @@ import AcsUserModel = require('./models/ACS/acsUserModel'); import AlfrescoApi = require('alfresco-js-api-node'); import { UploadActions } from './actions/ACS/upload.actions'; -describe('Test Content Services Viewer', () => { +describe('Content Services Viewer', () => { let acsUser = new AcsUserModel(); let viewerPage = new ViewerPage(); diff --git a/protractor.conf.js b/protractor.conf.js index 4e88899db3..2f7a135df5 100644 --- a/protractor.conf.js +++ b/protractor.conf.js @@ -27,7 +27,7 @@ exports.config = { allScriptsTimeout: 60000, specs: [ - './e2e/*.e2e.ts' + './e2e/**/*.e2e.ts' ], capabilities: { diff --git a/scripts/README.md b/scripts/README.md index 0512a736a4..54b0de38ac 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -373,6 +373,7 @@ Script to run e2e test |-e or --email |email user to use| |-b or --browser |browser run the test in the browsrwer (No headless mode)| |-s or --spec |spec run a single test file| +|-dev or --dev |run it against local development environment it will deploy on localhost:4200 the current version of your branch| |-host or --host | host against to run the test| |-proxy or --proxy | proxy Back end URL to use | diff --git a/scripts/test-e2e-lib.sh b/scripts/test-e2e-lib.sh index b51cadbf6f..9c638b10fe 100755 --- a/scripts/test-e2e-lib.sh +++ b/scripts/test-e2e-lib.sh @@ -3,6 +3,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd "$DIR/../" BROWSER_RUN=false +DEVELOPMENT=false show_help() { echo "Usage: ./scripts/test-e2e-lib.sh -host adf.domain.com -u admin -p admin -e admin" @@ -12,7 +13,8 @@ show_help() { echo "-e or --email" echo "-b or --browser run the test in the browsrwer (No headless mode)" echo "-s or --spec run a single test file" - echo "-p or --proxy proxy Back end URL to use" + echo "-proxy or --proxy proxy Back end URL to use only possibel to use with -dev option" + echo "-dev or --dev run it against local development environment it will deploy on localhost:4200 the current version of your branch" echo "-host or --host URL of the Front end to test" echo "-save save the error screenshot in the remote env" echo "-h or --help" @@ -44,10 +46,15 @@ set_browser(){ set_proxy(){ PROXY=$1 } + set_save_screenshot(){ SAVE_SCREENSHOT=true } +set_development(){ + DEVELOPMENT=true +} + while [[ $1 == -* ]]; do case "$1" in -h|--help|-\?) show_help; exit 0;; @@ -55,6 +62,7 @@ while [[ $1 == -* ]]; do -p|--password) set_password $2; shift 2;; -e|--email) set_email $2; shift 2;; -b|--browser) set_browser; shift;; + -dev|--dev) set_development; shift;; -s|--spec) set_test $2; shift 2;; -save) set_save_screenshot; shift;; -proxy|--proxy) set_proxy $2; shift 2;; @@ -74,10 +82,28 @@ export BROWSER_RUN=$BROWSER_RUN export PROXY_HOST_ADF=$PROXY export SAVE_SCREENSHOT=$SAVE_SCREENSHOT -if [[ $SINGLE_TEST == "true" ]]; then - echo "====== Single test run $NAME_TEST =====" - npm run e2e-lib -- --specs ./e2e/$NAME_TEST + +if [[ $DEVELOPMENT == "true" ]]; then + echo "====== Run against local development =====" + if [[ $SINGLE_TEST == "true" ]]; then + echo "====== Single test run $NAME_TEST =====" + npm run e2e-lib -- --specs ./e2e/$NAME_TEST + else + npm run e2e-lib + fi else - npm run e2e-lib + if [[ $SINGLE_TEST == "true" ]]; then + npm install --save-dev jasmine2-protractor-utils -g + echo "====== Single test run $NAME_TEST =====" + webdriver-manager update --gecko=false --versions.chrome=2.38 + protractor protractor.conf.js --specs ./e2e/$NAME_TEST + else + webdriver-manager update --gecko=false --versions.chrome=2.38 + protractor protractor.conf.js + fi fi + + + +