mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[ACA-2008] tests for add favourite /remove favorite on a site (#810)
This commit is contained in:
committed by
Denys Vuika
parent
79f92c38ef
commit
9b7ad0b0b3
@@ -79,13 +79,32 @@ export class FavoritesApi extends RepoApi {
|
||||
|
||||
async getFavoriteById(nodeId: string) {
|
||||
await this.apiAuth();
|
||||
return await this.alfrescoJsApi.core.favoritesApi.getFavorite('-me', nodeId);
|
||||
return await this.alfrescoJsApi.core.favoritesApi.getFavorite('-me-', nodeId);
|
||||
}
|
||||
|
||||
async isFavorite(nodeId: string) {
|
||||
return JSON.stringify((await this.getFavorites()).list.entries).includes(nodeId);
|
||||
}
|
||||
|
||||
async isFavoriteWithRetry(nodeId: string, data) {
|
||||
let isFavorite;
|
||||
try {
|
||||
const favorite = async () => {
|
||||
isFavorite = JSON.stringify((await this.getFavorites()).list.entries).includes(nodeId);
|
||||
if ( isFavorite !== data.expect ) {
|
||||
return Promise.reject(isFavorite);
|
||||
} else {
|
||||
return Promise.resolve(isFavorite);
|
||||
}
|
||||
};
|
||||
|
||||
return await Utils.retryCall(favorite);
|
||||
} catch (error) {
|
||||
console.log('-----> catch isFavoriteWithRetry: ', error);
|
||||
}
|
||||
return isFavorite;
|
||||
}
|
||||
|
||||
async removeFavoriteById(nodeId: string) {
|
||||
await this.apiAuth();
|
||||
return await this.alfrescoJsApi.core.peopleApi.removeFavoriteSite('-me-', nodeId);
|
||||
|
Reference in New Issue
Block a user