mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-5318] E2E Content Change type (#6799)
* [ADF-5318] E2E Content Change type * Update metadata-content-type.e2e.ts
This commit is contained in:
160
e2e/content-services/metadata/metadata-content-type.e2e.ts
Normal file
160
e2e/content-services/metadata/metadata-content-type.e2e.ts
Normal file
@@ -0,0 +1,160 @@
|
||||
/*!
|
||||
* @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 {
|
||||
ApiService,
|
||||
BrowserActions,
|
||||
LoginPage,
|
||||
ModelActions,
|
||||
UploadActions,
|
||||
UserModel,
|
||||
UsersActions,
|
||||
ViewerPage
|
||||
} from '@alfresco/adf-testing';
|
||||
import { CustomModel, CustomType } from '@alfresco/js-api';
|
||||
import { FileModel } from '../../models/ACS/file.model';
|
||||
import { browser } from 'protractor';
|
||||
import { MetadataViewPage } from '../../core/pages/metadata-view.page';
|
||||
import { NavigationBarPage } from '../../core/pages/navigation-bar.page';
|
||||
|
||||
describe('content type', () => {
|
||||
const apiService = new ApiService();
|
||||
const usersActions = new UsersActions(apiService);
|
||||
const modelActions = new ModelActions(apiService);
|
||||
|
||||
const viewerPage = new ViewerPage();
|
||||
const metadataViewPage = new MetadataViewPage();
|
||||
const navigationBarPage = new NavigationBarPage();
|
||||
const loginPage = new LoginPage();
|
||||
|
||||
const model: CustomModel = {
|
||||
name: 'test',
|
||||
namespaceUri: 'http://www.customModel.com/model/e2e/1.0',
|
||||
namespacePrefix: 'e2e',
|
||||
author: 'E2e Automation User',
|
||||
description: 'Custom type e2e model',
|
||||
status: 'DRAFT'
|
||||
};
|
||||
const type: CustomType = { name: 'test', parentName: 'cm:content', title: 'Test type' };
|
||||
const pdfFile = new FileModel({ name: browser.params.resources.Files.ADF_DOCUMENTS.PDF.file_name });
|
||||
const docxFileModel = new FileModel({
|
||||
name: browser.params.resources.Files.ADF_DOCUMENTS.TEST.file_name,
|
||||
location: browser.params.resources.Files.ADF_DOCUMENTS.TEST.file_path
|
||||
});
|
||||
let acsUser: UserModel;
|
||||
|
||||
beforeAll( async () => {
|
||||
try {
|
||||
await apiService.loginWithProfile('admin');
|
||||
|
||||
const typePaging = await modelActions.listTypes({where: `(namespaceUri matches('http://www.customModel.*'))`});
|
||||
if (typePaging.list.pagination.count === 0) {
|
||||
await modelActions.createModel(model);
|
||||
await modelActions.createType(model.name, type);
|
||||
await modelActions.activateCustomModel(model.name);
|
||||
}
|
||||
|
||||
acsUser = await usersActions.createUser();
|
||||
await apiService.login(acsUser.username, acsUser.password);
|
||||
|
||||
const uploadActions = new UploadActions(apiService);
|
||||
const filePdfNode = await uploadActions.uploadFile(pdfFile.location, pdfFile.name, '-my-');
|
||||
pdfFile.id = filePdfNode.entry.id;
|
||||
const docsNode = await uploadActions.uploadFile(docxFileModel.location, docxFileModel.name, '-my-');
|
||||
docxFileModel.id = docsNode.entry.id;
|
||||
|
||||
await loginPage.login(acsUser.username, acsUser.password);
|
||||
} catch (e) {
|
||||
console.error('Failed to setup custom types', JSON.stringify(e, null, 2));
|
||||
fail();
|
||||
}
|
||||
});
|
||||
|
||||
it('[C593560] Should the user be able to select a new content type and save it only after the confirmation dialog', async () => {
|
||||
await BrowserActions.getUrl(browser.baseUrl + `/(overlay:files/${pdfFile.id}/view)`);
|
||||
|
||||
await viewerPage.clickInfoButton();
|
||||
await viewerPage.checkInfoSideBarIsDisplayed();
|
||||
await metadataViewPage.clickOnPropertiesTab();
|
||||
await metadataViewPage.editIconIsDisplayed();
|
||||
|
||||
await expect(await viewerPage.getActiveTab()).toEqual('PROPERTIES');
|
||||
await metadataViewPage.hasContentType('Content');
|
||||
|
||||
await metadataViewPage.editIconClick();
|
||||
|
||||
await metadataViewPage.changeContentType(type.title);
|
||||
await metadataViewPage.clickSaveMetadata();
|
||||
|
||||
await metadataViewPage.checkConfirmDialogDisplayed();
|
||||
await metadataViewPage.applyNodeProperties();
|
||||
|
||||
await navigationBarPage.clickLogoutButton();
|
||||
await loginPage.login(acsUser.username, acsUser.password);
|
||||
await navigationBarPage.navigateToContentServices();
|
||||
|
||||
await viewerPage.viewFile(pdfFile.name);
|
||||
await viewerPage.checkFileIsLoaded();
|
||||
|
||||
await viewerPage.clickInfoButton();
|
||||
await viewerPage.checkInfoSideBarIsDisplayed();
|
||||
await metadataViewPage.clickOnPropertiesTab();
|
||||
await metadataViewPage.editIconIsDisplayed();
|
||||
|
||||
await expect(await viewerPage.getActiveTab()).toEqual('PROPERTIES');
|
||||
await metadataViewPage.hasContentType(type.title);
|
||||
|
||||
await viewerPage.clickCloseButton();
|
||||
});
|
||||
|
||||
it('[C593559] Should the user be able to select a new content type and not save it when press cancel in the confirmation dialog', async () => {
|
||||
await BrowserActions.getUrl(browser.baseUrl + `/(overlay:files/${docxFileModel.id}/view)`);
|
||||
|
||||
await viewerPage.clickInfoButton();
|
||||
await viewerPage.checkInfoSideBarIsDisplayed();
|
||||
await metadataViewPage.clickOnPropertiesTab();
|
||||
await metadataViewPage.editIconIsDisplayed();
|
||||
|
||||
await expect(await viewerPage.getActiveTab()).toEqual('PROPERTIES');
|
||||
await metadataViewPage.hasContentType('Content');
|
||||
|
||||
await metadataViewPage.editIconClick();
|
||||
|
||||
await metadataViewPage.changeContentType(type.title);
|
||||
await metadataViewPage.clickSaveMetadata();
|
||||
|
||||
await metadataViewPage.checkConfirmDialogDisplayed();
|
||||
await metadataViewPage.cancelNodeProperties();
|
||||
|
||||
await navigationBarPage.clickLogoutButton();
|
||||
await loginPage.login(acsUser.username, acsUser.password);
|
||||
await navigationBarPage.navigateToContentServices();
|
||||
|
||||
await viewerPage.viewFile(docxFileModel.name);
|
||||
await viewerPage.checkFileIsLoaded();
|
||||
|
||||
await viewerPage.clickInfoButton();
|
||||
await viewerPage.checkInfoSideBarIsDisplayed();
|
||||
await metadataViewPage.clickOnPropertiesTab();
|
||||
await metadataViewPage.editIconIsDisplayed();
|
||||
|
||||
await expect(await viewerPage.getActiveTab()).toEqual('PROPERTIES');
|
||||
await metadataViewPage.hasContentType('Content');
|
||||
|
||||
await viewerPage.clickCloseButton();
|
||||
});
|
||||
});
|
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
import { Locator, by, element, Key, protractor } from 'protractor';
|
||||
import { BrowserVisibility, BrowserActions } from '@alfresco/adf-testing';
|
||||
import { BrowserVisibility, BrowserActions, DropdownPage, TestElement } from '@alfresco/adf-testing';
|
||||
|
||||
export class MetadataViewPage {
|
||||
|
||||
@@ -216,6 +216,35 @@ export class MetadataViewPage {
|
||||
await BrowserVisibility.waitUntilElementIsVisible(property);
|
||||
}
|
||||
|
||||
async hasContentType(contentType: string): Promise<string> {
|
||||
const nodeType = TestElement.byText('div[data-automation-id="header-nodeType"] .adf-property-value', contentType);
|
||||
return nodeType.waitVisible();
|
||||
}
|
||||
|
||||
async changeContentType(option: string): Promise<void> {
|
||||
const nodeType = TestElement.byCss('div[data-automation-id="header-nodeType"] mat-form-field');
|
||||
await nodeType.waitPresent();
|
||||
await nodeType.click();
|
||||
const typesDropDownPage = new DropdownPage(nodeType.elementFinder);
|
||||
await typesDropDownPage.checkOptionIsDisplayed(option);
|
||||
await typesDropDownPage.selectOption(option);
|
||||
}
|
||||
|
||||
async checkConfirmDialogDisplayed(): Promise<void> {
|
||||
const confirmButton = TestElement.byCss('adf-content-type-dialog');
|
||||
await confirmButton.waitPresent();
|
||||
}
|
||||
|
||||
async applyNodeProperties(): Promise<void> {
|
||||
const confirmButton = TestElement.byId('content-type-dialog-apply-button');
|
||||
await confirmButton.click();
|
||||
}
|
||||
|
||||
async cancelNodeProperties(): Promise<void> {
|
||||
const cancelButton = TestElement.byId('content-type-dialog-actions-cancel');
|
||||
await cancelButton.click();
|
||||
}
|
||||
|
||||
async checkPropertyIsNotVisible(propertyName: string, type: string): Promise<void> {
|
||||
const property = element(by.css('div[data-automation-id="card-' + type + '-label-' + propertyName + '"]'));
|
||||
await BrowserVisibility.waitUntilElementIsNotVisible(property);
|
||||
|
Reference in New Issue
Block a user