mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[ACS-6572] break dependency on adf-testing (#3594)
* remove Logger dependency * remove BrowserVisibility dependency * remove BrowserActions dependency * remove ViewerPage dependency * remove ApiUtil dependency * remove StringUtil dependency * remove adf-testing dependency * bug fixes
This commit is contained in:
@@ -24,7 +24,6 @@
|
||||
|
||||
import { ApiClientFactory } from './api-client-factory';
|
||||
import { FavoriteEntry, FavoritePaging } from '@alfresco/js-api';
|
||||
import { Logger } from '@alfresco/adf-testing';
|
||||
import { Utils } from '../utils';
|
||||
|
||||
export class FavoritesPageApi {
|
||||
@@ -59,26 +58,22 @@ export class FavoritesPageApi {
|
||||
favorites.push(favorite);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
Logger.error(`FavoritesApi addFavoritesByIds : catch : `, error);
|
||||
}
|
||||
} catch {}
|
||||
return favorites;
|
||||
}
|
||||
|
||||
private async getFavorites(username: string): Promise<FavoritePaging> {
|
||||
try {
|
||||
return await this.apiService.favorites.listFavorites(username);
|
||||
} catch (error) {
|
||||
Logger.error(`FavoritesApi getFavorites : catch : `, error);
|
||||
return new FavoritePaging;
|
||||
} catch {
|
||||
return new FavoritePaging();
|
||||
}
|
||||
}
|
||||
|
||||
async isFavorite(username: string, nodeId: string): Promise<boolean> {
|
||||
try {
|
||||
return JSON.stringify((await this.getFavorites(username)).list.entries).includes(nodeId);
|
||||
} catch (error) {
|
||||
Logger.error(`FavoritesApi isFavorite : catch : `, error);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -102,8 +97,7 @@ export class FavoritesPageApi {
|
||||
async getFavoritesTotalItems(username: string): Promise<number> {
|
||||
try {
|
||||
return (await this.apiService.favorites.listFavorites(username)).list.pagination.totalItems;
|
||||
} catch (error) {
|
||||
Logger.error(`FavoritesApi getFavoritesTotalItems : catch : `, error);
|
||||
} catch {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -119,9 +113,6 @@ export class FavoritesPageApi {
|
||||
}
|
||||
};
|
||||
return await Utils.retryCall(favoriteFiles);
|
||||
} catch (error) {
|
||||
Logger.error(`FavoritesApi waitForApi : catch : `);
|
||||
Logger.error(`\tExpected: ${data.expect} items, but found ${error}`);
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
|
@@ -25,8 +25,8 @@
|
||||
import * as fs from 'fs';
|
||||
import { ApiClientFactory } from './api-client-factory';
|
||||
import { Utils } from '../utils';
|
||||
import { ApiUtil, Logger } from '@alfresco/adf-testing';
|
||||
import { NodeBodyCreate, NodeEntry, ResultSetPaging } from '@alfresco/js-api';
|
||||
import { waitForApi } from '@alfresco/aca-testing-shared';
|
||||
|
||||
export class FileActionsApi {
|
||||
private apiService: ApiClientFactory;
|
||||
@@ -73,7 +73,6 @@ export class FileActionsApi {
|
||||
try {
|
||||
return await this.apiService.upload.uploadFile(file, '', parentId, nodeProps, opts);
|
||||
} catch (error) {
|
||||
Logger.error(`${this.constructor.name} ${this.uploadFileWithRename.name}`, error);
|
||||
return Promise.reject(error);
|
||||
}
|
||||
}
|
||||
@@ -83,16 +82,13 @@ export class FileActionsApi {
|
||||
for (const nodeId of nodeIds) {
|
||||
await this.apiService.nodes.lockNode(nodeId, { type: lockType });
|
||||
}
|
||||
} catch (error) {
|
||||
Logger.error(`${this.constructor.name} ${this.lockNodes.name}`, error);
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
|
||||
async getNodeById(id: string): Promise<NodeEntry | null> {
|
||||
try {
|
||||
return await this.apiService.nodes.getNode(id);
|
||||
} catch (error) {
|
||||
Logger.error(`${this.constructor.name} ${this.getNodeById.name}`, error);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -101,8 +97,7 @@ export class FileActionsApi {
|
||||
try {
|
||||
const node = await this.getNodeById(nodeId);
|
||||
return node.entry.properties?.[property] || '';
|
||||
} catch (error) {
|
||||
Logger.error(`${this.constructor.name} ${this.getNodeProperty.name}`, error);
|
||||
} catch {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -111,8 +106,7 @@ export class FileActionsApi {
|
||||
try {
|
||||
const lockType = await this.getNodeProperty(nodeId, 'cm:lockType');
|
||||
return lockType || '';
|
||||
} catch (error) {
|
||||
Logger.error(`${this.constructor.name} ${this.getLockType.name}`, error);
|
||||
} catch {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -133,9 +127,7 @@ export class FileActionsApi {
|
||||
}
|
||||
};
|
||||
return await Utils.retryCall(locked, data.retry);
|
||||
} catch (error) {
|
||||
Logger.error(`${this.constructor.name} ${this.isFileLockedWriteWithRetry.name}`, error);
|
||||
}
|
||||
} catch {}
|
||||
return isLocked;
|
||||
}
|
||||
|
||||
@@ -150,8 +142,7 @@ export class FileActionsApi {
|
||||
|
||||
try {
|
||||
return await this.apiService.search.search(data);
|
||||
} catch (error) {
|
||||
Logger.error(`SearchApi queryNodesNames : catch : `, error);
|
||||
} catch {
|
||||
return new ResultSetPaging();
|
||||
}
|
||||
}
|
||||
@@ -168,11 +159,8 @@ export class FileActionsApi {
|
||||
};
|
||||
|
||||
try {
|
||||
await ApiUtil.waitForApi(apiCall, predicate, 30, 2500);
|
||||
} catch (error) {
|
||||
Logger.error(`SearchApi waitForNodes : catch : `);
|
||||
Logger.error(`\tExpected: ${data.expect} items, but found ${error}`);
|
||||
}
|
||||
await waitForApi(apiCall, predicate, 30, 2500);
|
||||
} catch {}
|
||||
}
|
||||
|
||||
async updateNodeContent(nodeId: string, content: string, majorVersion: boolean = true, comment?: string, newName?: string): Promise<NodeEntry> {
|
||||
|
@@ -23,7 +23,6 @@
|
||||
*/
|
||||
|
||||
import { ApiClientFactory } from './api-client-factory';
|
||||
import { Logger } from '@alfresco/adf-testing';
|
||||
import { Utils } from '../utils';
|
||||
import { ResultSetPaging } from '@alfresco/js-api';
|
||||
|
||||
@@ -54,14 +53,13 @@ export class SearchPageApi {
|
||||
|
||||
try {
|
||||
return await this.apiService.search.search(data);
|
||||
} catch (error) {
|
||||
Logger.error(`SearchApi queryRecentFiles : catch : `, error);
|
||||
return new ResultSetPaging;
|
||||
} catch {
|
||||
return new ResultSetPaging();
|
||||
}
|
||||
}
|
||||
|
||||
async getTotalItems(username: string): Promise<number> {
|
||||
return (await this.querySearchFiles(username)).list.pagination.totalItems;
|
||||
return (await this.querySearchFiles(username)).list.pagination.totalItems;
|
||||
}
|
||||
|
||||
async waitForApi(username: string, data: { expect: number }) {
|
||||
@@ -76,9 +74,6 @@ export class SearchPageApi {
|
||||
};
|
||||
|
||||
return await Utils.retryCall(searchFiles);
|
||||
} catch (error) {
|
||||
Logger.error(`SearchApi waitForApi : catch : `);
|
||||
Logger.error(`\tExpected: ${data.expect} items, but found ${error}`);
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user