From a4042adba2aa5dbdcf6d57f21f33f7fc28bcb187 Mon Sep 17 00:00:00 2001 From: talank Date: Wed, 29 Jul 2020 15:31:19 +0545 Subject: [PATCH] Fixed failing test on public link share --- .../shareByPublicLink.feature | 2 +- .../stepDefinitions/sharingContext.js | 24 +++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/tests/acceptance/features/webUISharingPublic/shareByPublicLink.feature b/tests/acceptance/features/webUISharingPublic/shareByPublicLink.feature index 40d39a05aa6..e2f1585a8e6 100644 --- a/tests/acceptance/features/webUISharingPublic/shareByPublicLink.feature +++ b/tests/acceptance/features/webUISharingPublic/shareByPublicLink.feature @@ -388,7 +388,7 @@ Feature: Share by public link And the public uses the webUI to access the last public link created by user "user1" with password "qwertyui" Then file "lorem.txt" should be listed on the webUI - @skipOnOCIS @skip @issue-3830 + @skipOnOCIS @issue-3830 Scenario: user edits the password of an already existing public link and tries to access with old password Given user "user1" has shared folder "simple-folder" with link with "read, update, create, delete" permissions and password "pass123" And user "user1" has created a public link with following settings diff --git a/tests/acceptance/stepDefinitions/sharingContext.js b/tests/acceptance/stepDefinitions/sharingContext.js index d1e525d009d..50aac2271ec 100644 --- a/tests/acceptance/stepDefinitions/sharingContext.js +++ b/tests/acceptance/stepDefinitions/sharingContext.js @@ -13,6 +13,7 @@ const _ = require('lodash') const path = require('../helpers/path') const util = require('util') const { COLLABORATOR_PERMISSION_ARRAY, calculateDate } = require('../helpers/sharingHelper') +let timeOfLastShareOperation = Date.now() /** * @@ -107,6 +108,23 @@ Given( } ) +/** + * makes sure share operations are carried out maximum once a second to avoid same stime + */ +const waitBetweenShareOperations = async function() { + const timeSinceLastShare = Date.now() - timeOfLastShareOperation + if (timeSinceLastShare <= 1001) { + await client.pause(1001 - timeSinceLastShare) + } +} + +/** + * update time in which the last share operation was carried out + */ +const updateTimeOfLastShareOperation = function() { + timeOfLastShareOperation = Date.now() +} + /** * creates a new share * @@ -120,7 +138,7 @@ Given( * @param {string} extraParams.password Password of the share (public links) * @param {string} extraParams.expireDate Expiry date of the share */ -const shareFileFolder = function( +const shareFileFolder = async function( elementToShare, sharer, receiver = null, @@ -129,6 +147,7 @@ const shareFileFolder = function( name = null, extraParams = {} ) { + await waitBetweenShareOperations() const params = new URLSearchParams() elementToShare = path.resolve(elementToShare) const permissions = sharingHelper.humanReadablePermissionsToBitmask(permissionString) @@ -147,12 +166,13 @@ const shareFileFolder = function( } } const url = 'apps/files_sharing/api/v1/shares' - return httpHelper + await httpHelper .postOCS(url, sharer, params) .then(res => res.json()) .then(function(json) { httpHelper.checkOCSStatus(json, 'Could not create share. Message: ' + json.ocs.meta.message) }) + await updateTimeOfLastShareOperation() } /** * create any share using dataTable