[ADF-5366] initialize discovery and version compatibility service for oauth based session (#6864)

* [ADF-5366] initialize discovery and version compatibility service for oauth based session

* better error message

* * fix spaces

* * revert the search service

* * fix build

* * check properties after type update

* * check properties after type update

* * check properties after type update

* * fix infinite loop

* * fix test without title

* * wait for options

* * wait for session

* Update metadata-content-type.e2e.ts

* Update metadata-content-type.e2e.ts

* Update protractor.excludes.json

* Update protractor.excludes.json
This commit is contained in:
Dharan 2021-04-29 18:10:49 +05:30 committed by GitHub
parent c0b5935b43
commit 8b5e45f4eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 532 additions and 345 deletions

View File

@ -90,34 +90,41 @@ describe('Permissions Component', () => {
let roleConsumerFolder, roleCoordinatorFolder, roleContributorFolder, roleCollaboratorFolder, roleEditorFolder;
beforeAll(async () => {
await apiService.loginWithProfile('admin');
await usersActions.createUser(fileOwnerUser);
await usersActions.createUser(filePermissionUser);
await apiService.getInstance().core.groupsApi.createGroup(groupBody);
try {
await apiService.loginWithProfile('admin');
await usersActions.createUser(fileOwnerUser);
await usersActions.createUser(filePermissionUser);
await apiService.getInstance().core.groupsApi.createGroup(groupBody);
// to sync user in acs
await searchService.isUserSearchable(filePermissionUser);
await apiService.login(fileOwnerUser.username, fileOwnerUser.password);
roleConsumerFolder = await uploadActions.createFolder(roleConsumerFolderModel.name, '-my-');
roleCoordinatorFolder = await uploadActions.createFolder(roleCoordinatorFolderModel.name, '-my-');
roleContributorFolder = await uploadActions.createFolder(roleContributorFolderModel.name, '-my-');
roleCollaboratorFolder = await uploadActions.createFolder(roleCollaboratorFolderModel.name, '-my-');
roleEditorFolder = await uploadActions.createFolder(roleEditorFolderModel.name, '-my-');
await apiService.login(fileOwnerUser.username, fileOwnerUser.password);
roleConsumerFolder = await uploadActions.createFolder(roleConsumerFolderModel.name, '-my-');
roleCoordinatorFolder = await uploadActions.createFolder(roleCoordinatorFolderModel.name, '-my-');
roleContributorFolder = await uploadActions.createFolder(roleContributorFolderModel.name, '-my-');
roleCollaboratorFolder = await uploadActions.createFolder(roleCollaboratorFolderModel.name, '-my-');
roleEditorFolder = await uploadActions.createFolder(roleEditorFolderModel.name, '-my-');
await uploadActions.uploadFile(fileModel.location, 'RoleConsumer' + fileModel.name, roleConsumerFolder.entry.id);
await uploadActions.uploadFile(fileModel.location, 'RoleContributor' + fileModel.name, roleContributorFolder.entry.id);
await uploadActions.uploadFile(fileModel.location, 'RoleCoordinator' + fileModel.name, roleCoordinatorFolder.entry.id);
await uploadActions.uploadFile(fileModel.location, 'RoleCollaborator' + fileModel.name, roleCollaboratorFolder.entry.id);
await uploadActions.uploadFile(fileModel.location, 'RoleEditor' + fileModel.name, roleEditorFolder.entry.id);
await uploadActions.uploadFile(fileModel.location, 'RoleConsumer' + fileModel.name, roleConsumerFolder.entry.id);
await uploadActions.uploadFile(fileModel.location, 'RoleContributor' + fileModel.name, roleContributorFolder.entry.id);
await uploadActions.uploadFile(fileModel.location, 'RoleCoordinator' + fileModel.name, roleCoordinatorFolder.entry.id);
await uploadActions.uploadFile(fileModel.location, 'RoleCollaborator' + fileModel.name, roleCollaboratorFolder.entry.id);
await uploadActions.uploadFile(fileModel.location, 'RoleEditor' + fileModel.name, roleEditorFolder.entry.id);
await permissionActions.addRoleForUser(filePermissionUser.username, 'Consumer', roleConsumerFolder);
await permissionActions.addRoleForUser(filePermissionUser.username, 'Collaborator', roleCollaboratorFolder);
await permissionActions.addRoleForUser(filePermissionUser.username, 'Coordinator', roleCoordinatorFolder);
await permissionActions.addRoleForUser(filePermissionUser.username, 'Contributor', roleContributorFolder);
await permissionActions.addRoleForUser(filePermissionUser.username, 'Editor', roleEditorFolder);
await permissionActions.addRoleForUser(filePermissionUser.username, 'Consumer', roleConsumerFolder);
await permissionActions.addRoleForUser(filePermissionUser.username, 'Collaborator', roleCollaboratorFolder);
await permissionActions.addRoleForUser(filePermissionUser.username, 'Coordinator', roleCoordinatorFolder);
await permissionActions.addRoleForUser(filePermissionUser.username, 'Contributor', roleContributorFolder);
await permissionActions.addRoleForUser(filePermissionUser.username, 'Editor', roleEditorFolder);
await browser.sleep(browser.params.testConfig.timeouts.index_search); // wait search index previous file/folder uploaded
// to sync user in acs
try {
await searchService.isUserSearchable(filePermissionUser);
} catch (e) {
console.error(`*****\n Failed to sync user \n*****`);
}
await browser.sleep(browser.params.testConfig.timeouts.index_search); // wait search index previous file/folder uploaded
} catch (e) {
fail('Failed to set up permission : \n' + JSON.stringify(e, null, 2));
}
});
describe('Inherit and assigning permissions', () => {
@ -209,6 +216,7 @@ describe('Permissions Component', () => {
await permissionsPage.addPermissionsDialog.checkAddPermissionDialogIsDisplayed();
await permissionsPage.addPermissionsDialog.checkSearchUserInputIsDisplayed();
await permissionsPage.addPermissionsDialog.searchUserOrGroup(filePermissionUser.firstName);
await permissionsPage.addPermissionsDialog.checkResultListIsDisplayed();
await permissionsPage.addPermissionsDialog.clickUserOrGroup(filePermissionUser.firstName);
await permissionsPage.addPermissionsDialog.selectRole(filePermissionUser.fullName, 'Contributor');
await expect(await permissionsPage.addPermissionsDialog.addButtonIsEnabled()).toBe(true, 'button should be enabled');

View File

@ -20,7 +20,7 @@ import {
ApiService,
BrowserActions,
LoginPage,
NotificationHistoryPage,
NotificationHistoryPage, SearchService,
StringUtil,
UploadActions,
UserModel,
@ -42,6 +42,7 @@ describe('Permissions Component', () => {
const apiService = new ApiService();
const uploadActions = new UploadActions(apiService);
const searchService = new SearchService(apiService);
const loginPage = new LoginPage();
const contentServicesPage = new ContentServicesPage();
@ -89,71 +90,81 @@ describe('Permissions Component', () => {
const usersActions = new UsersActions(apiService);
beforeAll(async () => {
await apiService.loginWithProfile('admin');
await usersActions.createUser(folderOwnerUser);
await usersActions.createUser(siteConsumerUser);
await usersActions.createUser(consumerUser);
await usersActions.createUser(contributorUser);
await usersActions.createUser(collaboratorUser);
await usersActions.createUser(managerUser);
await apiService.login(folderOwnerUser.username, folderOwnerUser.password);
try {
await apiService.loginWithProfile('admin');
await usersActions.createUser(folderOwnerUser);
await usersActions.createUser(siteConsumerUser);
await usersActions.createUser(consumerUser);
await usersActions.createUser(contributorUser);
await usersActions.createUser(collaboratorUser);
await usersActions.createUser(managerUser);
await apiService.login(folderOwnerUser.username, folderOwnerUser.password);
await browser.sleep(browser.params.testConfig.timeouts.index_search);
const publicSiteName = `PUBLIC_TEST_SITE_${StringUtil.generateRandomString(5)}`;
const publicSiteName = `PUBLIC_TEST_SITE_${StringUtil.generateRandomString(5)}`;
const privateSiteName = `PRIVATE_TEST_SITE_${StringUtil.generateRandomString(5)}`;
const privateSiteName = `PRIVATE_TEST_SITE_${StringUtil.generateRandomString(5)}`;
folderName = `MEESEEKS_${StringUtil.generateRandomString(5)}`;
folderName = `MEESEEKS_${StringUtil.generateRandomString(5)}`;
const publicSiteBody = { visibility: 'PUBLIC', title: publicSiteName };
const privateSiteBody = { visibility: 'PRIVATE', title: privateSiteName };
const publicSiteBody = { visibility: 'PUBLIC', title: publicSiteName };
const privateSiteBody = { visibility: 'PRIVATE', title: privateSiteName };
const sitesApi = new SitesApi(apiService.getInstance());
const sitesApi = new SitesApi(apiService.getInstance());
publicSite = await sitesApi.createSite(publicSiteBody);
privateSite = await sitesApi.createSite(privateSiteBody);
publicSite = await sitesApi.createSite(publicSiteBody);
privateSite = await sitesApi.createSite(privateSiteBody);
await sitesApi.createSiteMembership(publicSite.entry.id, {
id: siteConsumerUser.username,
role: CONSTANTS.CS_USER_ROLES.CONSUMER
});
await sitesApi.createSiteMembership(publicSite.entry.id, {
id: collaboratorUser.username,
role: CONSTANTS.CS_USER_ROLES.COLLABORATOR
});
await sitesApi.createSiteMembership(publicSite.entry.id, {
id: contributorUser.username,
role: CONSTANTS.CS_USER_ROLES.CONTRIBUTOR
});
await sitesApi.createSiteMembership(publicSite.entry.id, {
id: managerUser.username,
role: CONSTANTS.CS_USER_ROLES.MANAGER
});
await sitesApi.createSiteMembership(privateSite.entry.id, {
id: managerUser.username,
role: CONSTANTS.CS_USER_ROLES.MANAGER
});
siteFolder = await uploadActions.createFolder(folderName, publicSite.entry.guid);
privateSiteFile = await uploadActions.uploadFile(fileModel.location, 'privateSite' + fileModel.name, privateSite.entry.guid);
await apiService.getInstance().core.nodesApi.updateNode(privateSiteFile.entry.id,
{
permissions: {
locallySet: [{
authorityId: managerUser.username,
name: 'SiteConsumer',
accessStatus: 'ALLOWED'
}]
}
await sitesApi.createSiteMembership(publicSite.entry.id, {
id: siteConsumerUser.username,
role: CONSTANTS.CS_USER_ROLES.CONSUMER
});
await uploadActions.uploadFile(fileModel.location, 'Site' + fileModel.name, siteFolder.entry.id);
await sitesApi.createSiteMembership(publicSite.entry.id, {
id: collaboratorUser.username,
role: CONSTANTS.CS_USER_ROLES.COLLABORATOR
});
await sitesApi.createSiteMembership(publicSite.entry.id, {
id: contributorUser.username,
role: CONSTANTS.CS_USER_ROLES.CONTRIBUTOR
});
await sitesApi.createSiteMembership(publicSite.entry.id, {
id: managerUser.username,
role: CONSTANTS.CS_USER_ROLES.MANAGER
});
await sitesApi.createSiteMembership(privateSite.entry.id, {
id: managerUser.username,
role: CONSTANTS.CS_USER_ROLES.MANAGER
});
siteFolder = await uploadActions.createFolder(folderName, publicSite.entry.guid);
privateSiteFile = await uploadActions.uploadFile(fileModel.location, 'privateSite' + fileModel.name, privateSite.entry.guid);
await apiService.getInstance().core.nodesApi.updateNode(privateSiteFile.entry.id,
{
permissions: {
locallySet: [{
authorityId: managerUser.username,
name: 'SiteConsumer',
accessStatus: 'ALLOWED'
}]
}
});
await uploadActions.uploadFile(fileModel.location, 'Site' + fileModel.name, siteFolder.entry.id);
// to sync user in acs
try {
await searchService.isUserSearchable(consumerUser);
} catch (e) {
console.error(`*****\n Failed to sync user \n*****`);
}
await browser.sleep(browser.params.testConfig.timeouts.index_search);
} catch (error) {
fail('Failed to setup site permission : ' + JSON.stringify(error, null, 2));
}
});
afterAll(async () => {
@ -192,6 +203,7 @@ describe('Permissions Component', () => {
await permissionsPage.addPermissionsDialog.checkSearchUserInputIsDisplayed();
await permissionsPage.addPermissionsDialog.searchUserOrGroup(consumerUser.username);
await permissionsPage.addPermissionsDialog.checkResultListIsDisplayed();
await permissionsPage.addPermissionsDialog.clickUserOrGroup(consumerUser.firstName);
await permissionsPage.addPermissionsDialog.selectRole(consumerUser.fullName, 'Site Collaborator');

View File

@ -20,6 +20,7 @@ import {
BrowserActions,
LoginPage,
ModelActions,
StringUtil,
UploadActions,
UserModel,
UsersActions,
@ -30,26 +31,31 @@ 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';
import { ContentServicesPage } from '../../core/pages/content-services.page';
describe('content type', () => {
const apiService = new ApiService();
const usersActions = new UsersActions(apiService);
const modelActions = new ModelActions(apiService);
const uploadActions = new UploadActions(apiService);
const viewerPage = new ViewerPage();
const metadataViewPage = new MetadataViewPage();
const navigationBarPage = new NavigationBarPage();
const contentServicesPage = new ContentServicesPage();
const loginPage = new LoginPage();
const randomString = StringUtil.generateRandomString();
const model: CustomModel = {
name: 'test',
namespaceUri: 'http://www.customModel.com/model/e2e/1.0',
namespacePrefix: 'e2e',
name: `test-${randomString}`,
namespaceUri: `http://www.customModel.com/model/${randomString}/1.0`,
namespacePrefix: `e2e-${randomString}`,
author: 'E2e Automation User',
description: 'Custom type e2e model',
status: 'DRAFT'
};
const type: CustomType = { name: 'test', parentName: 'cm:content', title: 'Test type' };
const type: CustomType = { name: `test-type-${randomString}`, parentName: 'cm:content', title: `Test type - ${randomString}` };
const property = { name: `test-property-${randomString}`, title: `Test property - ${randomString}`, dataType: 'd:text', defaultValue: randomString };
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,
@ -60,81 +66,105 @@ describe('content type', () => {
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);
}
await modelActions.createModel(model);
await modelActions.createType(model.name, type);
await modelActions.addPropertyToType(model.name, type.name, [property]);
await modelActions.activateCustomModel(model.name);
await modelActions.isCustomTypeSearchable(type.title);
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();
fail('Failed to setup custom types :: ' + JSON.stringify(e, null, 2));
}
});
afterAll(async () => {
await apiService.login(acsUser.username, acsUser.password);
await uploadActions.deleteFileOrFolder(pdfFile.id);
await uploadActions.deleteFileOrFolder(docxFileModel.id);
try {
await apiService.loginWithProfile('admin');
await modelActions.deactivateCustomModel(model.name);
await modelActions.deleteCustomModel(model.name);
} catch (e) {
console.error('failed to delete the model', e);
}
});
beforeEach( async () => {
await loginPage.login(acsUser.username, acsUser.password);
await navigationBarPage.navigateToContentServices();
await contentServicesPage.contentList.dataTablePage().waitTillContentLoaded();
await browser.sleep(8000); // wait for sso session to initiate
});
afterEach( async () => {
await navigationBarPage.clickLogoutButton();
});
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.checkFileIsLoaded(pdfFile.name);
await viewerPage.clickInfoButton();
await viewerPage.checkInfoSideBarIsDisplayed();
await metadataViewPage.clickOnPropertiesTab();
await metadataViewPage.editIconIsDisplayed();
await expect(await viewerPage.getActiveTab()).toEqual('PROPERTIES');
await metadataViewPage.hasContentType('Content');
const defaultType = (await metadataViewPage.hasContentType('Content')) || (await metadataViewPage.hasContentType('cm:content'));
await expect(defaultType).toBe(true, 'Content type not found');
await metadataViewPage.editIconClick();
await metadataViewPage.changeContentType(type.title);
await expect(await metadataViewPage.changeContentType(type.title)).toBe(true, 'Failed to update node type.');
await metadataViewPage.clickSaveMetadata();
await metadataViewPage.checkConfirmDialogDisplayed();
await metadataViewPage.applyNodeProperties();
await expect(await metadataViewPage.checkPropertyDisplayed(`properties.${model.namespacePrefix}:${property.name}`))
.toContain(property.defaultValue, 'Custom property not found');
await navigationBarPage.clickLogoutButton();
await loginPage.login(acsUser.username, acsUser.password);
await navigationBarPage.navigateToContentServices();
await viewerPage.viewFile(pdfFile.name);
await viewerPage.checkFileIsLoaded();
await contentServicesPage.contentList.dataTablePage().waitTillContentLoaded();
await BrowserActions.getUrl(browser.baseUrl + `/(overlay:files/${pdfFile.id}/view)`);
await viewerPage.checkFileIsLoaded(pdfFile.name);
await viewerPage.clickInfoButton();
await viewerPage.checkInfoSideBarIsDisplayed();
await metadataViewPage.clickOnPropertiesTab();
await metadataViewPage.editIconIsDisplayed();
await expect(await viewerPage.getActiveTab()).toEqual('PROPERTIES');
await metadataViewPage.hasContentType(type.title);
const customType = (await metadataViewPage.hasContentType(type.title)) || (await metadataViewPage.hasContentType(`${model.namespacePrefix}:${type.name}`));
await expect(customType).toBe(true, 'Custom type not found');
await expect(await metadataViewPage.getPropertyText(`properties.${model.namespacePrefix}:${property.name}`)).toContain(property.defaultValue);
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.checkFileIsLoaded(docxFileModel.name);
await viewerPage.clickInfoButton();
await viewerPage.checkInfoSideBarIsDisplayed();
await metadataViewPage.clickOnPropertiesTab();
await metadataViewPage.editIconIsDisplayed();
await expect(await viewerPage.getActiveTab()).toEqual('PROPERTIES');
await metadataViewPage.hasContentType('Content');
let defaultType = (await metadataViewPage.hasContentType('Content')) || (await metadataViewPage.hasContentType('cm:content'));
await expect(defaultType).toBe(true, 'Content type not found');
await metadataViewPage.editIconClick();
await metadataViewPage.changeContentType(type.title);
await expect(await metadataViewPage.changeContentType(type.title)).toBe(true, 'Failed to update node type.');
await metadataViewPage.clickSaveMetadata();
await metadataViewPage.checkConfirmDialogDisplayed();
@ -143,18 +173,17 @@ describe('content type', () => {
await navigationBarPage.clickLogoutButton();
await loginPage.login(acsUser.username, acsUser.password);
await navigationBarPage.navigateToContentServices();
await viewerPage.viewFile(docxFileModel.name);
await viewerPage.checkFileIsLoaded();
await contentServicesPage.contentList.dataTablePage().waitTillContentLoaded();
await BrowserActions.getUrl(browser.baseUrl + `/(overlay:files/${docxFileModel.id}/view)`);
await viewerPage.checkFileIsLoaded(docxFileModel.name);
await viewerPage.clickInfoButton();
await viewerPage.checkInfoSideBarIsDisplayed();
await metadataViewPage.clickOnPropertiesTab();
await metadataViewPage.editIconIsDisplayed();
await expect(await viewerPage.getActiveTab()).toEqual('PROPERTIES');
await metadataViewPage.hasContentType('Content');
defaultType = (await metadataViewPage.hasContentType('Content')) || (await metadataViewPage.hasContentType('cm:content'));
await expect(defaultType).toBe(true, 'Content type not found');
await viewerPage.clickCloseButton();
});
});

View File

@ -15,8 +15,8 @@
* limitations under the License.
*/
import { Locator, by, element, Key, protractor } from 'protractor';
import { BrowserVisibility, BrowserActions, DropdownPage, TestElement } from '@alfresco/adf-testing';
import { by, element, Key, Locator, protractor } from 'protractor';
import { BrowserActions, BrowserVisibility, DropdownPage, TestElement, Logger } from '@alfresco/adf-testing';
export class MetadataViewPage {
@ -216,18 +216,60 @@ 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 hasContentType(contentType: string, attempt = 0, maxAttempt = 3): Promise<boolean> {
const contentTypeSelector = '[data-automation-id="select-readonly-value-nodeType"]';
const type = TestElement.byText(contentTypeSelector, contentType);
try {
if (attempt > maxAttempt) {
return false;
}
await type.waitVisible();
const isPresent = type.isPresent();
if (isPresent) {
return true;
}
return this.hasContentType(contentType, attempt + 1, maxAttempt);
} catch (e) {
Logger.log(`re trying content type attempt :: ${attempt}`);
return this.hasContentType(contentType, attempt + 1, maxAttempt);
}
}
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 checkPropertyDisplayed(propertyName: string, type?: string, attempt = 0, maxAttempt = 3): Promise<string> {
try {
if (attempt > maxAttempt) {
return '';
}
const propertyType = type || 'textitem';
await TestElement.byCss('[data-automation-id="card-' + propertyType + '-value-' + propertyName + '"]').waitVisible();
return this.getPropertyText(propertyName);
} catch (e) {
Logger.log(`re trying custom property attempt :: ${attempt}`);
return this.checkPropertyDisplayed(propertyName, type, attempt + 1, maxAttempt);
}
}
async changeContentType(option: string, attempt = 0, maxAttempt = 3): Promise<boolean> {
const nodeType = TestElement.byCss('div[data-automation-id="header-nodeType"] .mat-select-trigger');
if (attempt > maxAttempt) {
console.error(`content type select option not found. check acs version may be lesser than 7.0.0`);
return false;
}
try {
await nodeType.waitVisible();
if (await nodeType.isPresent()) {
await nodeType.click();
const typesDropDownPage = new DropdownPage(nodeType.elementFinder);
await typesDropDownPage.checkOptionIsDisplayed(option);
await typesDropDownPage.selectOption(option);
return true;
}
return this.changeContentType(option, attempt + 1, maxAttempt);
} catch (error) {
Logger.log(`re trying content type options attempt :: ${attempt}`);
await BrowserActions.closeMenuAndDialogs();
return this.changeContentType(option, attempt + 1, maxAttempt);
}
}
async checkConfirmDialogDisplayed(): Promise<void> {
@ -246,8 +288,7 @@ export class MetadataViewPage {
}
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);
await TestElement.byCss('div[data-automation-id="card-' + type + '-label-' + propertyName + '"]').waitNotVisible();
}
async clickCloseButton(): Promise<void> {

View File

@ -250,13 +250,30 @@ exports.config = {
})
);
function disableCSSAnimation() {
const css = '* {' +
'-webkit-transition-duration: 0s !important;' +
'transition-duration: 0s !important;' +
'-webkit-animation-duration: 0s !important;' +
'animation-duration: 0s !important;' +
'}';
const head = document.head || document.getElementsByTagName('head')[0];
const style = document.createElement('style');
style.type = 'text/css';
style.appendChild(document.createTextNode(css));
head.appendChild(style);
}
// @ts-ignore
await browser.driver.executeScript(disableCSSAnimation);
// @ts-ignore
await browser.waitForAngularEnabled(false);
await browser.get(`${HOST}/#/settings`);
await browser.waitForAngularEnabled(true);
if (typeof LocalStorageUtil.clearStorage === "function") {
try {
await LocalStorageUtil.clearStorage();
// @ts-ignore
await LocalStorageUtil.setStorageItem('ecmHost', browser.params.testConfig.appConfig.ecmHost);
@ -280,26 +297,10 @@ exports.config = {
await LocalStorageUtil.apiReset();
} else {
} catch (error) {
Logger.error(`====== Demo shell not able to start ======`);
process.exit();
}
function disableCSSAnimation() {
const css = '* {' +
'-webkit-transition-duration: 0s !important;' +
'transition-duration: 0s !important;' +
'-webkit-animation-duration: 0s !important;' +
'animation-duration: 0s !important;' +
'}';
const head = document.head || document.getElementsByTagName('head')[0];
const style = document.createElement('style');
style.type = 'text/css';
style.appendChild(document.createTextNode(css));
head.appendChild(style);
}
},
afterLaunch: async function (statusCode) {

View File

@ -4,7 +4,8 @@
"C279932": "login problem APS not basic",
"C279931": "login problem APS not basic",
"C279930": "login problem APS not basic",
"C593560": "https://alfresco.atlassian.net/browse/ADF-5366",
"C593560": "https://alfresco.atlassian.net/browse/ADF-5388",
"C593559": "https://alfresco.atlassian.net/browse/ADF-5388",
"C269081": "https://alfresco.atlassian.net/browse/ADF-5385",
"C272819": "https://alfresco.atlassian.net/browse/ADF-5385",
"C290069": "https://alfresco.atlassian.net/browse/ADF-5387"

View File

@ -4,6 +4,7 @@
<div class="adf-property-field">
<div *ngIf="!isEditable()"
class="adf-select-item-padding adf-property-value"
[attr.data-automation-id]="'select-readonly-value-' + property.key"
data-automation-class="read-only-value">{{ (property.displayValue | async) | translate }}</div>
<div *ngIf="isEditable()">
<mat-form-field class="adf-select-item-padding-editable adf-property-value">

View File

@ -41,6 +41,12 @@ describe('NodeDownloadDirective', () => {
let apiService: AlfrescoApiService;
let contentService;
let dialogSpy;
const mockOauth2Auth = {
oauth2Auth: {
callCustomApi: () => Promise.resolve(),
on: jasmine.createSpy('on')
}
};
setupTestBed({
imports: [
@ -63,7 +69,7 @@ describe('NodeDownloadDirective', () => {
});
it('should not download node when selection is empty', () => {
spyOn(apiService, 'getInstance');
spyOn(apiService, 'getInstance').and.returnValue(mockOauth2Auth);
component.selection = [];
fixture.detectChanges();

View File

@ -16,7 +16,7 @@
*/
import { Injectable } from '@angular/core';
import { Observable, from, throwError, Observer, ReplaySubject } from 'rxjs';
import { Observable, from, throwError, Observer, ReplaySubject, Subject } from 'rxjs';
import { AlfrescoApiService } from './alfresco-api.service';
import { CookieService } from './cookie.service';
import { LogService } from './log.service';
@ -39,7 +39,19 @@ export class AuthenticationService {
private bearerExcludedUrls: string[] = ['auth/realms', 'resources/', 'assets/'];
/**
* Emits oAuth token exchange event
*/
onTokenExchange: Subject<string> = new Subject<string>();
/**
* Emits Basic auth login event
*/
onLogin: ReplaySubject<any> = new ReplaySubject<any>(1);
/**
* Emits logout event
*/
onLogout: ReplaySubject<any> = new ReplaySubject<any>(1);
constructor(
@ -48,6 +60,15 @@ export class AuthenticationService {
private alfrescoApi: AlfrescoApiService,
private cookie: CookieService,
private logService: LogService) {
this.listenForOauthTokenExchange();
}
private listenForOauthTokenExchange() {
this.alfrescoApi.alfrescoApiInitialized.subscribe(() => {
this.alfrescoApi.getInstance().oauth2Auth?.on('token_issued', () => {
this.onTokenExchange.next(this.alfrescoApi.getInstance().oauth2Auth.token);
});
});
}
/**

View File

@ -17,64 +17,64 @@
import { TestBed } from '@angular/core/testing';
import { BpmProductVersionModel, EcmProductVersionModel } from '../models/product-version.model';
import { AppConfigService } from '../app-config/app-config.service';
import { DiscoveryApiService } from './discovery-api.service';
import { AlfrescoApiService } from './alfresco-api.service';
import { AuthenticationService } from './authentication.service';
import { setupTestBed } from '../testing/setup-test-bed';
import { CoreTestingModule } from '../testing/core.testing.module';
import { SystemPropertiesRepresentation } from '@alfresco/js-api';
import { TranslateModule } from '@ngx-translate/core';
declare let jasmine: any;
import { of, throwError } from 'rxjs';
const fakeEcmDiscoveryResponse: any = {
'entry': {
'repository': {
'edition': 'FAKE',
'version': {
'major': '5',
'minor': '2',
'patch': '0',
'hotfix': '0',
'schema': 999999,
'label': 'r134899-b26',
'display': '5.2.0.0 (r134899-b26) schema 10005'
entry: {
repository: {
edition: 'FAKE',
version: {
major: '5',
minor: '2',
patch: '0',
hotfix: '0',
schema: 999999,
label: 'r134899-b26',
display: '5.2.0.0 (r134899-b26) schema 10005'
},
'license': {
'issuedAt': '2017-06-22T10:56:45.796+0000',
'expiresAt': '2017-07-22T00:00:00.000+0000',
'remainingDays': 4,
'holder': 'Trial User',
'mode': 'ENTERPRISE',
'entitlements': {
'isClusterEnabled': false,
'isCryptodocEnabled': false
license: {
issuedAt: '2017-06-22T10:56:45.796+0000',
expiresAt: '2017-07-22T00:00:00.000+0000',
remainingDays: 4,
holder: 'Trial User',
mode: 'ENTERPRISE',
entitlements: {
isClusterEnabled: false,
isCryptodocEnabled: false
}
},
'status': {
'isReadOnly': false,
'isAuditEnabled': true,
'isQuickShareEnabled': true,
'isThumbnailGenerationEnabled': true
status: {
isReadOnly: false,
isAuditEnabled: true,
isQuickShareEnabled: true,
isThumbnailGenerationEnabled: true
},
'modules': [
modules: [
{
'id': 'alfresco-fake-services',
'title': 'Alfresco Share Services AMP',
'description': 'Module to be applied to alfresco.war, containing APIs for Alfresco Share',
'version': '5.2.0',
'installDate': '2017-03-07T08:48:14.161+0000',
'installState': 'INSTALLED',
'versionMin': '5.1',
'versionMax': '999'
id: 'alfresco-fake-services',
title: 'Alfresco Share Services AMP',
description: 'Module to be applied to alfresco.war, containing APIs for Alfresco Share',
version: '5.2.0',
installDate: '2017-03-07T08:48:14.161+0000',
installState: 'INSTALLED',
versionMin: '5.1',
versionMax: '999'
},
{
'id': 'alfresco-trashcan-fake',
'title': 'alfresco-trashcan-cleaner project',
'description': 'The Alfresco Trash Can Cleaner (Alfresco Module)',
'version': '2.2',
'installState': 'UNKNOWN',
'versionMin': '0',
'versionMax': '999'
id: 'alfresco-trashcan-fake',
title: 'alfresco-trashcan-cleaner project',
description: 'The Alfresco Trash Can Cleaner (Alfresco Module)',
version: '2.2',
installState: 'UNKNOWN',
versionMin: '0',
versionMax: '999'
}
]
}
@ -82,149 +82,177 @@ const fakeEcmDiscoveryResponse: any = {
};
const fakeBPMDiscoveryResponse: any = {
'revisionVersion': '2',
'edition': 'SUPER FAKE EDITION',
'type': 'bpmSuite',
'majorVersion': '1',
'minorVersion': '6'
};
revisionVersion: '2',
edition: 'SUPER FAKE EDITION',
type: 'bpmSuite',
majorVersion: '1',
minorVersion: '6'
};
const fakeBPMDiscoverySystemPropertyResponse: any = {
'allowInvolveByEmail': true,
'disableJavaScriptEventsInFormEditor': false,
'logoutDisabled': false,
'authConfiguration': {
'authUrl': 'fakeAuthUrl',
'realm': 'fakeRealm',
'clientId': 'fakeClient',
'useBrowserLogout': true
allowInvolveByEmail: true,
disableJavaScriptEventsInFormEditor: false,
logoutDisabled: false,
authConfiguration: {
authUrl: 'fakeAuthUrl',
realm: 'fakeRealm',
clientId: 'fakeClient',
useBrowserLogout: true
}
};
describe('Discovery Api Service', () => {
let service: DiscoveryApiService;
let apiService: AlfrescoApiService;
let authenticationService: AuthenticationService;
setupTestBed({
imports: [
TranslateModule.forRoot(),
CoreTestingModule
]
});
describe('Basic auth', () => {
setupTestBed({
imports: [TranslateModule.forRoot(), CoreTestingModule]
});
beforeEach(() => {
const appConfig: AppConfigService = TestBed.inject(AppConfigService);
appConfig.config = {
ecmHost: 'http://localhost:9876/ecm'
};
service = TestBed.inject(DiscoveryApiService);
jasmine.Ajax.install();
});
beforeEach(() => {
service = TestBed.inject(DiscoveryApiService);
apiService = TestBed.inject(AlfrescoApiService);
});
afterEach(() => {
jasmine.Ajax.uninstall();
});
describe('For ECM', () => {
it('Should retrieve the info about the product for ECM', done => {
spyOn(apiService.getInstance().discovery.discoveryApi, 'getRepositoryInformation')
.and.returnValue(of(fakeEcmDiscoveryResponse));
describe('For ECM', () => {
it('Should retrieve the info about the product for ECM', (done) => {
service.getEcmProductInfo().subscribe((data: EcmProductVersionModel) => {
expect(data).not.toBeNull();
expect(data.edition).toBe('FAKE');
expect(data.version.schema).toBe(999999);
expect(data.license.isClusterEnabled).toBeFalsy();
expect(data.status.isQuickShareEnabled).toBeTruthy();
expect(data.modules.length).toBe(2);
expect(data.modules[0].id).toBe('alfresco-fake-services');
expect(data.modules[1].id).toBe('alfresco-trashcan-fake');
done();
service.getEcmProductInfo()
.subscribe((data: EcmProductVersionModel) => {
expect(data).not.toBeNull();
expect(data.edition).toBe('FAKE');
expect(data.version.schema).toBe(999999);
expect(data.license.isClusterEnabled).toBeFalsy();
expect(data.status.isQuickShareEnabled).toBeTruthy();
expect(data.modules.length).toBe(2);
expect(data.modules[0].id).toBe('alfresco-fake-services');
expect(data.modules[1].id).toBe('alfresco-trashcan-fake');
done();
});
});
jasmine.Ajax.requests.mostRecent().respondWith({
status: 200,
contentType: 'json',
responseText: fakeEcmDiscoveryResponse
it('getEcmProductInfo catch errors call', done => {
spyOn(apiService.getInstance().discovery.discoveryApi, 'getRepositoryInformation')
.and.returnValue(throwError({ status: 403 }));
service.getEcmProductInfo().subscribe(
() => {},
() => {
done();
}
);
});
});
it('getEcmProductInfo catch errors call', (done) => {
service.getEcmProductInfo().subscribe(
() => {
},
() => {
describe('For BPM', () => {
it('Should retrieve the info about the product for BPM', done => {
spyOn(apiService.getInstance().activiti.aboutApi, 'getAppVersion')
.and.returnValue(of(fakeBPMDiscoveryResponse));
service.getBpmProductInfo().subscribe((data: BpmProductVersionModel) => {
expect(data).not.toBeNull();
expect(data.edition).toBe('SUPER FAKE EDITION');
expect(data.revisionVersion).toBe('2');
expect(data.type).toBe('bpmSuite');
done();
});
});
it('getBpmProductInfo catch errors call', done => {
spyOn(apiService.getInstance().activiti.aboutApi, 'getAppVersion')
.and.returnValue(throwError({ status: 403 }));
service.getBpmProductInfo().subscribe(
() => {},
() => {
done();
}
);
});
it('Should retrieve the system properties for BPM', done => {
spyOn(apiService.getInstance().activiti.systemPropertiesApi, 'getProperties')
.and.returnValue(of(fakeBPMDiscoverySystemPropertyResponse));
service.getBPMSystemProperties().subscribe((data: SystemPropertiesRepresentation) => {
expect(data).not.toBeNull();
expect(data.allowInvolveByEmail).toBe(true);
expect(data.disableJavaScriptEventsInFormEditor).toBe(false);
expect(data.logoutDisabled).toBe(false);
expect(data.authConfiguration.authUrl).toBe('fakeAuthUrl');
expect(data.authConfiguration.realm).toBe('fakeRealm');
expect(data.authConfiguration.clientId).toBe('fakeClient');
expect(data.authConfiguration.useBrowserLogout).toBe(true);
done();
});
});
it('Should retrieve the system properties for BPM', done => {
spyOn(
apiService.getInstance().activiti.systemPropertiesApi,
'getProperties'
).and.returnValue(
throwError({
error: {
response: {
statusCode: 404,
statusText: 'Not Found'
}
}
})
);
service.getBPMSystemProperties().subscribe(
() => {
fail('expected an error, bpm not running');
},
error => {
expect(error.response.statusCode).toEqual(404);
expect(error.response.statusText).toEqual('Not Found');
done();
}
);
});
});
});
describe('Oauth', () => {
setupTestBed({
imports: [
TranslateModule.forRoot(),
CoreTestingModule
]
});
beforeEach(() => {
service = TestBed.inject(DiscoveryApiService);
apiService = TestBed.inject(AlfrescoApiService);
authenticationService = TestBed.inject(AuthenticationService);
});
it('Should retrieve the info about the product for Oauth', done => {
spyOn(apiService.getInstance(), 'isEcmLoggedIn').and.returnValue(true);
spyOn(service, 'getEcmProductInfo').and.returnValue(of(new EcmProductVersionModel(fakeEcmDiscoveryResponse)));
const subscription = service.ecmProductInfo$.subscribe(
(data: EcmProductVersionModel) => {
expect(data).not.toBeNull();
expect(data.edition).toBe('FAKE');
expect(data.version.schema).toBe(999999);
expect(data.license.isClusterEnabled).toBeFalsy();
expect(data.status.isQuickShareEnabled).toBeTruthy();
expect(data.modules.length).toBe(2);
expect(data.modules[0].id).toBe('alfresco-fake-services');
expect(data.modules[1].id).toBe('alfresco-trashcan-fake');
subscription.unsubscribe();
done();
});
jasmine.Ajax.requests.mostRecent().respondWith({
status: 403
});
});
});
describe('For BPM', () => {
it('Should retrieve the info about the product for BPM', (done) => {
service.getBpmProductInfo().subscribe((data: BpmProductVersionModel) => {
expect(data).not.toBeNull();
expect(data.edition).toBe('SUPER FAKE EDITION');
expect(data.revisionVersion).toBe('2');
expect(data.type).toBe('bpmSuite');
done();
});
jasmine.Ajax.requests.mostRecent().respondWith({
status: 200,
contentType: 'json',
responseText: fakeBPMDiscoveryResponse
});
});
it('getBpmProductInfo catch errors call', (done) => {
service.getBpmProductInfo().subscribe(
() => {
},
() => {
done();
});
jasmine.Ajax.requests.mostRecent().respondWith({
status: 403
});
});
it('Should retrieve the system properties for BPM', (done) => {
service.getBPMSystemProperties().subscribe((data: SystemPropertiesRepresentation) => {
expect(data).not.toBeNull();
expect(data.allowInvolveByEmail).toBe(true);
expect(data.disableJavaScriptEventsInFormEditor).toBe(false);
expect(data.logoutDisabled).toBe(false);
expect(data.authConfiguration.authUrl).toBe('fakeAuthUrl');
expect(data.authConfiguration.realm).toBe('fakeRealm');
expect(data.authConfiguration.clientId).toBe('fakeClient');
expect(data.authConfiguration.useBrowserLogout).toBe(true);
done();
});
jasmine.Ajax.requests.mostRecent().respondWith({
status: 200,
contentType: 'json',
responseText: fakeBPMDiscoverySystemPropertyResponse
});
});
it('Should retrieve the system properties for BPM', (done) => {
service.getBPMSystemProperties().subscribe(
() => {
fail('expected an error, bpm not running');
},
(error) => {
expect(error.response.statusCode).toEqual(404);
expect(error.response.statusText).toEqual('Not Found');
done();
});
jasmine.Ajax.requests.mostRecent().respondWith({
status: 404,
statusText: 'Not Found'
});
}
);
authenticationService.onTokenExchange.next('<token>');
});
});
});

View File

@ -16,10 +16,10 @@
*/
import { Injectable } from '@angular/core';
import { from, merge, Observable, BehaviorSubject, throwError } from 'rxjs';
import { from, merge, Observable, throwError, Subject } from 'rxjs';
import { BpmProductVersionModel, EcmProductVersionModel } from '../models/product-version.model';
import { AlfrescoApiService } from './alfresco-api.service';
import { catchError, filter, map, switchMap } from 'rxjs/operators';
import { catchError, filter, map, switchMap, take } from 'rxjs/operators';
import { Activiti, SystemPropertiesRepresentation } from '@alfresco/js-api';
import { AuthenticationService } from './authentication.service';
@ -31,13 +31,13 @@ export class DiscoveryApiService {
/**
* Gets product information for Content Services.
*/
ecmProductInfo$ = new BehaviorSubject<EcmProductVersionModel>(null);
ecmProductInfo$ = new Subject<EcmProductVersionModel>();
constructor(
private apiService: AlfrescoApiService,
private authenticationService: AuthenticationService) {
merge(this.apiService.alfrescoApiInitialized, this.authenticationService.onLogin)
merge(this.authenticationService.onTokenExchange.pipe(take(1)), this.authenticationService.onLogin)
.pipe(
filter(() => this.apiService.getInstance()?.isEcmLoggedIn()),
switchMap(() => this.getEcmProductInfo())

View File

@ -22,7 +22,7 @@ import {
Core,
Node
} from '@alfresco/js-api';
import { Subject } from 'rxjs';
import { ReplaySubject, Subject } from 'rxjs';
@Injectable({
providedIn: 'root'
@ -34,6 +34,8 @@ export class ExternalAlfrescoApiService {
*/
nodeUpdated = new Subject<Node>();
alfrescoApiInitialized: ReplaySubject<boolean> = new ReplaySubject(1);
protected alfrescoApi: AlfrescoApiCompatibility;
getInstance(): AlfrescoApiCompatibility {
@ -60,6 +62,7 @@ export class ExternalAlfrescoApiService {
domainPrefix
};
this.initAlfrescoApi(config);
this.alfrescoApiInitialized.next(true);
}
protected initAlfrescoApi(config) {

View File

@ -36,7 +36,8 @@ describe('AppListCloudComponent', () => {
const mock = {
oauth2Auth: {
callCustomApi: () => Promise.resolve(fakeApplicationInstance)
callCustomApi: () => Promise.resolve(fakeApplicationInstance),
on: jasmine.createSpy('on')
},
isEcmLoggedIn() {
return false;

View File

@ -32,7 +32,8 @@ describe('AppsProcessCloudService', () => {
const apiMock = {
oauth2Auth: {
callCustomApi: () => Promise.resolve({list : { entries: [ {entry: fakeApplicationInstance[0]}, {entry: fakeApplicationInstance[1]}] }})
callCustomApi: () => Promise.resolve({list : { entries: [ {entry: fakeApplicationInstance[0]}, {entry: fakeApplicationInstance[1]}] }}),
on: jasmine.createSpy('on')
},
isEcmLoggedIn() {
return false;

View File

@ -29,7 +29,7 @@ const responseBody = {
{ id: 'id', name: 'name', formKey: 'form-key' }
};
const oauth2Auth = jasmine.createSpyObj('oauth2Auth', ['callCustomApi']);
const oauth2Auth = jasmine.createSpyObj('oauth2Auth', ['callCustomApi', 'on']);
describe('Form Cloud service', () => {

View File

@ -52,7 +52,7 @@ const responseBody = [
}
];
const oauth2Auth = jasmine.createSpyObj('oauth2Auth', ['callCustomApi']);
const oauth2Auth = jasmine.createSpyObj('oauth2Auth', ['callCustomApi', 'on']);
describe('Form Definition Selector Cloud Service', () => {

View File

@ -42,7 +42,8 @@ describe('GroupCloudComponent', () => {
const mock = {
oauth2Auth: {
callCustomApi: () => Promise.resolve(mockIdentityGroups)
callCustomApi: () => Promise.resolve(mockIdentityGroups),
on: jasmine.createSpy('on')
},
isEcmLoggedIn() {
return false;

View File

@ -42,7 +42,8 @@ describe('PeopleCloudComponent', () => {
const mock = {
oauth2Auth: {
callCustomApi: () => Promise.resolve(mockUsers)
callCustomApi: () => Promise.resolve(mockUsers),
on: jasmine.createSpy('on')
},
isEcmLoggedIn() {
return false;

View File

@ -66,7 +66,8 @@ describe('EditProcessFilterCloudComponent', () => {
const mock = {
oauth2Auth: {
callCustomApi: () => Promise.resolve(fakeApplicationInstance)
callCustomApi: () => Promise.resolve(fakeApplicationInstance),
on: jasmine.createSpy('on')
},
isEcmLoggedIn() {
return false;

View File

@ -45,7 +45,8 @@ describe('NotificationCloudService', () => {
const apiServiceMock = {
oauth2Auth: {
token: '1234567'
token: '1234567',
on: jasmine.createSpy('on')
},
isEcmLoggedIn() {
return false;

View File

@ -38,7 +38,8 @@ describe('PreferenceService', () => {
oauth2Auth: {
callCustomApi: () => {
return Promise.resolve(mockResponse);
}
},
on: jasmine.createSpy('on')
},
isEcmLoggedIn() {
return false;

View File

@ -40,7 +40,8 @@ describe('StartTaskCloudComponent', () => {
const mock = {
oauth2Auth: {
callCustomApi: () => Promise.resolve(taskDetailsMock)
callCustomApi: () => Promise.resolve(taskDetailsMock),
on: jasmine.createSpy('on')
},
isEcmLoggedIn() {
return false;

View File

@ -53,7 +53,8 @@ describe('EditTaskFilterCloudComponent', () => {
const mock = {
oauth2Auth: {
callCustomApi: () => Promise.resolve(fakeApplicationInstance)
callCustomApi: () => Promise.resolve(fakeApplicationInstance),
on: jasmine.createSpy('on')
},
isEcmLoggedIn() {
return false;

View File

@ -51,7 +51,8 @@ describe('TaskHeaderCloudComponent', () => {
const mock = {
oauth2Auth: {
callCustomApi: () => Promise.resolve({})
callCustomApi: () => Promise.resolve({}),
on: jasmine.createSpy('on')
},
isEcmLoggedIn() {
return false;

View File

@ -31,7 +31,8 @@ describe('Activiti ServiceTaskList Cloud Service', () => {
oauth2Auth: {
callCustomApi: (_queryUrl, _operation, _context, queryParams) => {
return Promise.resolve(queryParams);
}
},
on: jasmine.createSpy('on')
},
isEcmLoggedIn() {
return false;

View File

@ -32,7 +32,8 @@ describe('TaskListCloudService', () => {
oauth2Auth: {
callCustomApi : (_queryUrl, _operation, _context, queryParams) => {
return Promise.resolve(queryParams);
}
},
on: jasmine.createSpy('on')
},
isEcmLoggedIn() {
return false;

View File

@ -15,17 +15,18 @@
* limitations under the License.
*/
import { CustomModel, CustomModelApi, CustomModelProperty, CustomType, TypePaging, TypesApi } from '@alfresco/js-api';
import { ApiService } from '../../core/actions/api.service';
import { CustomModel, CustomModelApi, CustomType, TypePaging, TypesApi } from '@alfresco/js-api';
import { ApiUtil } from '../../core/actions/api.util';
import { Logger } from '../../core/utils/logger';
export class ModelActions {
customModelApi: CustomModelApi;
typesApi: TypesApi;
constructor(api: ApiService) {
this.customModelApi = new CustomModelApi(api.getInstance());
this.typesApi = new TypesApi(api.getInstance());
constructor(apiService: ApiService) {
this.customModelApi = new CustomModelApi(apiService.getInstance());
this.typesApi = new TypesApi(apiService.getInstance());
}
async createModel({status, description, name, namespaceUri, namespacePrefix, author}: CustomModel): Promise<{ entry: CustomModel }> {
@ -36,6 +37,10 @@ export class ModelActions {
return this.customModelApi.createCustomType(modelName, name, parentName, title, description);
}
async addPropertyToType(modelName: string, typeName: string, properties?: CustomModelProperty[]): Promise<CustomType> {
return this.customModelApi.addPropertyToType(modelName , typeName, properties);
}
async activateCustomModel(modelName: string): Promise<{ entry: CustomModel }> {
return this.customModelApi.activateCustomModel(modelName);
}
@ -44,7 +49,25 @@ export class ModelActions {
return this.customModelApi.deactivateCustomModel(modelName);
}
async deleteCustomModel(modelName: string): Promise<{ entry: CustomModel }> {
return this.customModelApi.deleteCustomModel(modelName);
}
async listTypes(opts?: any): Promise<TypePaging> {
return this.typesApi.listTypes(opts);
}
async isCustomTypeSearchable(title: string): Promise<any> {
const predicate = (result: TypePaging) => !!result.list.entries.find(({entry}) => entry.title === title);
const apiCall = async () => {
try {
return this.listTypes({where: `(not namespaceUri matches('http://www.alfresco.*'))`});
} catch (error) {
Logger.error('Failed to list types', error);
return null;
}
};
return ApiUtil.waitForApi(apiCall, predicate);
}
}

View File

@ -20,6 +20,7 @@ import { BrowserActions } from '../../core/utils/browser-actions';
import { DataTableComponentPage } from '../../core/pages/data-table-component.page';
import { BrowserVisibility } from '../../core/utils/browser-visibility';
import { DropdownPage } from '../../core/pages/material/dropdown.page';
import { TestElement } from '../../core/test-element';
const column = {
role: 'Role'
@ -102,10 +103,10 @@ export class AddPermissionsDialogPage {
await BrowserActions.click(this.addButton);
}
async selectRole(name: string, role) {
async selectRole(name: string, role: string) {
const row = this.userRoleDataTableComponentPage.getRow('Users and Groups', name);
await BrowserActions.click(row.element(by.css('[id="adf-select-role-permission"] .mat-select-trigger')));
await this.getRoleDropdownOptions();
await TestElement.byCss('.mat-select-panel').waitVisible();
await this.selectOption(role);
}
}