diff --git a/e2e/core/viewer/viewer-component.e2e.ts b/e2e/core/viewer/viewer-component.e2e.ts index d40764da71..88ce3a2207 100644 --- a/e2e/core/viewer/viewer-component.e2e.ts +++ b/e2e/core/viewer/viewer-component.e2e.ts @@ -23,6 +23,7 @@ import { NavigationBarPage } from '../../pages/adf/navigationBarPage'; import { ContentServicesPage } from '../../pages/adf/contentServicesPage'; import { ContentListPage } from '../../pages/adf/dialog/contentListPage'; import { ShareDialog } from '../../pages/adf/dialog/shareDialog'; +import { AboutPage } from '../../pages/adf/demo-shell/aboutPage'; import CONSTANTS = require('../../util/constants'); import resources = require('../../util/resources'); @@ -35,6 +36,7 @@ import { AcsUserModel } from '../../models/ACS/acsUserModel'; import AlfrescoApi = require('alfresco-js-api-node'); import { UploadActions } from '../../actions/ACS/upload.actions'; import { browser } from 'protractor'; +import { viewWrappedDebugError } from '@angular/core/src/view/errors'; xdescribe('Viewer', () => { @@ -48,6 +50,7 @@ xdescribe('Viewer', () => { let pngFileUploaded; const contentList = new ContentListPage(); const shareDialog = new ShareDialog(); + const about = new AboutPage(); let pngFileInfo = new FileModel({ 'name': resources.Files.ADF_DOCUMENTS.PNG.file_name, @@ -452,4 +455,45 @@ xdescribe('Viewer', () => { }); }); }); + + describe('Viewer - Code editor extension', () => { + + let jsFileInfo = new FileModel({ + 'name': resources.Files.ADF_DOCUMENTS.JS.file_name, + 'location': resources.Files.ADF_DOCUMENTS.JS.file_location + }); + + let jsFileUploaded; + + beforeAll(async (done) => { + await this.alfrescoJsApi.login(acsUser.id, acsUser.password); + + jsFileUploaded = await uploadActions.uploadFile(this.alfrescoJsApi, jsFileInfo.location, jsFileInfo.name, '-my-'); + + loginPage.loginToContentServicesUsingUserModel(acsUser); + + done(); + }); + + afterAll(async (done) => { + await this.alfrescoJsApi.login(acsUser.id, acsUser.password); + await uploadActions.deleteFilesOrFolder(this.alfrescoJsApi, jsFileUploaded.entry.id); + done(); + }); + + it('[C297698] Should be able to add an extension for code editor viewer', () => { + navigationBarPage.checkAboutButtonIsDisplayed(); + navigationBarPage.clickAboutButton(); + + about.checkMonacoPluginIsDisplayed(); + + navigationBarPage.clickContentServicesButton(); + + contentServicesPage.waitForTableBody(); + contentServicesPage.checkContentIsDisplayed(jsFileInfo.name); + contentServicesPage.doubleClickRow(jsFileInfo.name); + + viewerPage.checkCodeViewerIsDisplayed(); + }); + }); }); diff --git a/e2e/pages/adf/demo-shell/aboutPage.ts b/e2e/pages/adf/demo-shell/aboutPage.ts new file mode 100644 index 0000000000..3b506fed58 --- /dev/null +++ b/e2e/pages/adf/demo-shell/aboutPage.ts @@ -0,0 +1,28 @@ +/*! + * @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 { by, element } from 'protractor'; +import { Util } from '../../../util/util'; + +export class AboutPage { + + monacoPlugin = element(by.cssContainingText('mat-row > mat-cell', 'monaco plugin')); + + checkMonacoPluginIsDisplayed() { + return Util.waitUntilElementIsVisible(this.monacoPlugin); + } +} diff --git a/e2e/pages/adf/navigationBarPage.ts b/e2e/pages/adf/navigationBarPage.ts index c12d103a49..442f338635 100644 --- a/e2e/pages/adf/navigationBarPage.ts +++ b/e2e/pages/adf/navigationBarPage.ts @@ -46,6 +46,7 @@ export class NavigationBarPage { iconsButton = element(by.css('a[data-automation-id="Icons"]')); customSourcesButton = element(by.css('a[data-automation-id="Custom Sources"]')); settingsButton = element(by.css('a[data-automation-id="Settings"]')); + aboutButton = element(by.css('a[data-automation-id="About"]')); navigateToDatatable() { Util.waitUntilElementIsVisible(this.dataTableButton); @@ -151,6 +152,15 @@ export class NavigationBarPage { return this.headerDataButton.click(); } + clickAboutButton() { + Util.waitUntilElementIsClickable(this.aboutButton); + return this.aboutButton.click(); + } + + checkAboutButtonIsDisplayed() { + return Util.waitUntilElementIsVisible(this.aboutButton); + } + checkMenuButtonIsDisplayed() { return Util.waitUntilElementIsVisible(this.menuButton); } diff --git a/e2e/pages/adf/viewerPage.ts b/e2e/pages/adf/viewerPage.ts index a131f5661f..08b12ff915 100644 --- a/e2e/pages/adf/viewerPage.ts +++ b/e2e/pages/adf/viewerPage.ts @@ -95,6 +95,12 @@ export class ViewerPage { timeButton = element(by.id('adf-viewer-time')); bugButton = element(by.id('adf-viewer-bug')); + codeViewer = element(by.id('adf-monaco-file-editor')); + + checkCodeViewerIsDisplayed() { + return Util.waitUntilElementIsVisible(this.codeViewer); + } + viewFile(fileName) { let fileView = element.all(by.css(`#document-list-container div[filename="${fileName}"]`)).first(); Util.waitUntilElementIsVisible(fileView); diff --git a/e2e/resources/adf/a_js_file.js b/e2e/resources/adf/a_js_file.js new file mode 100644 index 0000000000..09d1b2f0bc --- /dev/null +++ b/e2e/resources/adf/a_js_file.js @@ -0,0 +1 @@ +tiw tiw \ No newline at end of file diff --git a/e2e/util/resources.js b/e2e/util/resources.js index 963165d2b3..c1ec69a40d 100644 --- a/e2e/util/resources.js +++ b/e2e/util/resources.js @@ -323,6 +323,10 @@ exports.Files = { }, ADF_DOCUMENTS: { + JS: { + file_location: "/resources/adf/a_js_file.js", + file_name: "a_js_file.js" + }, PDF: { file_location: "/resources/adf/allFileTypes/a_file_supported.pdf", file_name: "a_file_supported.pdf",