diff --git a/e2e/actions/APS/apps.actions.ts b/e2e/actions/APS/apps.actions.ts index 2dce26780c..60fba5cf1d 100644 --- a/e2e/actions/APS/apps.actions.ts +++ b/e2e/actions/APS/apps.actions.ts @@ -19,6 +19,29 @@ export class AppsActions { return appCreated; } + async publishDeployApp(alfrescoJsApi, appId) { + + let publishApp = await alfrescoJsApi.activiti.appsApi.publishAppDefinition(appId, new AppPublish()); + + let published = await alfrescoJsApi.activiti.appsApi.deployAppDefinitions({ appDefinitions: [{ id: publishApp.appDefinition.id }] }); + + return publishApp; + } + + async importNewVersionAppDefinitionPublishDeployApp(alfrescoJsApi, appFileLocation, modelId) { + + let pathFile = path.join(TestConfig.main.rootPath + appFileLocation); + let file = fs.createReadStream(pathFile); + + let appCreated = await alfrescoJsApi.activiti.appsApi.importNewAppDefinition(modelId, file); + + let publishApp = await alfrescoJsApi.activiti.appsApi.publishAppDefinition(appCreated.id, new AppPublish()); + + let published = await alfrescoJsApi.activiti.appsApi.deployAppDefinitions({ appDefinitions: [{ id: publishApp.appDefinition.id }] }); + + return appCreated; + } + async startProcess(alfrescoJsApi, app, processName) { let appDefinitionsList = await alfrescoJsApi.activiti.appsApi.getAppDefinitions(); diff --git a/e2e/actions/APS/models.actions.ts b/e2e/actions/APS/models.actions.ts new file mode 100644 index 0000000000..f7b9a1b937 --- /dev/null +++ b/e2e/actions/APS/models.actions.ts @@ -0,0 +1,20 @@ +import TestConfig = require('../../test.config'); +import AppPublish = require('../../models/APS/AppPublish'); + +export class ModelsActions { + + async deleteVersionModel(alfrescoJsApi, modelId) { + + let versionModelDeleted = await alfrescoJsApi.activiti.modelsApi.deleteModel(modelId, { cascade: false, deleteRuntimeApp : true }); + + return versionModelDeleted; + } + + async deleteEntireModel(alfrescoJsApi, modelId) { + + let modelDeleted = await alfrescoJsApi.activiti.modelsApi.deleteModel(modelId, { cascade: true, deleteRuntimeApp : true }); + + return modelDeleted; + } + +} diff --git a/e2e/apps-section.e2e.ts b/e2e/apps-section.e2e.ts index e3a741bf28..88e9230963 100644 --- a/e2e/apps-section.e2e.ts +++ b/e2e/apps-section.e2e.ts @@ -20,6 +20,7 @@ import ProcessServicesPage = require('./pages/adf/process_services/processServic import NavigationBarPage = require('./pages/adf/navigationBarPage'); import CONSTANTS = require('./util/constants'); +import Util = require('./util/util'); import TestConfig = require('./test.config'); import resources = require('./util/resources'); @@ -27,16 +28,22 @@ 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 { ModelsActions } from './actions/APS/models.actions'; +import AppPublish = require('./models/APS/AppPublish'); -describe('Attachment list', () => { +describe('Modify applications', () => { let loginPage = new LoginPage(); let navigationBarPage = new NavigationBarPage(); let processServicesPage = new ProcessServicesPage(); let app = resources.Files.APP_WITH_PROCESSES; + let appTobeDeleted = resources.Files.SIMPLE_APP_WITH_USER_FORM; + let replacingApp = resources.Files.WIDGETS_SMOKE_TEST; + let apps = new AppsActions(); + let modelActions = new ModelsActions(); + let firstApp, appVersionToBeDeleted; - beforeAll(async (done) => { - let apps = new AppsActions(); + beforeAll(async(done) => { let users = new UsersActions(); this.alfrescoJsApi = new AlfrescoApi({ @@ -50,21 +57,92 @@ describe('Attachment list', () => { await this.alfrescoJsApi.login(user.email, user.password); - await apps.importPublishDeployApp(this.alfrescoJsApi, app.file_location); + firstApp = await apps.importPublishDeployApp(this.alfrescoJsApi, app.file_location); + appVersionToBeDeleted = await apps.importPublishDeployApp(this.alfrescoJsApi, appTobeDeleted.file_location); loginPage.loginToProcessServicesUsingUserModel(user); done(); }); - it('[C260198] Publish on ADF side', () => { + it('[C260198] Should the app be displayed on dashboard when is deployed on APS', () => { navigationBarPage.clickProcessServicesButton(); processServicesPage.checkApsContainer(); - expect(processServicesPage.getAppIconType(app.title)).toEqual('ac_unit'); + expect(processServicesPage.getAppIconType(app.title)).toEqual(CONSTANTS.APP_ICON.UNIT); expect(processServicesPage.getBackgroundColor(app.title)).toEqual(CONSTANTS.APP_COLOR.BLUE); - expect(processServicesPage.getDescription(app.title)).toEqual('Description for app'); + expect(processServicesPage.getDescription(app.title)).toEqual(app.description); + }); + + it('[C260213] Should a new version of the app be displayed on dashboard when is replaced by importing another app in APS', async() => { + navigationBarPage.clickProcessServicesButton(); + + processServicesPage.checkApsContainer(); + + expect(processServicesPage.getAppIconType(app.title)).toEqual(CONSTANTS.APP_ICON.UNIT); + expect(processServicesPage.getBackgroundColor(app.title)).toEqual(CONSTANTS.APP_COLOR.BLUE); + expect(processServicesPage.getDescription(app.title)).toEqual(app.description); + + browser.controlFlow().execute(() => { + return apps.importNewVersionAppDefinitionPublishDeployApp(this.alfrescoJsApi, replacingApp.file_location, firstApp.id); + }); + + Util.refreshBrowser(); + + processServicesPage.checkApsContainer(); + + expect(processServicesPage.getAppIconType(app.title)).toEqual(CONSTANTS.APP_ICON.FAVORITE); + expect(processServicesPage.getBackgroundColor(app.title)).toEqual(CONSTANTS.APP_COLOR.GREY); + expect(processServicesPage.getDescription(app.title)).toEqual(app.description); + }); + + it('[C260220] Should the app not be displayed on dashboard after it was deleted in APS', async() => { + navigationBarPage.clickProcessServicesButton(); + + processServicesPage.checkApsContainer(); + + processServicesPage.checkAppIsDisplayed(app.title); + + browser.controlFlow().execute(() => { + return modelActions.deleteEntireModel(this.alfrescoJsApi, firstApp.id); + }); + + Util.refreshBrowser(); + + processServicesPage.checkApsContainer(); + processServicesPage.checkAppIsNotDisplayed(app.title); + }); + + it('[C260215] Should the penultimate version of an app be displayed on dashboard when the last version is deleted in APS', async() => { + navigationBarPage.clickProcessServicesButton(); + + processServicesPage.checkApsContainer(); + + processServicesPage.checkAppIsDisplayed(appTobeDeleted.title); + expect(processServicesPage.getBackgroundColor(appTobeDeleted.title)).toEqual(CONSTANTS.APP_COLOR.ORANGE); + + browser.controlFlow().execute(() => { + return apps.importNewVersionAppDefinitionPublishDeployApp(this.alfrescoJsApi, replacingApp.file_location, appVersionToBeDeleted.id); + }); + + Util.refreshBrowser(); + + processServicesPage.getBackgroundColor(appTobeDeleted.title); + + expect(processServicesPage.getBackgroundColor(appTobeDeleted.title)).toEqual(CONSTANTS.APP_COLOR.GREY); + + browser.controlFlow().execute(async() => { + await modelActions.deleteVersionModel(this.alfrescoJsApi, appVersionToBeDeleted.id); + await modelActions.deleteVersionModel(this.alfrescoJsApi, appVersionToBeDeleted.id); + await apps.publishDeployApp(this.alfrescoJsApi, appVersionToBeDeleted.id); + }); + + Util.refreshBrowser(); + + processServicesPage.checkApsContainer(); + processServicesPage.checkAppIsDisplayed(appTobeDeleted.title); + expect(processServicesPage.getBackgroundColor(appTobeDeleted.title)).toEqual(CONSTANTS.APP_COLOR.ORANGE); }); }); diff --git a/e2e/pages/adf/process_services/processServicesPage.js b/e2e/pages/adf/process_services/processServicesPage.js index cd4fbed34e..2a99394e07 100644 --- a/e2e/pages/adf/process_services/processServicesPage.js +++ b/e2e/pages/adf/process_services/processServicesPage.js @@ -77,9 +77,7 @@ var ProcessServicesPage = function(){ this.getBackgroundColor = function(applicationName) { var app = element(by.css("mat-card[title='" + applicationName +"']")); Util.waitUntilElementIsVisible(app); - return app.getCssValue("color").then(function (value) { - return value; - }); + return app.getCssValue("background-color"); }; this.getDescription = function(applicationName) { @@ -90,6 +88,16 @@ var ProcessServicesPage = function(){ return description.getText(); }; + this.checkAppIsNotDisplayed = function(applicationName) { + var app = element(by.css("mat-card[title='" + applicationName +"']")); + return Util.waitUntilElementIsNotOnPage(app); + }; + + this.checkAppIsDisplayed = function(applicationName) { + var app = element(by.css("mat-card[title='" + applicationName +"']")); + return Util.waitUntilElementIsVisible(app); + }; + }; module.exports = ProcessServicesPage; diff --git a/e2e/util/constants.js b/e2e/util/constants.js index e30da4acfe..71f75c8665 100644 --- a/e2e/util/constants.js +++ b/e2e/util/constants.js @@ -110,7 +110,14 @@ exports.THEMING = { }; exports.APP_COLOR = { - BLUE: "rgba(0, 0, 0, 0.87)" + BLUE: "rgba(38, 154, 188, 1)", + GREY: "rgba(105, 108, 103, 1)", + ORANGE: "rgba(250, 185, 108, 1)" +}; + +exports.APP_ICON = { + FAVORITE: "favorite_border", + UNIT: "ac_unit" }; exports.PROCESSENDDATE = "No date";