Remove dead code from the e2e (#3542)

* cleanup dead code

* cleanup dead code

* cleanup dead code

* cleanup dead code

* cleanup dead code

* cleanup dead code
This commit is contained in:
Denys Vuika
2023-11-28 16:00:00 +00:00
committed by GitHub
parent 53931b0d27
commit 8aaca5f693
29 changed files with 9 additions and 1016 deletions

View File

@@ -22,8 +22,8 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { PersonEntry, NodeEntry, PeopleApi } from '@alfresco/js-api';
import { PersonModel, SitesApi, UploadApi, NodesApi, NodeContentTree, Person, SharedLinksApi } from './repo-client/apis';
import { PersonEntry, PeopleApi } from '@alfresco/js-api';
import { PersonModel, SitesApi, UploadApi, NodesApi, Person, SharedLinksApi } from './repo-client/apis';
import { UserActions } from './user-actions';
import { browser } from 'protractor';
@@ -37,31 +37,6 @@ export class AdminActions extends UserActions {
return super.login(username || browser.params.ADMIN_USERNAME, password || browser.params.ADMIN_PASSWORD);
}
private async getDataDictionaryId(): Promise<string> {
return this.nodes.getNodeIdFromParent('Data Dictionary', '-root-').catch((error) => {
super.handleError('Admin Actions - getDataDictionaryId failed : ', error);
return '';
});
}
async getNodeTemplatesFolderId(): Promise<string> {
try {
return this.nodes.getNodeIdFromParent('Node Templates', await this.getDataDictionaryId());
} catch (error) {
super.handleError('Admin Actions - getNodeTemplatesFolderId failed : ', error);
return '';
}
}
async getSpaceTemplatesFolderId(): Promise<string> {
try {
return this.nodes.getNodeIdFromParent('Space Templates', await this.getDataDictionaryId());
} catch (error) {
super.handleError('Admin Actions - getSpaceTemplatesFolderId failed : ', error);
return '';
}
}
async createUser(user: PersonModel): Promise<PersonEntry> {
const person = new Person(user);
const peopleApi = new PeopleApi(this.alfrescoApi);
@@ -74,118 +49,4 @@ export class AdminActions extends UserActions {
return null;
}
}
async disableUser(username: string): Promise<PersonEntry> {
const peopleApi = new PeopleApi(this.alfrescoApi);
await this.login();
try {
return peopleApi.updatePerson(username, { enabled: false });
} catch (error) {
super.handleError('Admin Actions - createUser failed : ', error);
return null;
}
}
async changePassword(username: string, newPassword: string): Promise<PersonEntry> {
const peopleApi = new PeopleApi(this.alfrescoApi);
await this.login();
try {
return peopleApi.updatePerson(username, { password: newPassword });
} catch (error) {
super.handleError('Admin Actions - changePassword failed : ', error);
return null;
}
}
async createNodeTemplatesHierarchy(hierarchy: NodeContentTree): Promise<any> {
return this.nodes.createContent(hierarchy, `Data Dictionary/Node Templates`).catch((error) => {
super.handleError('Admin Actions - createNodeTemplatesHierarchy failed : ', error);
});
}
async createSpaceTemplatesHierarchy(hierarchy: NodeContentTree): Promise<any> {
return this.nodes.createContent(hierarchy, `Data Dictionary/Space Templates`).catch((error) => {
super.handleError('Admin Actions - createSpaceTemplatesHierarchy failed : ', error);
});
}
async removeUserAccessOnNodeTemplate(nodeName: string): Promise<NodeEntry> {
try {
const templatesRootFolderId = await this.getNodeTemplatesFolderId();
const nodeId: string = await this.nodes.getNodeIdFromParent(nodeName, templatesRootFolderId);
return this.nodes.setInheritPermissions(nodeId, false);
} catch (error) {
super.handleError('Admin Actions - removeUserAccessOnNodeTemplate failed : ', error);
return null;
}
}
async removeUserAccessOnSpaceTemplate(nodeName: string): Promise<NodeEntry> {
try {
const templatesRootFolderId = await this.getSpaceTemplatesFolderId();
const nodeId: string = await this.nodes.getNodeIdFromParent(nodeName, templatesRootFolderId);
return this.nodes.setInheritPermissions(nodeId, false);
} catch (error) {
super.handleError('Admin Actions - removeUserAccessOnSpaceTemplate failed : ', error);
return null;
}
}
async cleanupNodeTemplatesItems(nodeNames: string[]): Promise<void> {
try {
const templatesFolderId = await this.getNodeTemplatesFolderId();
for (const nodeName of nodeNames) {
const nodeId = await this.nodes.getNodeIdFromParent(nodeName, templatesFolderId);
await this.nodes.deleteNodeById(nodeId);
}
} catch (error) {
super.handleError('Admin Actions - cleanupNodeTemplatesItems failed : ', error);
}
}
async cleanupSpaceTemplatesItems(nodeNames: string[]): Promise<void> {
try {
const spaceTemplatesNodeId = await this.getSpaceTemplatesFolderId();
for (const nodeName of nodeNames) {
const nodeId = await this.nodes.getNodeIdFromParent(nodeName, spaceTemplatesNodeId);
await this.nodes.deleteNodeById(nodeId);
}
} catch (error) {
super.handleError('Admin Actions - cleanupSpaceTemplatesFolder failed : ', error);
}
}
async createLinkToFileName(originalFileName: string, originalFileParentId: string, destinationParentId?: string): Promise<NodeEntry> {
if (!destinationParentId) {
destinationParentId = originalFileParentId;
}
try {
const nodeId = await this.nodes.getNodeIdFromParent(originalFileName, originalFileParentId);
return this.nodes.createFileLink(nodeId, destinationParentId);
} catch (error) {
super.handleError('Admin Actions - createLinkToFileName failed : ', error);
return null;
}
}
async createLinkToFolderName(originalFolderName: string, originalFolderParentId: string, destinationParentId?: string): Promise<NodeEntry> {
if (!destinationParentId) {
destinationParentId = originalFolderParentId;
}
try {
const nodeId = await this.nodes.getNodeIdFromParent(originalFolderName, originalFolderParentId);
return this.nodes.createFolderLink(nodeId, destinationParentId);
} catch (error) {
super.handleError('Admin Actions - createLinkToFolderName failed : ', error);
return null;
}
}
}

View File

@@ -1,38 +0,0 @@
/*!
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { browser } from 'protractor';
import { USE_HASH_STRATEGY } from '../configs';
export async function navigate(relativePath: string) {
const path = [
browser.baseUrl,
browser.baseUrl.endsWith('/') ? '' : '/',
USE_HASH_STRATEGY ? '#' : '',
relativePath.startsWith('/') ? '' : '/',
relativePath
].join('');
return browser.get(path);
}

View File

@@ -26,5 +26,4 @@ export * from './repo-client/apis';
export * from './repo-client/repo-client';
export * from './admin-actions';
export * from './user-actions';
export * from './browser-utils';
export * from './utils';

View File

@@ -93,16 +93,6 @@ export class FavoritesApi extends RepoApi {
}
}
async getFavoriteById(nodeId: string) {
try {
await this.apiAuth();
return await this.favoritesApi.getFavorite('-me-', nodeId);
} catch (error) {
this.handleError(`FavoritesApi getFavoriteById : catch : `, error);
return null;
}
}
async isFavorite(nodeId: string) {
try {
return JSON.stringify((await this.getFavorites()).list.entries).includes(nodeId);

View File

@@ -74,16 +74,6 @@ export class NodesApi extends RepoApi {
}
}
async getNodeTitle(name: string, parentId: string): Promise<string> {
try {
const children = (await this.getNodeChildren(parentId)).list.entries;
return children.find((elem) => elem.entry.name === name).entry.properties['cm:title'];
} catch (error) {
this.handleError(`${this.constructor.name} ${this.getNodeTitle.name}`, error);
return '';
}
}
async getNodeProperty(nodeId: string, property: string): Promise<string> {
try {
const node = await this.getNodeById(nodeId);
@@ -341,27 +331,6 @@ export class NodesApi extends RepoApi {
}
}
async createFileLink(originalNodeId: string, destinationId: string): Promise<NodeEntry | null> {
const name = (await this.getNodeById(originalNodeId)).entry.name;
const nodeBody = {
name: `Link to ${name}.url`,
nodeType: 'app:filelink',
properties: {
'cm:destination': originalNodeId
}
};
try {
await this.apiAuth();
const link = await this.nodesApi.createNode(destinationId, nodeBody);
await this.addAspects(originalNodeId, ['app:linked']);
return link;
} catch (error) {
this.handleError(`${this.constructor.name} ${this.createFileLink.name}`, error);
return null;
}
}
async createFolderLink(originalNodeId: string, destinationId: string): Promise<NodeEntry | null> {
const name = (await this.getNodeById(originalNodeId)).entry.name;
const nodeBody = {
@@ -407,33 +376,6 @@ export class NodesApi extends RepoApi {
}
}
async renameNode(nodeId: string, newName: string): Promise<NodeEntry | null> {
try {
await this.apiAuth();
return this.nodesApi.updateNode(nodeId, { name: newName });
} catch (error) {
this.handleError(`${this.constructor.name} ${this.renameNode.name}`, error);
return null;
}
}
// node permissions
async setInheritPermissions(nodeId: string, inheritPermissions: boolean): Promise<NodeEntry | null> {
const data = {
permissions: {
isInheritanceEnabled: inheritPermissions
}
};
try {
await this.apiAuth();
return await this.nodesApi.updateNode(nodeId, data);
} catch (error) {
this.handleError(`${this.constructor.name} ${this.setGranularPermission.name}`, error);
return null;
}
}
async setGranularPermission(nodeId: string, inheritPermissions: boolean = false, username: string, role: string): Promise<NodeEntry | null> {
const data = {
permissions: {

View File

@@ -118,21 +118,6 @@ export class SitesApi extends RepoApi {
}
}
async deleteAllUserSites(permanent: boolean = true) {
try {
await this.apiAuth();
const sites = await this.sitesApi.listSiteMembershipsForPerson(this.username);
const siteIds = sites.list.entries.map((entries) => entries.entry.id);
return await siteIds.reduce(async (previous, current) => {
await previous;
return this.deleteSite(current, permanent);
}, Promise.resolve());
} catch (error) {
this.handleError(`SitesApi deleteAllUserSites : catch : `, error);
}
}
async updateSiteMember(siteId: string, userId: string, role: string) {
const siteRole = {
role: role
@@ -178,10 +163,6 @@ export class SitesApi extends RepoApi {
return this.addSiteMember(siteId, userId, SITE_ROLES.SITE_COLLABORATOR.ROLE);
}
async addSiteManager(siteId: string, userId: string): Promise<SiteMemberEntry> {
return this.addSiteMember(siteId, userId, SITE_ROLES.SITE_MANAGER.ROLE);
}
async deleteSiteMember(siteId: string, userId: string) {
try {
await this.apiAuth();

View File

@@ -69,11 +69,6 @@ export class RepoClient {
return new UploadApi(this.username, this.password);
}
async logout(): Promise<any> {
await this.apiAuth();
return this.alfrescoApi.logout();
}
async createFolder(name: string, parentId?: string): Promise<string> {
const response = await this.nodes.createFolder(name, parentId);
return response.entry.id;

View File

@@ -23,9 +23,8 @@
*/
import { Logger } from '@alfresco/adf-testing';
import { AlfrescoApi, Comment, CommentsApi, NodesApi, TrashcanApi, SitesApi, SharedlinksApi, SiteEntry } from '@alfresco/js-api';
import { AlfrescoApi, Comment, CommentsApi, NodesApi, TrashcanApi, SitesApi, SharedlinksApi } from '@alfresco/js-api';
import { browser } from 'protractor';
import { SITE_VISIBILITY } from '../configs';
import { Utils } from './utils';
export class UserActions {
@@ -62,15 +61,6 @@ export class UserActions {
}
}
async logout(): Promise<any> {
try {
await this.alfrescoApi.login(this.username, this.password);
return this.alfrescoApi.logout();
} catch (error) {
this.handleError('User Actions - logout failed : ', error);
}
}
async createComment(nodeId: string, content: string): Promise<Comment | null> {
try {
const comment = await this.commentsApi.createComment(nodeId, { content });
@@ -180,32 +170,6 @@ export class UserActions {
}
}
/**
* Create multiple sites
* @param siteNames The list of the site names
* @param visibility Default site visibility
* @returns List of site entries
*/
async createSites(siteNames: string[], visibility?: string): Promise<SiteEntry[]> {
const sites: SiteEntry[] = [];
try {
if (siteNames && siteNames.length > 0) {
for (const siteName of siteNames) {
const site = await this.sitesApi.createSite({
title: siteName,
visibility: visibility || SITE_VISIBILITY.PUBLIC,
id: siteName
});
sites.push(site);
}
}
} catch (error) {
this.handleError(`User Actions - createSites failed : `, error);
}
return sites;
}
/**
* Delete multiple sites/libraries.
* @param siteIds The list of the site/library IDs to delete.

View File

@@ -86,10 +86,6 @@ export class Utils {
return crypto.getRandomValues(new Uint32Array(1))[0].toString(36).substring(0, 5).toLowerCase();
}
static async clearLocalStorage(): Promise<void> {
await browser.executeScript('window.localStorage.clear();');
}
static async setSessionStorageFromConfig(configFileName: string): Promise<void> {
const configFile = `${browser.params.e2eRootPath}/resources/extensibility-configs/${configFileName}`;
const fileContent = JSON.stringify(fs.readFileSync(configFile, { encoding: 'utf8' }));