Skip to content

Commit

Permalink
[ACS-6239] Addressed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kritagya09 committed Nov 22, 2023
1 parent b2b9fc7 commit 290b6f1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
10 changes: 5 additions & 5 deletions e2e/playwright/pagination/src/tests/multiple-pages-files.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ test.describe('Pagination on multiple pages : ', () => {
const parent = `parent-${random}`;
let parentId: string;

const files = Array(51)
.fill('my-file')
.map((name, index): string => `${name}-${index + 1}-${random}.txt`);

const apiClientFactory = new ApiClientFactory();

test.beforeAll(async () => {
await apiClientFactory.setUpAcaBackend('admin');
await apiClientFactory.createUser({ username });
const nodesApi = await NodesApi.initialize(username, username);
parentId = (await nodesApi.createFolder(parent)).entry.id;

const files = Array(51)
.fill('my-file')
.map((name, index): string => `${name}-${index + 1}-${random}.txt`);

parentId = (await nodesApi.createFolder(parent)).entry.id;
(await nodesApi.createFiles(files, parent)).list.entries.map((entries: any) => entries.entry.id);
});

Expand Down
25 changes: 13 additions & 12 deletions projects/aca-playwright-shared/src/api/nodes-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/

import { ApiClientFactory } from './api-client-factory';
import { NodeChildAssociationPaging, NodeEntry } from '@alfresco/js-api';
import { NodeChildAssociationPaging, NodeEntry, NodePaging } from '@alfresco/js-api';
import { logger } from '@alfresco/adf-cli/scripts/logger';
import { NodeContentTree, flattenNodeContentTree } from './node-content-tree';

Expand Down Expand Up @@ -73,11 +73,12 @@ export class NodesApi {
}
}

async createFiles(names: string[], relativePath: string = '/'): Promise<NodeEntry | any> {
async createFiles(names: string[], relativePath = '/'): Promise<NodePaging> {
try {
return await this.createContent({ files: names }, relativePath);
} catch (error) {
throw new Error(`${this.constructor.name} ${this.createFiles.name}: ${error}`);
logger.error(`${this.constructor.name} ${this.createFiles.name}: ${error}`);
return null;
}
}

Expand Down Expand Up @@ -145,9 +146,9 @@ export class NodesApi {
}

/**
* Delete all nodes of the currently logged in user
* @param userNodeId The id of User node, all child nodes of "userNodeId" will be gathered as a list and deleted ( e.g.: "-my-" - User Homes folder)
*/
* Delete all nodes of the currently logged in user
* @param userNodeId The id of User node, all child nodes of "userNodeId" will be gathered as a list and deleted ( e.g.: "-my-" - User Homes folder)
*/
async deleteCurrentUserNodes(): Promise<void> {
try {
const userNodes = (await this.getNodeChildren('-my-')).list.entries;
Expand All @@ -168,11 +169,12 @@ export class NodesApi {
}
}

async createContent(content: NodeContentTree, relativePath: string = '/'): Promise<NodeEntry | any> {
async createContent(content: NodeContentTree, relativePath: string = '/'): Promise<NodePaging> {
try {
return await this.apiService.nodes.createNode('-my-', flattenNodeContentTree(content, relativePath) as any);
} catch (error) {
logger.error(`${this.constructor.name} ${this.createContent.name}`, error);
return null;
}
}

Expand Down Expand Up @@ -258,11 +260,10 @@ export class NodesApi {
}

private async getDataDictionaryId(): Promise<string> {
return this.getNodeIdFromParent('Data Dictionary', '-root-')
.catch((error) => {
logger.error('Admin Actions - getDataDictionaryId failed : ', error);
return '';
});
return this.getNodeIdFromParent('Data Dictionary', '-root-').catch((error) => {
logger.error('Admin Actions - getDataDictionaryId failed : ', error);
return '';
});
}

async setGranularPermission(nodeId: string, inheritPermissions: boolean = false, username: string, role: string): Promise<NodeEntry | null> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ export class PersonalFilesPage extends BasePage {
}

async closeMenu(): Promise<void> {
this.page.keyboard.press('Escape');
await this.page.keyboard.press('Escape');
}
}

0 comments on commit 290b6f1

Please sign in to comment.