[ADF-4151] Automation test for code viewer (#4355)

This commit is contained in:
Marouan Bentaleb
2019-02-27 09:12:47 +00:00
committed by Eugenio Romano
parent bfe046637a
commit cd5870790d
6 changed files with 93 additions and 0 deletions

View File

@@ -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();
});
});
});

View File

@@ -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);
}
}

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -0,0 +1 @@
tiw tiw

View File

@@ -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",