diff --git a/tests/acceptance/pageObjects/FilesPageElement/expirationDatePicker.js b/tests/acceptance/pageObjects/FilesPageElement/expirationDatePicker.js index fe35bdf8959..2962405564a 100644 --- a/tests/acceptance/pageObjects/FilesPageElement/expirationDatePicker.js +++ b/tests/acceptance/pageObjects/FilesPageElement/expirationDatePicker.js @@ -1,4 +1,5 @@ const util = require('util') +const sharingHelper = require('../../helpers/sharingHelper') module.exports = { commands: { @@ -144,6 +145,30 @@ module.exports = { } }) return disabled + }, + /** + * sets expiration date on collaborators/public-link shares + * + * @param {string} value - provided date in format YYYY-MM-DD, or empty string to unset date + * @returns {Promise} + */ + setExpirationDate: async function (value) { + if (value === '') { + return this.click('@publicLinkDeleteExpirationDateButton') + } + value = sharingHelper.calculateDate(value) + const dateToSet = new Date(Date.parse(value)) + const year = dateToSet.getFullYear() + const month = dateToSet.toLocaleString('en-GB', { month: 'long' }) + const day = dateToSet.getDate() + await this + .initAjaxCounters() + .waitForElementVisible('@linkExpirationDateField') + .click('@linkExpirationDateField') + return this + .setExpiryDateYear(year) + .setExpiryDateMonth(month) + .setExpiryDateDay(day) } }, elements: { @@ -171,6 +196,9 @@ module.exports = { }, linkExpirationDateField: { selector: '.vdatetime-input' + }, + publicLinkDeleteExpirationDateButton: { + selector: '#oc-files-file-link-expire-date-delete' } } } diff --git a/tests/acceptance/pageObjects/FilesPageElement/publicLinksDialog.js b/tests/acceptance/pageObjects/FilesPageElement/publicLinksDialog.js index 3ad1382986c..19aa6af3224 100644 --- a/tests/acceptance/pageObjects/FilesPageElement/publicLinksDialog.js +++ b/tests/acceptance/pageObjects/FilesPageElement/publicLinksDialog.js @@ -1,6 +1,5 @@ const util = require('util') const _ = require('lodash') -const sharingHelper = require('../../helpers/sharingHelper') module.exports = { commands: { @@ -65,32 +64,6 @@ module.exports = { .clearValue('@publicLinkPasswordField') .setValue('@publicLinkPasswordField', linkPassword) }, - /** - * sets expire date of the public link share using webUI - * - * @param {string} value - provided date in format YYYY-MM-DD, or empty string to unset date - * @returns {Promise} - */ - setPublicLinkExpiryDate: async function (value) { - const expirationDatePicker = this.api.page.FilesPageElement.expirationDatePicker() - if (value === '') { - return this.click('@publicLinkDeleteExpirationDateButton') - } - value = sharingHelper.calculateDate(value) - const dateToSet = new Date(Date.parse(value)) - const year = dateToSet.getFullYear() - const month = dateToSet.toLocaleString('en-GB', { month: 'long' }) - const day = dateToSet.getDate() - const linkExpirationDateField = expirationDatePicker.elements.linkExpirationDateField.selector - await this - .initAjaxCounters() - .waitForElementVisible(linkExpirationDateField) - .click(linkExpirationDateField) - return expirationDatePicker - .setExpiryDateYear(year) - .setExpiryDateMonth(month) - .setExpiryDateDay(day) - }, /** * function sets different fields for public link * @@ -106,7 +79,7 @@ module.exports = { } else if (key === 'password') { return this.setPublicLinkPassword(value) } else if (key === 'expireDate') { - return this.setPublicLinkExpiryDate(value) + return this.setExpirationDate(value) } return this }, @@ -430,9 +403,6 @@ module.exports = { }, sidebarPrivateLinkIconCopied: { selector: '#files-sidebar-private-link-icon-copied' - }, - publicLinkDeleteExpirationDateButton: { - selector: '#oc-files-file-link-expire-date-delete' } } } diff --git a/tests/acceptance/pageObjects/FilesPageElement/sharingDialog.js b/tests/acceptance/pageObjects/FilesPageElement/sharingDialog.js index 95c12a12cb2..246d97ea553 100644 --- a/tests/acceptance/pageObjects/FilesPageElement/sharingDialog.js +++ b/tests/acceptance/pageObjects/FilesPageElement/sharingDialog.js @@ -496,8 +496,8 @@ module.exports = { await collaboratorDialog.clickEditShare(collaborator) await this.api.page .FilesPageElement - .publicLinksDialog() - .setPublicLinkExpiryDate(value) + .expirationDatePicker() + .setExpirationDate(value) return this.saveChanges() } },