From e8e353fd48c6f73c7ce66c75c7c48ebcf77951b0 Mon Sep 17 00:00:00 2001 From: Adina Parpalita Date: Tue, 22 Oct 2019 16:54:02 +0300 Subject: [PATCH] some more fixes --- e2e/suites/actions/share-file.test.ts | 12 ++++++------ e2e/suites/viewer/viewer-actions.test.ts | 3 +-- .../repo-client/apis/favorites/favorites-api.ts | 9 +++++---- .../repo-client/apis/nodes/nodes-api.ts | 2 +- .../repo-client/apis/queries/queries-api.ts | 8 +++++--- e2e/utilities/repo-client/apis/repo-api.ts | 16 ++++++++++++---- .../repo-client/apis/search/search-api.ts | 10 ++++++---- .../apis/shared-links/shared-links-api.ts | 3 ++- .../repo-client/apis/sites/sites-api.ts | 3 ++- .../repo-client/apis/trashcan/trashcan-api.ts | 3 ++- 10 files changed, 42 insertions(+), 27 deletions(-) diff --git a/e2e/suites/actions/share-file.test.ts b/e2e/suites/actions/share-file.test.ts index 46c765275..4f3522d55 100755 --- a/e2e/suites/actions/share-file.test.ts +++ b/e2e/suites/actions/share-file.test.ts @@ -250,7 +250,7 @@ describe('Share a file', () => { expect(await shareDialog.getExpireDate()).toBe('', 'Expire date input is not empty'); await shareDialog.clickClose(); - expect(await apis.user.nodes.getSharedExpiryDate(file7Id)).toBe(undefined, `${file7} link still has expiration`); + expect(await apis.user.nodes.getSharedExpiryDate(file7Id)).toBe('', `${file7} link still has expiration`); }); it('Shared file URL is not changed when Share dialog is closed and opened again - [C286335]', async () => { @@ -430,7 +430,7 @@ describe('Share a file', () => { expect(await shareDialog.getExpireDate()).toBe('', 'Expire date input is not empty'); await shareDialog.clickClose(); - expect(await apis.user.nodes.getSharedExpiryDate(file7Id)).toBe(undefined, `${file7} link still has expiration`); + expect(await apis.user.nodes.getSharedExpiryDate(file7Id)).toBe('', `${file7} link still has expiration`); }); it('Shared file URL is not changed when Share dialog is closed and opened again - [C286646]', async () => { @@ -607,7 +607,7 @@ describe('Share a file', () => { expect(await shareDialog.getExpireDate()).toBe('', 'Expire date input is not empty'); await shareDialog.clickClose(); - expect(await apis.user.nodes.getSharedExpiryDate(file7Id)).toBe(undefined, `${file7} link still has expiration`); + expect(await apis.user.nodes.getSharedExpiryDate(file7Id)).toBe('', `${file7} link still has expiration`); }); it('Shared file URL is not changed when Share dialog is closed and opened again - [C286664]', async () => { @@ -753,7 +753,7 @@ describe('Share a file', () => { expect(await shareDialog.getExpireDate()).toBe('', 'Expire date input is not empty'); await shareDialog.clickClose(); - expect(await apis.user.nodes.getSharedExpiryDate(file5Id)).toBe(undefined, `${file5} link still has expiration`); + expect(await apis.user.nodes.getSharedExpiryDate(file5Id)).toBe('', `${file5} link still has expiration`); }); it('Shared file URL is not changed when Share dialog is closed and opened again - [C286655]', async () => { @@ -946,7 +946,7 @@ describe('Share a file', () => { expect(await shareDialog.getExpireDate()).toBe('', 'Expire date input is not empty'); await shareDialog.clickClose(); - expect(await apis.user.nodes.getSharedExpiryDate(file7Id)).toBe(undefined, `${file7} link still has expiration`); + expect(await apis.user.nodes.getSharedExpiryDate(file7Id)).toBe('', `${file7} link still has expiration`); }); it('Shared file URL is not changed when Share dialog is closed and opened again - [C286673]', async () => { @@ -1082,7 +1082,7 @@ describe('Share a file', () => { expect(await shareDialog.getExpireDate()).toBe('', 'Expire date input is not empty'); await shareDialog.clickClose(); - expect(await apis.user.nodes.getSharedExpiryDate(file7Id)).toBe(undefined, `${file7} link still has expiration`); + expect(await apis.user.nodes.getSharedExpiryDate(file7Id)).toBe('', `${file7} link still has expiration`); }); it('Share a file from the context menu - [C306981]', async () => { diff --git a/e2e/suites/viewer/viewer-actions.test.ts b/e2e/suites/viewer/viewer-actions.test.ts index 11777415f..7f79e6b80 100755 --- a/e2e/suites/viewer/viewer-actions.test.ts +++ b/e2e/suites/viewer/viewer-actions.test.ts @@ -687,7 +687,7 @@ describe('Viewer actions', () => { expect(await Utils.fileExistsOnOS(docxSharedFiles)).toBe(true, 'File not found in download location'); }); - it('Copy action - [C286377]', async (done) => { + it('Copy action - [C286377]', async () => { await dataTable.doubleClickOnRowByName(docxSharedFiles); expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); @@ -704,7 +704,6 @@ describe('Viewer actions', () => { expect(await dataTable.isItemPresent(docxSharedFiles)).toBe(true, 'Item is not present in destination'); await apis.user.nodes.deleteNodeChildren(destinationId); - done(); }); it('Move action - [C286378]', async () => { diff --git a/e2e/utilities/repo-client/apis/favorites/favorites-api.ts b/e2e/utilities/repo-client/apis/favorites/favorites-api.ts index 645d4f94a..71b41b3b5 100755 --- a/e2e/utilities/repo-client/apis/favorites/favorites-api.ts +++ b/e2e/utilities/repo-client/apis/favorites/favorites-api.ts @@ -116,8 +116,8 @@ export class FavoritesApi extends RepoApi { } } - async isFavoriteWithRetry(nodeId: string, data) { - let isFavorite; + async isFavoriteWithRetry(nodeId: string, data: { expect: boolean }) { + let isFavorite: boolean; try { const favorite = async () => { isFavorite = await this.isFavorite(nodeId); @@ -129,7 +129,7 @@ export class FavoritesApi extends RepoApi { }; return await Utils.retryCall(favorite); } catch (error) { - this.handleError(`${this.constructor.name} ${this.isFavoriteWithRetry.name}`, error); + // this.handleError(`${this.constructor.name} ${this.isFavoriteWithRetry.name}`, error); } return isFavorite; } @@ -166,7 +166,8 @@ export class FavoritesApi extends RepoApi { }; return await Utils.retryCall(favoriteFiles); } catch (error) { - this.handleError(`${this.constructor.name} ${this.waitForApi.name}`, error); + console.log(`${this.constructor.name} ${this.waitForApi.name} catch: `); + console.log(`\tExpected: ${data.expect} items, but found ${error}`); } } } diff --git a/e2e/utilities/repo-client/apis/nodes/nodes-api.ts b/e2e/utilities/repo-client/apis/nodes/nodes-api.ts index 8db1c871a..6f8c406d4 100755 --- a/e2e/utilities/repo-client/apis/nodes/nodes-api.ts +++ b/e2e/utilities/repo-client/apis/nodes/nodes-api.ts @@ -415,7 +415,7 @@ export class NodesApi extends RepoApi { return Promise.resolve(isLocked); } } - await Utils.retryCall(locked, data.retry); + return await Utils.retryCall(locked, data.retry); } catch (error) { this.handleError(`${this.constructor.name} ${this.isFileLockedWriteWithRetry.name}`, error); } diff --git a/e2e/utilities/repo-client/apis/queries/queries-api.ts b/e2e/utilities/repo-client/apis/queries/queries-api.ts index 6ff8a1ad0..e1641701f 100755 --- a/e2e/utilities/repo-client/apis/queries/queries-api.ts +++ b/e2e/utilities/repo-client/apis/queries/queries-api.ts @@ -77,11 +77,12 @@ export class QueriesApi extends RepoApi { return await Utils.retryCall(sites); } catch (error) { - this.handleError(`${this.constructor.name} ${this.waitForSites.name}`, error); + console.log(`${this.constructor.name} ${this.waitForSites.name} catch: `); + console.log(`\tExpected: ${data.expect} items, but found ${error}`); } } - async waitForFilesAndFolders(searchTerm: string, data: any) { + async waitForFilesAndFolders(searchTerm: string, data: { expect: number }) { try { const nodes = async () => { const totalItems = (await this.findNodes(searchTerm)).list.pagination.totalItems; @@ -94,7 +95,8 @@ export class QueriesApi extends RepoApi { return await Utils.retryCall(nodes); } catch (error) { - this.handleError(`${this.constructor.name} ${this.waitForFilesAndFolders.name}`, error); + console.log(`${this.constructor.name} ${this.waitForFilesAndFolders.name} catch: `); + console.log(`\tExpected: ${data.expect} items, but found ${error}`); } } } diff --git a/e2e/utilities/repo-client/apis/repo-api.ts b/e2e/utilities/repo-client/apis/repo-api.ts index d66e0ad74..f1fb9c3a1 100644 --- a/e2e/utilities/repo-client/apis/repo-api.ts +++ b/e2e/utilities/repo-client/apis/repo-api.ts @@ -50,10 +50,18 @@ export abstract class RepoApi { protected handleError(message: string, response: any) { console.log(`\n--- ${message} error :`); - console.log('\t>>> Status: ', response.status); - console.log('\t>>> Text: ', response.response.text); - console.log('\t>>> Method: ', response.response.error.method); - console.log('\t>>> Path: ', response.response.error.path); + if ( response.status ) { + try { + console.log('\t>>> Status: ', response.status); + console.log('\t>>> Text: ', response.response.text); + console.log('\t>>> Method: ', response.response.error.method); + console.log('\t>>> Path: ', response.response.error.path); + } catch { + console.log('\t>>> ', response); + } + } + else console.log('\t>>> ', response); + } } diff --git a/e2e/utilities/repo-client/apis/search/search-api.ts b/e2e/utilities/repo-client/apis/search/search-api.ts index 3ce50123d..b2cf7c2ac 100755 --- a/e2e/utilities/repo-client/apis/search/search-api.ts +++ b/e2e/utilities/repo-client/apis/search/search-api.ts @@ -96,7 +96,7 @@ export class SearchApi extends RepoApi { } } - async waitForApi(username, data) { + async waitForApi(username: string, data: { expect: number }) { try { const recentFiles = async () => { const totalItems = (await this.queryRecentFiles(username)).list.pagination.totalItems; @@ -109,11 +109,12 @@ export class SearchApi extends RepoApi { return await Utils.retryCall(recentFiles); } catch (error) { - this.handleError(`${this.constructor.name} ${this.waitForApi.name}`, error); + console.log(`${this.constructor.name} ${this.waitForApi.name} catch: `); + console.log(`\tExpected: ${data.expect} items, but found ${error}`); } } - async waitForNodes(searchTerm: string, data) { + async waitForNodes(searchTerm: string, data: { expect: number }) { try { const nodes = async () => { const totalItems = (await this.queryNodesNames(searchTerm)).list.pagination.totalItems; @@ -126,7 +127,8 @@ export class SearchApi extends RepoApi { return await Utils.retryCall(nodes); } catch (error) { - this.handleError(`${this.constructor.name} ${this.waitForNodes.name}`, error); + console.log(`${this.constructor.name} ${this.waitForNodes.name} catch: `); + console.log(`\tExpected: ${data.expect} items, but found ${error}`); } } } diff --git a/e2e/utilities/repo-client/apis/shared-links/shared-links-api.ts b/e2e/utilities/repo-client/apis/shared-links/shared-links-api.ts index 06f7f78da..b43cc2a4b 100755 --- a/e2e/utilities/repo-client/apis/shared-links/shared-links-api.ts +++ b/e2e/utilities/repo-client/apis/shared-links/shared-links-api.ts @@ -102,7 +102,8 @@ export class SharedLinksApi extends RepoApi { return await Utils.retryCall(sharedFiles); } catch (error) { - this.handleError(`${this.constructor.name} ${this.waitForApi.name}`, error); + console.log(`${this.constructor.name} ${this.waitForApi.name} catch: `); + console.log(`\tExpected: ${data.expect} items, but found ${error}`); } } } diff --git a/e2e/utilities/repo-client/apis/sites/sites-api.ts b/e2e/utilities/repo-client/apis/sites/sites-api.ts index b0cae8221..cfff6c340 100755 --- a/e2e/utilities/repo-client/apis/sites/sites-api.ts +++ b/e2e/utilities/repo-client/apis/sites/sites-api.ts @@ -233,7 +233,8 @@ export class SitesApi extends RepoApi { return await Utils.retryCall(sites); } catch (error) { - this.handleError(`${this.constructor.name} ${this.waitForApi.name}`, error); + console.log(`${this.constructor.name} ${this.waitForApi.name} catch: `); + console.log(`\tExpected: ${data.expect} items, but found ${error}`); } } } diff --git a/e2e/utilities/repo-client/apis/trashcan/trashcan-api.ts b/e2e/utilities/repo-client/apis/trashcan/trashcan-api.ts index e12619a7b..cabace88f 100644 --- a/e2e/utilities/repo-client/apis/trashcan/trashcan-api.ts +++ b/e2e/utilities/repo-client/apis/trashcan/trashcan-api.ts @@ -92,7 +92,8 @@ export class TrashcanApi extends RepoApi { return await Utils.retryCall(deletedFiles); } catch (error) { - this.handleError(`${this.constructor.name} ${this.waitForApi.name}`, error); + console.log(`${this.constructor.name} ${this.waitForApi.name} catch: `); + console.log(`\tExpected: ${data.expect} items, but found ${error}`); } } }