diff --git a/e2e/card-view-component.e2e.ts b/e2e/card-view-component.e2e.ts new file mode 100644 index 0000000000..1b83518bd5 --- /dev/null +++ b/e2e/card-view-component.e2e.ts @@ -0,0 +1,103 @@ +/*! + * @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 NavigationBarPage = require('./pages/adf/navigationBarPage'); + import TestConfig = require('./test.config'); + import resources = require('./util/resources'); + import AlfrescoApi = require('alfresco-js-api-node'); + import { UsersActions } from './actions/users.actions'; + import { AppsActions } from './actions/APS/apps.actions'; + import CardViewPageComponent = require('./pages/adf/cardViewPageComponent'); + import Util = require('./util/util'); + + describe('CardView Component', () => { + const loginPage = new LoginPage(); + const navigationBarPage = new NavigationBarPage(); + const cardViewPageComponent = new CardViewPageComponent(); + const app = resources.Files.APP_WITH_PROCESSES; + + beforeAll(async (done) => { + const apps = new AppsActions(); + const users = new UsersActions(); + + this.alfrescoJsApi = new AlfrescoApi({ + provider: 'BPM', + hostBpm: TestConfig.adf.url + }); + + await this.alfrescoJsApi.login(TestConfig.adf.adminEmail, TestConfig.adf.adminPassword); + + let user = await users.createTenantAndUser(this.alfrescoJsApi); + + await this.alfrescoJsApi.login(user.email, user.password); + + await apps.importPublishDeployApp(this.alfrescoJsApi, app.file_location); + + loginPage.loginToProcessServicesUsingUserModel(user); + + done(); + }); + + beforeEach(() => { + Util.refreshBrowser(); + }); + + it('[C279898] Register pairs values', () => { + navigationBarPage.clickCardViewButton(); + cardViewPageComponent.clickOnAddButton(); + cardViewPageComponent.setName('testName'); + cardViewPageComponent.setValue('testValue'); + cardViewPageComponent.clickOnAddButton(); + cardViewPageComponent.waitForOutput(); + expect(cardViewPageComponent.getOutputText(0)) + .toBe('[CardView Key-Value Pairs Item] - [{"name":"testName","value":"testValue"}]'); + + }); + + it('[C279898] Delete pairs values', () => { + navigationBarPage.clickCardViewButton(); + cardViewPageComponent.clickOnAddButton(); + cardViewPageComponent.setName('testName'); + cardViewPageComponent.setValue('testValue'); + cardViewPageComponent.clickOnAddButton(); + cardViewPageComponent.waitForOutput(); + expect(cardViewPageComponent.getOutputText(0)) + .toBe('[CardView Key-Value Pairs Item] - [{"name":"testName","value":"testValue"}]'); + cardViewPageComponent.deletePairsValues(); + expect(cardViewPageComponent.getOutputText(1)) + .toBe('[CardView Key-Value Pairs Item] - []'); + cardViewPageComponent.checkNameAndValueVisibility(0); + }); + + it('[C279899] Check default value ', () => { + navigationBarPage.clickCardViewButton(); + cardViewPageComponent.clickComboBox(); + expect(cardViewPageComponent.getSelectionValue()).toBe('One'); + + }); + + it('[C279899] Select combobox values', () => { + navigationBarPage.clickCardViewButton(); + cardViewPageComponent.clickComboBox(); + cardViewPageComponent.selectValueFromComboBox(1); + expect(cardViewPageComponent.getOutputText(0)) + .toBe('[CardView Select Item] - two'); + + }); + + }); diff --git a/e2e/pages/adf/cardViewPageComponent.js b/e2e/pages/adf/cardViewPageComponent.js new file mode 100644 index 0000000000..a628a852fa --- /dev/null +++ b/e2e/pages/adf/cardViewPageComponent.js @@ -0,0 +1,97 @@ +/*! + * @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 CardViewComponentPage = function (){ + + const addButton = element(by.className('card-view__key-value-pairs__add-btn')); + const keyValueRow = 'card-view__key-value-pairs__row'; + const selectValue = 'mat-option'; + const valueInputField = element(by.xpath("//*[contains(@id,'input') and @placeholder='Value']")); + const nameInputField = element(by.xpath("//*[contains(@id,'input') and @placeholder='Name']")); + const consoleLog = element(by.className('console')); + const deleteButton = element(by.className('card-view__key-value-pairs__remove-btn')); + const select = element(by.css('mat-select[data-automation-class="select-box"]')); + const listContent = element(by.className('mat-select-content')); + const selectedValue = element(by.css('.mat-select-value-text span')); + + this.clickOnAddButton = function() { + Util.waitUntilElementIsVisible(addButton); + addButton.click(); + return this; + }; + + this.setName = function(name) { + Util.waitUntilElementIsVisible(nameInputField); + nameInputField.sendKeys(name); + return this; + }; + + this.setValue = function(value) { + Util.waitUntilElementIsVisible(valueInputField); + valueInputField.sendKeys(value); + return this; + }; + + + this.waitForOutput = function(){ + Util.waitUntilElementIsVisible(consoleLog); + return this; + }; + + this.getOutputText = function(index){ + return consoleLog.all(by.css('p')).get(index).getText() + }; + + this.deletePairsValues = function(){ + Util.waitUntilElementIsVisible(deleteButton); + deleteButton.click(); + return this; + }; + + this.checkNameAndValueVisibility = (index) => { + Util.waitUntilElementIsNotOnPage(this.getKeyValueRow(index)); + return this; + }; + + this.getKeyValueRow = (index) => { + return element.all(by.css(keyValueRow)).get(index); + + }; + + this.getMatSelectValue = (index) => { + return element.all(by.className(selectValue)).get(index); + }; + + this.clickComboBox = () => { + select.click(); + Util.waitUntilElementIsVisible(listContent); + }; + + this.selectValueFromComboBox = (index) => { + this.getMatSelectValue(index).click(); + Util.waitUntilElementIsVisible(consoleLog); + return this; + }; + + this.getSelectionValue = () => { + return selectedValue.getText(); + }; + +} +module.exports = CardViewComponentPage; \ No newline at end of file diff --git a/e2e/pages/adf/navigationBarPage.js b/e2e/pages/adf/navigationBarPage.js index 4146443ad5..2d5ef4ec4e 100644 --- a/e2e/pages/adf/navigationBarPage.js +++ b/e2e/pages/adf/navigationBarPage.js @@ -27,6 +27,7 @@ var NavigationBarPage = function (){ var themeButton = element(by.css("button[data-automation-id='theme menu']")); var themeMenuContent = element(by.css("div[class*='mat-menu-panel']")); var logoutButton = element(by.css("a[adf-logout]")); + var cardViewButton = element(by.cssContainingText(".sidenav-menu-label","CardView")); /** * Click Content Services Button @@ -35,7 +36,7 @@ var NavigationBarPage = function (){ this.clickContentServicesButton = function (){ Util.waitUntilElementIsVisible(contentServicesButton); contentServicesButton.click(); - }; + }; /** * Click Process Services Button @@ -87,6 +88,15 @@ var NavigationBarPage = function (){ logoutButton.click(); }; + /** + * Click Card View Button + * @method clickCardViewButton + */ + this.clickCardViewButton = function(){ + Util.waitUntilElementIsVisible(cardViewButton); + cardViewButton.click(); + }; + }; module.exports = NavigationBarPage;