diff --git a/e2e/process-services/attach-folder.e2e.ts b/e2e/process-services/attach-folder.e2e.ts new file mode 100644 index 0000000000..68b64c136d --- /dev/null +++ b/e2e/process-services/attach-folder.e2e.ts @@ -0,0 +1,120 @@ +/*! + * @license + * Copyright 2019 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + ApplicationService, + ContentNodeSelectorDialogPage, + IntegrationService, + LoginPage, + Widget +} from '@alfresco/adf-testing'; +import { TasksPage } from '../pages/adf/process-services/tasks.page'; +import { browser } from 'protractor'; +import { NavigationBarPage } from '../pages/adf/navigation-bar.page'; +import { AlfrescoApiCompatibility as AlfrescoApi } from '@alfresco/js-api'; +import { UsersActions } from '../actions/users.actions'; +import { User } from '../models/APS/user'; +import CONSTANTS = require('../util/constants'); + +describe('Attach Folder', () => { + this.alfrescoJsApi = new AlfrescoApi({ + provider: 'ALL', + hostEcm: browser.params.testConfig.adf_acs.host, + hostBpm: browser.params.testConfig.adf_aps.host + }); + const integrationService = new IntegrationService(this.alfrescoJsApi); + const applicationService = new ApplicationService(this.alfrescoJsApi); + + const users = new UsersActions(); + const loginPage = new LoginPage(); + const widget = new Widget(); + const taskPage = new TasksPage(); + const navigationBarPage = new NavigationBarPage(); + const contentNodeSelector = new ContentNodeSelectorDialogPage(); + + const app = browser.params.resources.Files.WIDGET_CHECK_APP; + const meetingNotes = 'Meeting Notes'; + const { adminEmail, adminPassword } = browser.params.testConfig.adf; + let user: User; + + beforeAll(async () => { + await this.alfrescoJsApi.login(adminEmail, adminPassword); + user = await users.createTenantAndUser(this.alfrescoJsApi); + const acsUser = { ...user, id: user.email }; delete acsUser.type; delete acsUser.tenantId; + await this.alfrescoJsApi.core.peopleApi.addPerson(acsUser); + + const repository = { + name: 'adf dev', + tenantId: user.tenantId, + alfrescoTenantId: '', + repositoryUrl: `${browser.params.testConfig.adf_acs.host}/alfresco`, + shareUrl: `${browser.params.testConfig.adf_acs.host}/share`, + version: '4.2', + useShareConnector: false + }; + + await integrationService.addCSIntegration(repository); + await this.alfrescoJsApi.login(user.email, user.password); + await applicationService.importPublishDeployApp(app.file_path); + await loginPage.loginToAllUsingUserModel(user); + }); + + afterAll(async () => { + await this.alfrescoJsApi.login(adminEmail, adminPassword); + await this.alfrescoJsApi.activiti.adminTenantsApi.deleteTenant(user.tenantId); + }); + + it('[C246534] Attach folder - ACS', async () => { + await (await (await navigationBarPage.navigateToProcessServicesPage()).goToTaskApp()).clickTasksButton(); + await taskPage.filtersPage().goToFilter(CONSTANTS.TASK_FILTERS.MY_TASKS); + await taskPage.createTask({ name: 'Attach folder', formName: app.UPLOAD_FOLDER_FORM_CS.formName }); + + const contentFileWidget = widget.attachFolderWidget(); + await contentFileWidget.clickWidget(app.UPLOAD_FOLDER_FORM_CS.FIELD.widget_id); + + await contentNodeSelector.checkDialogIsDisplayed(); + + await contentNodeSelector.typeIntoNodeSelectorSearchField(user.email); + await contentNodeSelector.contentListPage().dataTablePage().checkRowContentIsDisplayed(user.email); + await contentNodeSelector.clickContentNodeSelectorResult(user.email); + await expect(await contentNodeSelector.checkCancelButtonIsEnabled()).toBe(true); + await expect(await contentNodeSelector.checkCopyMoveButtonIsEnabled()).toBe(true); + + await contentNodeSelector.typeIntoNodeSelectorSearchField(meetingNotes); + await contentNodeSelector.contentListPage().dataTablePage().checkRowContentIsDisplayed(meetingNotes); + await contentNodeSelector.clickContentNodeSelectorResult(meetingNotes); + await expect(await contentNodeSelector.checkCancelButtonIsEnabled()).toBe(true); + await expect(await contentNodeSelector.checkCopyMoveButtonIsEnabled()).toBe(false); + + await contentNodeSelector.clickCancelButton(); + await widget.attachFolderWidget().checkFolderIsNotAttached(app.UPLOAD_FOLDER_FORM_CS.FIELD.widget_id, user.email); + + await contentFileWidget.clickWidget(app.UPLOAD_FOLDER_FORM_CS.FIELD.widget_id); + await contentNodeSelector.checkDialogIsDisplayed(); + + await contentNodeSelector.typeIntoNodeSelectorSearchField(user.email); + await contentNodeSelector.contentListPage().dataTablePage().checkRowContentIsDisplayed(user.email); + await contentNodeSelector.clickContentNodeSelectorResult(user.email); + await expect(await contentNodeSelector.checkCancelButtonIsEnabled()).toBe(true); + await expect(await contentNodeSelector.checkCopyMoveButtonIsEnabled()).toBe(true); + + await contentNodeSelector.clickMoveCopyButton(); + await widget.attachFolderWidget().checkFolderIsAttached(app.UPLOAD_FOLDER_FORM_CS.FIELD.widget_id, user.email); + await widget.attachFolderWidget().removeFolder(app.UPLOAD_FOLDER_FORM_CS.FIELD.widget_id, user.email); + await widget.attachFolderWidget().checkFolderIsNotAttached(app.UPLOAD_FOLDER_FORM_CS.FIELD.widget_id, user.email); + }); +}); diff --git a/e2e/resources/apps/WidgetApps.zip b/e2e/resources/apps/WidgetApps.zip index 97e19e4d7b..80ff15fe13 100644 Binary files a/e2e/resources/apps/WidgetApps.zip and b/e2e/resources/apps/WidgetApps.zip differ diff --git a/e2e/util/resources.js b/e2e/util/resources.js index ef5addac21..eb6721cf2e 100644 --- a/e2e/util/resources.js +++ b/e2e/util/resources.js @@ -391,6 +391,13 @@ exports.Files = { searchTerm: 'One', result: [ '123456789 - Customer Number One' ] } + }, + + UPLOAD_FOLDER_FORM_CS: { + formName: "upload-folder-cs", + FIELD: { + widget_id: 'attachfolder', + } } }, diff --git a/lib/testing/src/lib/core/actions/APS/integration.service.ts b/lib/testing/src/lib/core/actions/APS/integration.service.ts new file mode 100644 index 0000000000..4f9bddbfa2 --- /dev/null +++ b/lib/testing/src/lib/core/actions/APS/integration.service.ts @@ -0,0 +1,47 @@ +/*! + * @license + * Copyright 2019 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AlfrescoApiCompatibility as AlfrescoApi } from '@alfresco/js-api'; + +export interface IntegrationType { + name: string; + tenantId: number; + alfrescoTenantId: string; + repositoryUrl: string; + shareUrl: string; + version: string; + useShareConnector: boolean; +} + +export class IntegrationService { + api: AlfrescoApi; + + constructor(api: AlfrescoApi) { + this.api = api; + } + + addCSIntegration(body: IntegrationType): Promise { + return this.api.activiti.integrationAccountApi.apiClient.callApi('app/rest/integration/alfresco', 'POST', + {}, {}, {}, {}, body, [], [], Object); + } + + authenticateRepositary(id: number, body: { username: string, password: string }): Promise { + return this.api.activiti.integrationAccountApi.apiClient.callApi(`app/rest/integration/alfresco/${id}/account`, 'POST', + {}, {}, {}, body, {}, [], []); + } + +} diff --git a/lib/testing/src/lib/core/actions/APS/public-api.ts b/lib/testing/src/lib/core/actions/APS/public-api.ts index 508e260424..ec85e7680c 100644 --- a/lib/testing/src/lib/core/actions/APS/public-api.ts +++ b/lib/testing/src/lib/core/actions/APS/public-api.ts @@ -17,3 +17,4 @@ export * from './applications.service'; export * from './models.service'; +export * from './integration.service'; diff --git a/lib/testing/src/lib/core/pages/form/widgets/attach-folder-widget.page.ts b/lib/testing/src/lib/core/pages/form/widgets/attach-folder-widget.page.ts new file mode 100644 index 0000000000..88fc855f91 --- /dev/null +++ b/lib/testing/src/lib/core/pages/form/widgets/attach-folder-widget.page.ts @@ -0,0 +1,58 @@ +/*! + * @license + * Copyright 2019 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as remote from 'selenium-webdriver/remote'; +import { browser, by, element } from 'protractor'; +import { FormFields } from '../form-fields'; +import { BrowserActions, BrowserVisibility } from '../../../utils/public-api'; + +export class AttachFolderWidgetPage { + + formFields: FormFields = new FormFields(); + foldersListLocator = by.css('.adf-attach-folder-result'); + + async clickWidget(fieldId: string): Promise { + browser.setFileDetector(new remote.FileDetector()); + const widget = await this.formFields.getWidget(fieldId).element(by.css(`button[id="folder-${fieldId}-button"]`)); + await BrowserActions.click(widget); + } + + async checkFolderIsAttached(fieldId, name): Promise { + const widget = await this.formFields.getWidget(fieldId); + const folderAttached = widget.element(this.foldersListLocator).element(by.cssContainingText('span', name)); + await BrowserVisibility.waitUntilElementIsVisible(folderAttached); + } + + async checkFolderIsNotAttached(fieldId, name): Promise { + const widget = await this.formFields.getWidget(fieldId); + const folderAttached = widget.element(this.foldersListLocator).element(by.cssContainingText('span', name)); + await BrowserVisibility.waitUntilElementIsNotPresent(folderAttached); + } + + async attachFileWidgetDisplayed(id: string): Promise { + const locator = element(by.css(id ? id : '#attachfolder')); + await BrowserVisibility.waitUntilElementIsVisible(locator); + } + + async removeFolder(fieldId: string, name: string): Promise { + await this.checkFolderIsAttached(fieldId, name); + const widget = await this.formFields.getWidget(fieldId); + const folderToBeRemoved = widget.element(this.foldersListLocator).element(by.css(`[id="folder-${fieldId}-remove"]`)); + await BrowserActions.click(folderToBeRemoved); + } + +} diff --git a/lib/testing/src/lib/core/pages/form/widgets/widget.ts b/lib/testing/src/lib/core/pages/form/widgets/widget.ts index 2db2d90f97..cceacce75f 100644 --- a/lib/testing/src/lib/core/pages/form/widgets/widget.ts +++ b/lib/testing/src/lib/core/pages/form/widgets/widget.ts @@ -36,6 +36,7 @@ import { TabPage } from './tab.page'; import { DocumentWidgetPage } from './document-widget.page'; import { GroupWidgetPage } from './group-widget.page'; import { TypeaheadWidgetPage } from './typeahead-widget.page'; +import { AttachFolderWidgetPage } from './attach-folder-widget.page'; export class Widget { @@ -55,6 +56,10 @@ export class Widget { return new AttachFileWidgetPage(); } + attachFolderWidget(): AttachFolderWidgetPage { + return new AttachFolderWidgetPage(); + } + displayValueWidget(): DisplayValueWidgetPage { return new DisplayValueWidgetPage(); }