[ACS-6066] viewer special permissions playwright (#3453)

* [ACS-5923] sidenav and singleclick test

* [ACS-5923] remove protractor test and fix flaky test

* [ACS-5923] test fix

* [ACS-5639] fix exclude test  in viewer

* [ACS-5923] remove exclude test and fix test

* [ACS-6066] viewer special permissions playwright test

* [ACS-6066] viewer protractor test remove

* [ACS-6066] viewer failed test fix

* [ACS-5923] review changes added

* [ACS-5923] fix error in script
This commit is contained in:
Akash Rathod
2023-10-05 12:19:57 +02:00
committed by GitHub
parent 4059a3d219
commit f2d09e8b1a
30 changed files with 1515 additions and 39 deletions

View File

@@ -23,7 +23,7 @@
*/
import { ApiClientFactory } from './api-client-factory';
import { FavoriteEntry } from '@alfresco/js-api';
import { FavoriteEntry, FavoritePaging } from '@alfresco/js-api';
import { Logger } from '@alfresco/adf-testing';
import { Utils } from '../utils';
@@ -38,7 +38,7 @@ export class FavoritesPageApi {
await classObj.apiService.setUpAcaBackend(userName, password);
return classObj;
}
async addFavoriteById(nodeType: 'file' | 'folder' | 'site', id: string): Promise<FavoriteEntry | null> {
async addFavoriteById(nodeType: 'file' | 'folder' | 'site', id: string): Promise<FavoriteEntry> {
let guid = nodeType === 'site' ? (await this.apiService.sites.getSite(id)).entry.guid : id;
const data = {
target: {
@@ -50,25 +50,40 @@ export class FavoritesPageApi {
return await this.apiService.favorites.createFavorite('-me-', data);
}
private async getFavorites(username: string) {
async addFavoritesByIds(nodeType: 'file' | 'folder' | 'site', ids: string[]): Promise<FavoriteEntry[]> {
const favorites: FavoriteEntry[] = [];
try {
if (ids && ids.length > 0) {
for (const id of ids) {
const favorite = await this.addFavoriteById(nodeType, id);
favorites.push(favorite);
}
}
} catch (error) {
Logger.error(`FavoritesApi addFavoritesByIds : catch : `, error);
}
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 null;
return new FavoritePaging;
}
}
async isFavorite(username: string, nodeId: string) {
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);
return null;
return false;
}
}
async isFavoriteWithRetry(username: string, nodeId: string, data: { expect: boolean }) {
async isFavoriteWithRetry(username: string, nodeId: string, data: { expect: boolean }): Promise<boolean> {
let isFavorite = false;
try {
const favorite = async () => {
@@ -83,4 +98,30 @@ export class FavoritesPageApi {
} catch (error) {}
return isFavorite;
}
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);
return -1;
}
}
async waitForApi(username: string, data: { expect: number }) {
try {
const favoriteFiles = async () => {
const totalItems = await this.getFavoritesTotalItems(username);
if (totalItems !== data.expect) {
return Promise.reject(totalItems);
} else {
return Promise.resolve(totalItems);
}
};
return await Utils.retryCall(favoriteFiles);
} catch (error) {
Logger.error(`FavoritesApi waitForApi : catch : `);
Logger.error(`\tExpected: ${data.expect} items, but found ${error}`);
}
}
}