From decfa37003a45d8425b9e5d0f5fec7c4be6bd7af Mon Sep 17 00:00:00 2001 From: jdosti Date: Tue, 11 Sep 2018 17:43:45 +0100 Subject: [PATCH] [ADF-3535] Create automated test for Unshared file (#3773) --- e2e/content-services/unshare_file.e2e.ts | 98 ++++++++++++++++++++++++ e2e/pages/adf/contentServicesPage.js | 40 ++++++---- e2e/pages/adf/dialog/shareDialog.ts | 46 +++++++++++ 3 files changed, 167 insertions(+), 17 deletions(-) create mode 100644 e2e/content-services/unshare_file.e2e.ts create mode 100644 e2e/pages/adf/dialog/shareDialog.ts diff --git a/e2e/content-services/unshare_file.e2e.ts b/e2e/content-services/unshare_file.e2e.ts new file mode 100644 index 0000000000..80688de83b --- /dev/null +++ b/e2e/content-services/unshare_file.e2e.ts @@ -0,0 +1,98 @@ +/*! + * @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 ContentListPage = require('../pages/adf/dialog/contentList'); +import ErrorPage = require('../pages/adf/errorPage'); +import { ShareDialog } from '../pages/adf/dialog/shareDialog'; + +import AcsUserModel = require('../models/ACS/acsUserModel'); +import FileModel = require('../models/ACS/fileModel'); + +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 { browser } from "protractor"; + +describe('Unshare file', () => { + + const loginPage = new LoginPage(); + const contentServicesPage = new ContentServicesPage(); + const contentListPage = new ContentListPage(); + const errorPage = new ErrorPage(); + const shareDialog = new ShareDialog(); + + let acsUser = new AcsUserModel(); + let uploadActions = new UploadActions(); + + let pngFileModel = new FileModel({ + 'name': resources.Files.ADF_DOCUMENTS.PNG.file_name, + 'location': resources.Files.ADF_DOCUMENTS.PNG.file_location + }); + + let nodeId; + + beforeAll(async(done) => { + 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); + + let pngUploadedFile = await uploadActions.uploadFile(this.alfrescoJsApi, pngFileModel.location, pngFileModel.name, '-my-'); + + nodeId = pngUploadedFile.entry.id; + + loginPage.loginToContentServicesUsingUserModel(acsUser); + + contentServicesPage.navigateToDocumentList(); + + done(); + }); + + afterAll(async(done) =>{ + await uploadActions.deleteFilesOrFolder(this.alfrescoJsApi, nodeId); + + done(); + }); + + it('[C280556] Unshared file should show 404 page', async()=> { + contentListPage.clickRowToSelect(pngFileModel.name); + + contentServicesPage.clickShareButton(); + + shareDialog.checkDialogIsDisplayed(); + shareDialog.clickShareToggle(); + shareDialog.checkShareLinkIsDisplayed(); + + let sharedLink = await shareDialog.getShareLink(); + + shareDialog.clickShareToggle(); + + browser.get(sharedLink); + + errorPage.checkErrorPage(); + }); +}); diff --git a/e2e/pages/adf/contentServicesPage.js b/e2e/pages/adf/contentServicesPage.js index 2d4c8073b7..2b41a1fd86 100644 --- a/e2e/pages/adf/contentServicesPage.js +++ b/e2e/pages/adf/contentServicesPage.js @@ -59,6 +59,7 @@ var ContentServicesPage = function () { var cardViewContainer = element(by.css("div.document-list-container div.adf-data-table-card")); var copyButton = element(by.css('button[data-automation-id="content-node-selector-actions-choose"]')); var searchInputElement = element(by.css('input[data-automation-id="content-node-selector-search-input"')); + var shareNodeButton = element(by.cssContainingText("mat-icon", " share ")); this.checkRecentFileToBeShowed = function () { Util.waitUntilElementIsVisible(recentFiles); @@ -513,51 +514,51 @@ var ContentServicesPage = function () { let iconRow = element(by.css(`.document-list-container div.adf-data-table-cell[filename="${fileName}"] img`)); Util.waitUntilElementIsVisible(iconRow); return iconRow; - } + }; this.getRowIconImageUrl = async function(fileName) { let iconRow = this.checkIconForRowIsDisplayed(fileName); return iconRow.getAttribute('src'); - } + }; this.checkGridViewButtonIsVisible = function () { Util.waitUntilElementIsVisible(gridViewButton); - } + }; this.clickGridViewButton = function() { this.checkGridViewButtonIsVisible(); gridViewButton.click(); - } + }; this.checkCardViewContainerIsDisplayed = function () { Util.waitUntilElementIsVisible(cardViewContainer); - } + }; this.getCardElementShowedInPage = function() { this.checkCardViewContainerIsDisplayed(); let actualCards = $$('div.document-list-container div.adf-data-table-card div.cell-value img').count(); return actualCards; - } + }; this.getDocumentCardIconForElement = function(elementName){ let elementIcon = element(by.css(`.document-list-container div.adf-data-table-cell[filename="${elementName}"] img`)); return elementIcon.getAttribute('src'); - } + }; this.checkDocumentCardPropertyIsShowed = function(elementName, propertyName) { let elementProperty = element(by.css(`.document-list-container div.adf-data-table-cell[filename="${elementName}"][title="${propertyName}"]`)); Util.waitUntilElementIsVisible(elementProperty); - } + }; this.getAttributeValueForElement = function(elementName, propertyName) { let elementSize = element(by.css(`.document-list-container div.adf-data-table-cell[filename="${elementName}"][title="${propertyName}"] span`)); return elementSize.getText(); - } + }; this.checkMenuIsShowedForElementIndex = function(elementIndex) { let elementMenu = element(by.css(`button[data-automation-id="action_menu_${elementIndex}"]`)); Util.waitUntilElementIsVisible(elementMenu); - } + }; this.navigateToCardFolder = function(folderName) { let folderCard = element(by.css(`.document-list-container div.image-table-cell.adf-data-table-cell[filename="${folderName}"]`)); @@ -565,13 +566,13 @@ var ContentServicesPage = function () { let folderSelected = element(by.css(`.adf-datatable-row.is-selected div[filename="${folderName}"].adf-data-table-cell--image`)); Util.waitUntilElementIsVisible(folderSelected); browser.actions().sendKeys(protractor.Key.ENTER).perform(); - } + }; this.getGridViewSortingDropdown = function() { let sortingDropdown = element(by.css('mat-select[data-automation-id="grid-view-sorting"]')); Util.waitUntilElementIsVisible(sortingDropdown); return sortingDropdown; - } + }; this.selectGridSortingFromDropdown = function(sortingChosen){ let dropdownSorting = this.getGridViewSortingDropdown(); @@ -579,28 +580,33 @@ var ContentServicesPage = function () { let optionToClick = element(by.css(`mat-option[data-automation-id="grid-view-sorting-${sortingChosen}"]`)); Util.waitUntilElementIsPresent(optionToClick); optionToClick.click(); - } + }; this.checkRowIsDisplayed = function(rowName){ let row = contentList.getRowByRowName(rowName); Util.waitUntilElementIsVisible(row); - } + }; this.typeIntoNodeSelectorSearchField = function(text) { Util.waitUntilElementIsVisible(searchInputElement); searchInputElement.sendKeys(text); - } + }; this.clickContentNodeSelectorResult = function(name){ let resultElement = element.all(by.css(`div[data-automation-id="content-node-selector-content-list"] div[filename="${name}"`)).first(); Util.waitUntilElementIsVisible(resultElement); resultElement.click(); - } + }; this.clickCopyButton = function(){ Util.waitUntilElementIsClickable(copyButton); copyButton.click(); - } + }; + + this.clickShareButton = function(){ + Util.waitUntilElementIsClickable(shareNodeButton); + shareNodeButton.click(); + }; }; module.exports = ContentServicesPage; diff --git a/e2e/pages/adf/dialog/shareDialog.ts b/e2e/pages/adf/dialog/shareDialog.ts new file mode 100644 index 0000000000..38166ebb71 --- /dev/null +++ b/e2e/pages/adf/dialog/shareDialog.ts @@ -0,0 +1,46 @@ +/*! + * @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 } from 'protractor'; +import Util = require('../../../util/util'); + +export class ShareDialog { + + dialogTitle = element(by.id('adf-share-title')); + shareToggle = element(by.id('adf-share-toggle')); + shareLink = element(by.id('adf-share-link')); + + checkDialogIsDisplayed() { + return Util.waitUntilElementIsVisible(this.dialogTitle); + } + + clickShareToggle() { + Util.waitUntilElementIsVisible(this.shareToggle); + Util.waitUntilElementIsClickable(this.shareToggle); + return this.shareToggle.click(); + + } + + checkShareLinkIsDisplayed() { + return Util.waitUntilElementIsVisible(this.shareLink); + } + + getShareLink() { + Util.waitUntilElementIsVisible(this.shareLink) + return this.shareLink.getAttribute('value'); + } +}