alfresco-ng2-components/e2e/process-services/attach-file-widget.e2e.ts
Maurizio Vitale 3fc9390666 [ADF-4909] e2e - Move the resources as part of protractor params (#5086)
* Move the resources as part of protractor params

* Revert replace mistakes

* Remove the resources imports

* fix resources import
2019-10-10 10:22:11 +01:00

96 lines
3.8 KiB
TypeScript

/*!
* @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 } from '@alfresco/adf-testing';
import { TasksPage } from '../pages/adf/process-services/tasksPage';
import CONSTANTS = require('../util/constants');
import { FileModel } from '../models/ACS/fileModel';
import { browser } from 'protractor';
import { ViewerPage } from '../pages/adf/viewerPage';
import { AppsActions } from '../actions/APS/apps.actions';
import { NavigationBarPage } from '../pages/adf/navigationBarPage';
import { AlfrescoApiCompatibility as AlfrescoApi } from '@alfresco/js-api';
import { UsersActions } from '../actions/users.actions';
describe('Start Task - Task App', () => {
const loginPage = new LoginPage();
const viewerPage = new ViewerPage();
const widget = new Widget();
const taskPage = new TasksPage();
const navigationBarPage = new NavigationBarPage();
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);
});
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('[C274690] Should be able to open a file attached to a start form', 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.addForm(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);
await widget.attachFileWidget().viewFile(pdfFile.name);
await viewerPage.checkFileContent('1', pdfFile.firstPageText);
await viewerPage.checkCloseButtonIsDisplayed();
await viewerPage.clickCloseButton();
await taskPage.tasksListPage().checkContentIsDisplayed('View file');
});
});