Skip to content

Commit

Permalink
Sonarcloud issues fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalKinas committed Oct 27, 2023
1 parent 3d6ec4b commit 421bf24
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 59 deletions.
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
Expand Down
2 changes: 1 addition & 1 deletion docs/ja/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html>
<html lang="ja">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
Expand Down
24 changes: 12 additions & 12 deletions e2e/protractor/suites/actions/copy-move/copy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ describe('Copy content', () => {

async function copyFile(fileName: string, location: string = '', destination: string, doBefore?: () => void) {
if (doBefore) {
await doBefore();
doBefore();
}
await dataTable.selectItem(fileName, location);
await toolbar.clickMoreActionsCopy();
Expand All @@ -269,7 +269,7 @@ describe('Copy content', () => {

async function copyFolderWithContent(folderName: string, location: string = '', destination: string, doBefore?: () => void) {
if (doBefore) {
await doBefore();
doBefore();
}
await dataTable.selectItem(folderName, location);
await toolbar.clickMoreActionsCopy();
Expand All @@ -294,7 +294,7 @@ describe('Copy content', () => {

async function copyMultipleItems(items: string[], location: string = '', destination: string, doBefore?: () => void) {
if (doBefore) {
await doBefore();
doBefore();
}
await dataTable.selectMultipleItems(items, location);
await toolbar.clickMoreActionsCopy();
Expand All @@ -317,7 +317,7 @@ describe('Copy content', () => {

async function copyFileWithNameThatAlreadyExists(fileName: string, location: string = '', destination: string, doBefore?: () => void) {
if (doBefore) {
await doBefore();
doBefore();
}
await dataTable.selectItem(fileName, location);
await toolbar.clickMoreActionsCopy();
Expand All @@ -338,7 +338,7 @@ describe('Copy content', () => {

async function copyFolderWithNameThatAlreadyExists(folderName: string, location: string = '', destination: string, doBefore?: () => void) {
if (doBefore) {
await doBefore();
doBefore();
}
await dataTable.selectItem(folderName, location);
await toolbar.clickMoreActionsCopy();
Expand All @@ -362,7 +362,7 @@ describe('Copy content', () => {

async function copyItemsIntoLibrary(items: string[], location: string = '', destination: string, doBefore?: () => void) {
if (doBefore) {
await doBefore();
doBefore();
}
const noOfItems = items.length;
await dataTable.selectMultipleItems(items, location);
Expand Down Expand Up @@ -393,7 +393,7 @@ describe('Copy content', () => {

async function copyLockedFile(fileName: string, location: string = '', destination: string, doBefore?: () => void) {
if (doBefore) {
await doBefore();
doBefore();
}

await dataTable.selectItem(fileName, location);
Expand All @@ -417,7 +417,7 @@ describe('Copy content', () => {

async function copyFolderThatContainsLockedFile(folderName: string, location: string = '', destination: string, doBefore?: () => void) {
if (doBefore) {
await doBefore();
doBefore();
}

await dataTable.selectItem(folderName, location);
Expand Down Expand Up @@ -451,7 +451,7 @@ describe('Copy content', () => {

async function undoCopyFile(fileName: string, location: string = '', destination: string, doBefore?: () => void) {
if (doBefore) {
await doBefore();
doBefore();
}
await dataTable.selectItem(fileName, location);
await toolbar.clickMoreActionsCopy();
Expand All @@ -475,7 +475,7 @@ describe('Copy content', () => {

async function undoCopyFolder(folderName: string, location: string = '', destination: string, doBefore?: () => void) {
if (doBefore) {
await doBefore();
doBefore();
}
await dataTable.selectItem(folderName, location);
await toolbar.clickMoreActionsCopy();
Expand All @@ -497,7 +497,7 @@ describe('Copy content', () => {
expect(await dataTable.isEmpty()).toBe(true, 'Trash is not empty');
}

async function undoCopyFileWithExistingName(fileName: string, location: string = '', destination: string, doBefore?: () => void) {
async function undoCopyFileWithExistingName(fileName: string, location: string = '', destination: string, doBefore?: () => Promise<void>) {
if (doBefore) {
await doBefore();
}
Expand Down Expand Up @@ -527,7 +527,7 @@ describe('Copy content', () => {

async function undoCopyFolderWithExistingName(folderName: string, location: string = '', destination: string, doBefore?: () => void) {
if (doBefore) {
await doBefore();
doBefore();
}

await dataTable.selectItem(folderName, location);
Expand Down
6 changes: 4 additions & 2 deletions e2e/protractor/suites/list-views/file-libraries.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ describe('File Libraries', () => {
const { dataTable } = page;
const adminApiActions = new AdminActions();

const sortAlphabetically = (a: string, b: string) => a.localeCompare(b);

beforeAll(async () => {
try {
await adminApiActions.createUser({ username });
Expand Down Expand Up @@ -146,7 +148,7 @@ describe('File Libraries', () => {
it('[C217098] Site ID is displayed when two sites have the same name', async () => {
const expectedSites = [`${siteName} (${siteId1})`, `${siteName} (${siteId2})`];
const actualSites = await dataTable.getCellsContainingName(siteName);
expect(actualSites.sort()).toEqual(expectedSites.sort());
expect(actualSites.sort(sortAlphabetically)).toEqual(expectedSites.sort(sortAlphabetically));
});

it('[C217096] Tooltip for sites without description', async () => {
Expand Down Expand Up @@ -211,7 +213,7 @@ describe('File Libraries', () => {
it('[C289896] Site ID is displayed when two sites have the same name', async () => {
const expectedSites = [`${siteName} (${siteId1})`, `${siteName} (${siteId2})`];
const actualSites = await dataTable.getCellsContainingName(siteName);
expect(actualSites.sort()).toEqual(expectedSites.sort());
expect(actualSites.sort(sortAlphabetically)).toEqual(expectedSites.sort(sortAlphabetically));
});

it('[C289894] Tooltip for sites without description', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ describe('NodeActionsService', () => {
reject(permissionError);
} else {
const node = familyNodes.filter((familyNode) => familyNode.parentNodeId === parentId);
resolve({ list: { entries: node[0].nodeChildren } } || emptyChildrenList);
resolve(node.length > 0 ? { list: { entries: node[0].nodeChildren } } : emptyChildrenList);
}
})
};
Expand Down
11 changes: 5 additions & 6 deletions projects/aca-playwright-shared/src/api/nodes-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,11 @@ export class NodesApi {
}

private async getDataDictionaryId(): Promise<string> {
try {
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
18 changes: 6 additions & 12 deletions projects/aca-testing-shared/src/utilities/admin-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,10 @@ export class AdminActions extends UserActions {
}

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

async getNodeTemplatesFolderId(): Promise<string> {
Expand Down Expand Up @@ -106,19 +104,15 @@ export class AdminActions extends UserActions {
}

async createNodeTemplatesHierarchy(hierarchy: NodeContentTree): Promise<any> {
try {
return this.nodes.createContent(hierarchy, `Data Dictionary/Node Templates`);
} catch (error) {
return this.nodes.createContent(hierarchy, `Data Dictionary/Node Templates`).catch((error) => {
super.handleError('Admin Actions - createNodeTemplatesHierarchy failed : ', error);
}
});
}

async createSpaceTemplatesHierarchy(hierarchy: NodeContentTree): Promise<any> {
try {
return this.nodes.createContent(hierarchy, `Data Dictionary/Space Templates`);
} catch (error) {
return this.nodes.createContent(hierarchy, `Data Dictionary/Space Templates`).catch((error) => {
super.handleError('Admin Actions - createSpaceTemplatesHierarchy failed : ', error);
}
});
}

async removeUserAccessOnNodeTemplate(nodeName: string): Promise<NodeEntry> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,20 @@ export class SharedLinksApi extends RepoApi {
}

async waitForFilesToBeShared(filesIds: string[]): Promise<any> {
try {
const sharedFile = async () => {
const sharedFiles = (await this.getSharedLinks()).list.entries.map((link) => link.entry.nodeId);
const foundItems = filesIds.every((id) => sharedFiles.includes(id));
if (foundItems) {
return Promise.resolve(foundItems);
} else {
return Promise.reject(foundItems);
}
};
const sharedFile = async () => {
const sharedFiles = (await this.getSharedLinks()).list.entries.map((link) => link.entry.nodeId);
const foundItems = filesIds.every((id) => sharedFiles.includes(id));
if (foundItems) {
return Promise.resolve(foundItems);
} else {
return Promise.reject(foundItems);
}
};

return Utils.retryCall(sharedFile);
} catch (error) {
return Utils.retryCall(sharedFile).catch((error) => {
Logger.error(`SharedLinksApi waitForFilesToBeShared : catch : ${error}`);
Logger.error(`\tWait timeout reached waiting for files to be shared`);
}
});
}

async waitForFilesToNotBeShared(filesIds: string[]): Promise<any> {
Expand Down
20 changes: 9 additions & 11 deletions projects/aca-testing-shared/src/utilities/user-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,20 +142,18 @@ export class UserActions {
* @param expectedSize Size of the trashcan to wait for.
*/
async waitForTrashcanSize(expectedSize: number): Promise<number> {
try {
return Utils.retryCall(async () => {
const totalItems = await this.getTrashcanSize();
return Utils.retryCall(async () => {
const totalItems = await this.getTrashcanSize();

if (totalItems !== expectedSize) {
return Promise.reject(totalItems);
} else {
return Promise.resolve(totalItems);
}
});
} catch (error) {
if (totalItems !== expectedSize) {
return Promise.reject(totalItems);
} else {
return Promise.resolve(totalItems);
}
}).catch((error) => {
this.handleError('User Actions - waitForTrashcanSize failed : ', error);
return -1;
}
});
}

async lockNodes(nodeIds: string[], lockType: string = 'ALLOW_OWNER_CHANGES') {
Expand Down

0 comments on commit 421bf24

Please sign in to comment.