diff --git a/e2e/content-services/document-list/document-list-pagination.e2e.ts b/e2e/content-services/document-list/document-list-pagination.e2e.ts index 6f38421399..0276b17c7e 100644 --- a/e2e/content-services/document-list/document-list-pagination.e2e.ts +++ b/e2e/content-services/document-list/document-list-pagination.e2e.ts @@ -382,8 +382,7 @@ describe('Document List - Pagination', () => { await contentServicesPage.selectFolderWithCommandKey('subfolder6'); await contentServicesPage.clickDownloadButton(); - await expect(await FileBrowserUtil.isFileDownloaded('subfolder6.zip') - ).toBe(true, `subfolder6 not downloaded`); + await FileBrowserUtil.isFileDownloaded('subfolder6.zip'); await contentServicesPage.deleteSubFolderUnderRoot(newFolderModel.name, folderTwoModel.name); }); diff --git a/e2e/content-services/sso/sso-download-directive-component.e2e.ts b/e2e/content-services/sso/sso-download-directive-component.e2e.ts index 19fe8d855b..dfcfdf7687 100644 --- a/e2e/content-services/sso/sso-download-directive-component.e2e.ts +++ b/e2e/content-services/sso/sso-download-directive-component.e2e.ts @@ -128,7 +128,7 @@ describe('SSO in ADF using ACS and AIS, Download Directive, Viewer, DocumentList it('[C291936] Should be able to download a file', async () => { await contentListPage.selectRow(pngFileModel.name); await contentServicesPage.clickDownloadButton(); - await expect(await FileBrowserUtil.isFileDownloaded(pngFileModel.name)).toBe(true, `${pngFileModel.name} not downloaded`); + await FileBrowserUtil.isFileDownloaded(pngFileModel.name); }); it('[C291938] Should be able to open a document', async () => { @@ -154,7 +154,7 @@ describe('SSO in ADF using ACS and AIS, Download Directive, Viewer, DocumentList await contentListPage.dataTablePage().checkRowIsChecked('Display name', pngFileModel.name); await contentListPage.dataTablePage().checkRowIsChecked('Display name', firstPdfFileModel.name); await contentServicesPage.clickDownloadButton(); - await expect(await FileBrowserUtil.isFileDownloaded('archive.zip')).toBe(true, `archive.zip not downloaded`); + await FileBrowserUtil.isFileDownloaded('archive.zip'); }); it('[C291940] Should be able to view thumbnails when enabled', async () => { diff --git a/e2e/content-services/version/version-actions.e2e.ts b/e2e/content-services/version/version-actions.e2e.ts index 1be455965f..a4f104ad6e 100644 --- a/e2e/content-services/version/version-actions.e2e.ts +++ b/e2e/content-services/version/version-actions.e2e.ts @@ -107,9 +107,9 @@ describe('Version component actions', () => { it('[C269081] Should be possible download all the version of a file', async () => { await versionManagePage.downloadFileVersion('1.0'); - await expect(await FileBrowserUtil.isFileDownloaded(txtFileModel.name)).toBe(true, `${txtFileModel.name} not downloaded`); + await FileBrowserUtil.isFileDownloaded(txtFileModel.name); await versionManagePage.downloadFileVersion('1.1'); - await expect(await FileBrowserUtil.isFileDownloaded(fileModelVersionTwo.name)).toBe(true, `${fileModelVersionTwo.name} not downloaded`); + await FileBrowserUtil.isFileDownloaded(fileModelVersionTwo.name); }); it('[C272819] Should be possible delete a version when click on delete version action', async () => { diff --git a/e2e/process-services-cloud/start-task-form-cloud.e2e.ts b/e2e/process-services-cloud/start-task-form-cloud.e2e.ts index 698a315a30..35f35370cd 100644 --- a/e2e/process-services-cloud/start-task-form-cloud.e2e.ts +++ b/e2e/process-services-cloud/start-task-form-cloud.e2e.ts @@ -528,7 +528,7 @@ describe('Start Task Form', () => { await contentFileWidget.checkFileIsAttached(testFileModel.name); await contentFileWidget.downloadFile(testFileModel.name); - await expect(await FileBrowserUtil.isFileDownloaded(testFileModel.name)).toBe(true); + await FileBrowserUtil.isFileDownloaded(testFileModel.name); const taskId = await taskHeaderCloudPage.getId(); await taskFormCloudComponent.clickCompleteButton(); @@ -540,7 +540,7 @@ describe('Start Task Form', () => { await tasksCloudDemoPage.taskListCloudComponent().selectRowByTaskId(taskId); await contentFileWidget.checkFileIsAttached(testFileModel.name); await contentFileWidget.downloadFile(testFileModel.name); - await expect(await FileBrowserUtil.isFileDownloaded(testFileModel.name)).toBe(true); + await FileBrowserUtil.isFileDownloaded(testFileModel.name); }); }); }); diff --git a/e2e/process-services/process-attachment-list-action-menu.e2e.ts b/e2e/process-services/process-attachment-list-action-menu.e2e.ts index a3aa87b2e9..4d626236aa 100644 --- a/e2e/process-services/process-attachment-list-action-menu.e2e.ts +++ b/e2e/process-services/process-attachment-list-action-menu.e2e.ts @@ -113,7 +113,7 @@ describe('Attachment list action menu for processes', () => { await browser.sleep(1000); - await expect(await FileBrowserUtil.isFileDownloaded(downloadedPngFile)).toBe(true); + await FileBrowserUtil.isFileDownloaded(downloadedPngFile); await attachmentListPage.removeFile(pngFile.name); await attachmentListPage.checkFileIsRemoved(pngFile.name); @@ -146,7 +146,7 @@ describe('Attachment list action menu for processes', () => { await browser.sleep(1000); - await expect(await FileBrowserUtil.isFileDownloaded(downloadedPngFile)).toBe(true); + await FileBrowserUtil.isFileDownloaded(downloadedPngFile); await attachmentListPage.removeFile(pngFile.name); await attachmentListPage.checkFileIsRemoved(pngFile.name); diff --git a/e2e/process-services/start-process-component.e2e.ts b/e2e/process-services/start-process-component.e2e.ts index 51f4cca9a8..2e694422a9 100644 --- a/e2e/process-services/start-process-component.e2e.ts +++ b/e2e/process-services/start-process-component.e2e.ts @@ -328,7 +328,7 @@ describe('Start Process Component', () => { await processFiltersPage.selectFromProcessList('Audit Log'); await processDetailsPage.clickAuditLogButton(); - await expect(await FileBrowserUtil.isFileDownloaded(auditLogFile)).toBe(true); + await FileBrowserUtil.isFileDownloaded(auditLogFile); }); it('Should be able to attach a file using the button', async () => { diff --git a/e2e/process-services/task-attachment-list-action-menu.e2e.ts b/e2e/process-services/task-attachment-list-action-menu.e2e.ts index ab3bfb78ae..c16de72a28 100644 --- a/e2e/process-services/task-attachment-list-action-menu.e2e.ts +++ b/e2e/process-services/task-attachment-list-action-menu.e2e.ts @@ -96,7 +96,7 @@ describe('Attachment list action menu for tasks', () => { await browser.sleep(1000); - await expect(await FileBrowserUtil.isFileDownloaded(downloadedPngFile)).toBe(true); + await FileBrowserUtil.isFileDownloaded(downloadedPngFile); await attachmentListPage.removeFile(pngFile.name); await attachmentListPage.checkFileIsRemoved(pngFile.name); @@ -127,7 +127,7 @@ describe('Attachment list action menu for tasks', () => { await browser.sleep(1000); - await expect(await FileBrowserUtil.isFileDownloaded(downloadedPngFile)).toBe(true); + await FileBrowserUtil.isFileDownloaded(downloadedPngFile); await attachmentListPage.removeFile(pngFile.name); await attachmentListPage.checkFileIsRemoved(pngFile.name); diff --git a/e2e/process-services/task-audit.e2e.ts b/e2e/process-services/task-audit.e2e.ts index c1f8af35dc..311b25466e 100644 --- a/e2e/process-services/task-audit.e2e.ts +++ b/e2e/process-services/task-audit.e2e.ts @@ -73,7 +73,7 @@ describe('Task Audit', () => { await taskPage.tasksListPage().checkContentIsDisplayed(taskTaskApp); await taskPage.taskDetails().clickAuditLogButton(); - await expect(await FileBrowserUtil.isFileDownloaded(auditLogFile)).toBe(true); + await FileBrowserUtil.isFileDownloaded(auditLogFile); }); it('[C260389] Should Audit file be downloaded when clicking on Task Audit log icon on a standalone completed task', async () => { @@ -88,7 +88,7 @@ describe('Task Audit', () => { await expect(await taskPage.formFields().getCompletedTaskNoFormMessage()).toEqual('Task ' + taskTaskApp + ' completed'); await taskPage.taskDetails().clickAuditLogButton(); - await expect(await FileBrowserUtil.isFileDownloaded(auditLogFile)).toBe(true); + await FileBrowserUtil.isFileDownloaded(auditLogFile); }); it('[C263944] Should Audit file be downloaded when clicking on Task Audit log icon on a custom app standalone completed task', async () => { @@ -105,7 +105,7 @@ describe('Task Audit', () => { await expect(await taskPage.formFields().getCompletedTaskNoFormMessage()).toEqual('Task ' + taskCompleteCustomApp + ' completed'); await taskPage.taskDetails().clickAuditLogButton(); - await expect(await FileBrowserUtil.isFileDownloaded(auditLogFile)).toBe(true); + await FileBrowserUtil.isFileDownloaded(auditLogFile); }); it('[C263943] Should Audit file be downloaded when clicking on Task Audit log icon on a custom app standalone running task', async () => { @@ -117,6 +117,6 @@ describe('Task Audit', () => { await taskPage.tasksListPage().checkContentIsDisplayed(taskCustomApp); await taskPage.taskDetails().clickAuditLogButton(); - await expect(await FileBrowserUtil.isFileDownloaded(auditLogFile)).toBe(true); + await FileBrowserUtil.isFileDownloaded(auditLogFile); }); }); diff --git a/e2e/process-services/widgets/attach-file-widget.e2e.ts b/e2e/process-services/widgets/attach-file-widget.e2e.ts new file mode 100644 index 0000000000..385113365a --- /dev/null +++ b/e2e/process-services/widgets/attach-file-widget.e2e.ts @@ -0,0 +1,125 @@ +/*! + * @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 { LoginPage, Widget, ViewerPage, FileBrowserUtil } from '@alfresco/adf-testing'; +import { TasksPage } from '../../pages/adf/process-services/tasks.page'; +import CONSTANTS = require('../../util/constants'); +import { FileModel } from '../../models/ACS/file.model'; +import { browser } from 'protractor'; +import { AppsActions } from '../../actions/APS/apps.actions'; +import { NavigationBarPage } from '../../pages/adf/navigation-bar.page'; +import { AlfrescoApiCompatibility as AlfrescoApi } from '@alfresco/js-api'; +import { UsersActions } from '../../actions/users.actions'; +import { TaskDetailsPage } from '../../pages/adf/process-services/task-details.page'; +import { TasksListPage } from '../../pages/adf/process-services/tasks-list.page'; +import { FiltersPage } from '../../pages/adf/process-services/filters.page'; + +describe('Attach widget - File', () => { + const loginPage = new LoginPage(); + const viewerPage = new ViewerPage(); + const widget = new Widget(); + const taskPage = new TasksPage(); + const navigationBarPage = new NavigationBarPage(); + const taskDetailsPage = new TaskDetailsPage(); + const tasksListPage = new TasksListPage(); + const filtersPage = new FiltersPage(); + + let processUserModel; + const app = browser.params.resources.Files.WIDGETS_SMOKE_TEST; + const pdfFile = new FileModel({'name': browser.params.resources.Files.ADF_DOCUMENTS.PDF.file_name}); + const appFields = app.form_fields; + + beforeAll(async () => { + const users = new UsersActions(); + const apps = new AppsActions(); + + this.alfrescoJsApi = new AlfrescoApi({ + provider: 'BPM', + hostBpm: browser.params.testConfig.adf_aps.host + }); + + await this.alfrescoJsApi.login(browser.params.testConfig.adf.adminEmail, browser.params.testConfig.adf.adminPassword); + processUserModel = await users.createTenantAndUser(this.alfrescoJsApi); + await this.alfrescoJsApi.login(processUserModel.email, processUserModel.password); + + await apps.importPublishDeployApp(this.alfrescoJsApi, app.file_location); + await loginPage.loginToProcessServicesUsingUserModel(processUserModel); + }); + + beforeEach(async () => { + await (await (await navigationBarPage.navigateToProcessServicesPage()).goToTaskApp()).clickTasksButton(); + + await taskPage.filtersPage().goToFilter(CONSTANTS.TASK_FILTERS.MY_TASKS); + + const newTask = await taskPage.createNewTask(); + await newTask.addName('View file'); + await newTask.selectForm(app.formName); + await newTask.clickStartButton(); + + await widget.attachFileWidget().attachFile(appFields.attachFile_id, browser.params.testConfig.main.rootPath + pdfFile.location); + await widget.attachFileWidget().checkFileIsAttached(appFields.attachFile_id, pdfFile.name); + }); + + afterAll(async () => { + this.alfrescoJsApi = new AlfrescoApi({ + provider: 'BPM', + hostBpm: browser.params.testConfig.adf_aps.host + }); + await this.alfrescoJsApi.login(browser.params.testConfig.adf.adminEmail, browser.params.testConfig.adf.adminPassword); + await this.alfrescoJsApi.activiti.adminTenantsApi.deleteTenant(processUserModel.tenantId); + }); + + it('[C268067] Should be able to preview, download and remove attached files from an active form', async () => { + await widget.attachFileWidget().toggleAttachedFileMenu(); + await widget.attachFileWidget().checkAttachFileOptionsActiveForm(); + + await widget.attachFileWidget().viewAttachedFile(); + await viewerPage.checkFileContent('1', pdfFile.firstPageText); + await viewerPage.checkCloseButtonIsDisplayed(); + await viewerPage.clickCloseButton(); + + await widget.attachFileWidget().toggleAttachedFileMenu(); + await widget.attachFileWidget().downloadFile(); + await FileBrowserUtil.isFileDownloaded(pdfFile.name); + + await widget.attachFileWidget().toggleAttachedFileMenu(); + await widget.attachFileWidget().removeAttachedFile(); + await widget.attachFileWidget().attachFileWidgetDisplayed(); + }); + + it('[C268070] Should be able to preview and download files from a completed form', async () => { + await taskDetailsPage.checkCompleteFormButtonIsDisplayed(); + await taskDetailsPage.clickCompleteFormTask(); + + await tasksListPage.checkTaskListIsLoaded(); + await filtersPage.goToFilter('Completed Tasks'); + await tasksListPage.checkTaskListIsLoaded(); + await widget.attachFileWidget().checkFileIsAttached(appFields.attachFile_id, pdfFile.name); + + await widget.attachFileWidget().toggleAttachedFileMenu(); + await widget.attachFileWidget().checkAttachFileOptionsCompletedForm(); + + await widget.attachFileWidget().viewAttachedFile(); + await viewerPage.checkFileContent('1', pdfFile.firstPageText); + await viewerPage.checkCloseButtonIsDisplayed(); + await viewerPage.clickCloseButton(); + + await widget.attachFileWidget().toggleAttachedFileMenu(); + await widget.attachFileWidget().downloadFile(); + await FileBrowserUtil.isFileDownloaded(pdfFile.name); + }); +}); diff --git a/lib/testing/src/lib/core/pages/form/widgets/attach-file-widget.page.ts b/lib/testing/src/lib/core/pages/form/widgets/attach-file-widget.page.ts index 86dbad25fd..b9c809537b 100644 --- a/lib/testing/src/lib/core/pages/form/widgets/attach-file-widget.page.ts +++ b/lib/testing/src/lib/core/pages/form/widgets/attach-file-widget.page.ts @@ -26,6 +26,12 @@ export class AttachFileWidgetPage { uploadLocator = by.css('button[id="attachfile"]'); localStorageButton: ElementFinder = element(by.css('input[id="attachfile"]')); filesListLocator = by.css('div[id="adf-attach-widget-readonly-list"]'); + attachFileWidget: ElementFinder = element(by.css('#attachfile')); + attachedFileMenu: ElementFinder = element(by.css('mat-list-item button')); + attachedFileOptions: ElementFinder = element(by.css('.mat-menu-panel .mat-menu-content')); + viewFileOptionButton: ElementFinder = element(by.css(`.mat-menu-panel .mat-menu-content button[id$="show-file"]`)); + downloadFileOptionButton: ElementFinder = element(by.css(`.mat-menu-panel .mat-menu-content button[id$="download-file"]`)); + removeFileOptionButton: ElementFinder = element(by.css(`.mat-menu-panel .mat-menu-content button[id$="remove"]`)); async attachFile(fieldId, fileLocation): Promise { browser.setFileDetector(new remote.FileDetector()); @@ -47,4 +53,38 @@ export class AttachFileWidgetPage { await BrowserActions.click(fileView); await browser.actions().doubleClick(fileView).perform(); } + + async attachFileWidgetDisplayed(): Promise { + await BrowserVisibility.waitUntilElementIsVisible(this.attachFileWidget); + } + + async toggleAttachedFileMenu(): Promise { + await BrowserActions.click(this.attachedFileMenu); + } + + async checkAttachFileOptionsActiveForm(): Promise { + await BrowserVisibility.waitUntilElementIsVisible(this.attachedFileOptions); + await BrowserVisibility.waitUntilElementIsVisible(this.viewFileOptionButton); + await BrowserVisibility.waitUntilElementIsVisible(this.downloadFileOptionButton); + await BrowserVisibility.waitUntilElementIsVisible(this.removeFileOptionButton); + } + + async checkAttachFileOptionsCompletedForm(): Promise { + await BrowserVisibility.waitUntilElementIsVisible(this.attachedFileOptions); + await BrowserVisibility.waitUntilElementIsVisible(this.viewFileOptionButton); + await BrowserVisibility.waitUntilElementIsVisible(this.downloadFileOptionButton); + await BrowserVisibility.waitUntilElementIsNotVisible(this.removeFileOptionButton); + } + + async viewAttachedFile(): Promise { + await BrowserActions.click(this.viewFileOptionButton); + } + + async downloadFile(): Promise { + await BrowserActions.click(this.downloadFileOptionButton); + } + + async removeAttachedFile(): Promise { + await BrowserActions.click(this.removeFileOptionButton); + } } diff --git a/lib/testing/src/lib/core/utils/file-browser.util.ts b/lib/testing/src/lib/core/utils/file-browser.util.ts index 5e979f4a84..4fb7e69e21 100644 --- a/lib/testing/src/lib/core/utils/file-browser.util.ts +++ b/lib/testing/src/lib/core/utils/file-browser.util.ts @@ -28,7 +28,7 @@ export class FileBrowserUtil { return fs.existsSync(path.join(DEFAULT_ROOT_PATH, 'downloads', fileName)); }, 30000); - await expect(file).toBe(true); + await expect(file).toBe(true, `${fileName} not downloaded`); return !!file; }