From 46301da7faafa94e94b40fd5cd3f33cbca4d1ed6 Mon Sep 17 00:00:00 2001 From: Kiran Parajuli Date: Fri, 13 Mar 2020 12:14:53 +0545 Subject: [PATCH] More Refactors and added jsDoc --- .../FilesPageElement/publicLinksDialog.js | 2 +- .../FilesPageElement/sharingDialog.js | 31 +++++++++++++------ .../stepDefinitions/publicLinkContext.js | 2 +- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/tests/acceptance/pageObjects/FilesPageElement/publicLinksDialog.js b/tests/acceptance/pageObjects/FilesPageElement/publicLinksDialog.js index fab2f3bc2b2..69b212b8f50 100644 --- a/tests/acceptance/pageObjects/FilesPageElement/publicLinksDialog.js +++ b/tests/acceptance/pageObjects/FilesPageElement/publicLinksDialog.js @@ -84,7 +84,7 @@ module.exports = { return this.api.page .FilesPageElement .sharingDialog() - .openExpiryDateCalender() + .openExpirationDatePicker() .setExpirationDate(value, 'link') } }, diff --git a/tests/acceptance/pageObjects/FilesPageElement/sharingDialog.js b/tests/acceptance/pageObjects/FilesPageElement/sharingDialog.js index 26d5d1b5d2f..6a46207702e 100644 --- a/tests/acceptance/pageObjects/FilesPageElement/sharingDialog.js +++ b/tests/acceptance/pageObjects/FilesPageElement/sharingDialog.js @@ -1,13 +1,14 @@ const util = require('util') const _ = require('lodash') -const sharingHelper = require('../../helpers/sharingHelper') const { client } = require('nightwatch-api') +const sharingHelper = require('../../helpers/sharingHelper') const collaboratorDialog = client.page.FilesPageElement.SharingDialog.collaboratorsDialog() const SHARE_TYPE_STRING = { user: 'user', group: 'group', federation: 'remote' } +const COLLABORATOR_PERMISSION_ARRAY = sharingHelper.COLLABORATOR_PERMISSION_ARRAY module.exports = { commands: { @@ -139,9 +140,7 @@ module.exports = { * * @return void */ - shareWithUserOrGroup: async function ( - sharee, shareWithGroup = false, role, permissions, remote = false, days - ) { + shareWithUserOrGroup: async function (sharee, shareWithGroup = false, role, permissions, remote = false, days) { await collaboratorDialog.clickCreateShare() await this.selectCollaboratorForShare(sharee, shareWithGroup, remote) await this.selectRoleForNewCollaborator(role) @@ -153,7 +152,7 @@ module.exports = { if (days) { const dateToSet = sharingHelper.calculateDate(days) const expectToSucceed = await this - .openExpiryDateCalender() + .openExpirationDatePicker() .setExpirationDate(dateToSet) if (!expectToSucceed) { console.log('WARNING: Cannot create share with disabled expiration date!') @@ -222,10 +221,10 @@ module.exports = { const permissions = {} const panelSelector = this.elements.sharingSidebarRoot.selector let permissionToggle - for (let i = 0; i < sharingHelper.COLLABORATOR_PERMISSION_ARRAY.length; i++) { + for (let i = 0; i < COLLABORATOR_PERMISSION_ARRAY.length; i++) { permissionToggle = panelSelector + util.format( this.elements.permissionCheckbox.selector, - sharingHelper.COLLABORATOR_PERMISSION_ARRAY[i] + COLLABORATOR_PERMISSION_ARRAY[i] ) await this.api.element('xpath', permissionToggle, result => { @@ -233,7 +232,7 @@ module.exports = { return } return this.api.elementIdSelected(result.value.ELEMENT, result => { - permissions[sharingHelper.COLLABORATOR_PERMISSION_ARRAY[i]] = result.value + permissions[COLLABORATOR_PERMISSION_ARRAY[i]] = result.value }) }) } @@ -490,7 +489,7 @@ module.exports = { await collaboratorDialog.clickEditShare(collaborator) const dateToSet = sharingHelper.calculateDate(days) const expectToSucceed = await this - .openExpiryDateCalender() + .openExpirationDatePicker() .setExpirationDate(dateToSet) if (!expectToSucceed) { console.log('WARNING: Cannot create share with disabled expiration date!') @@ -498,13 +497,21 @@ module.exports = { } return this.saveChanges() }, - openExpiryDateCalender: function () { + /** + * opens expiration date field on the webUI + * @return {*} + */ + openExpirationDatePicker: function () { this .initAjaxCounters() .waitForElementVisible('@expirationDateField') .click('@expirationDateField') return client.page.FilesPageElement.expirationDatePicker() }, + /** + * extracts set value in expiration date field + * @return {Promise<*>} + */ getExpirationDateFromInputField: async function () { let expirationDate await this @@ -514,6 +521,10 @@ module.exports = { }) return expirationDate }, + /** + * gets disabled status of save share button + * @return {Promise<*>} + */ getDisabledAttributeOfSaveShareButton: async function () { let disabled await this diff --git a/tests/acceptance/stepDefinitions/publicLinkContext.js b/tests/acceptance/stepDefinitions/publicLinkContext.js index 235c5cdfad7..1eb1492d1ca 100644 --- a/tests/acceptance/stepDefinitions/publicLinkContext.js +++ b/tests/acceptance/stepDefinitions/publicLinkContext.js @@ -138,7 +138,7 @@ When('the user tries to edit expiration of the public link named {string} of fil const dateToSet = new Date(Date.parse(value)) const isDisabled = await api .sharingDialog() - .openExpiryDateCalender() + .openExpirationDatePicker() .isExpiryDateDisabled(dateToSet) return assert.ok( isDisabled,