From 111dbb33a90a969172bad1337b108c2cec273909 Mon Sep 17 00:00:00 2001 From: Nalem7 <61624650+nabim777@users.noreply.github.com> Date: Tue, 21 Nov 2023 12:18:23 +0545 Subject: [PATCH] add test for unlocking project space file (#7698) --- .../features/apiLocks/unlockFiles.feature | 22 ++++++++++++ .../bootstrap/WebDavLockingContext.php | 36 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 tests/acceptance/features/apiLocks/unlockFiles.feature diff --git a/tests/acceptance/features/apiLocks/unlockFiles.feature b/tests/acceptance/features/apiLocks/unlockFiles.feature new file mode 100644 index 0000000000..8f5ac2c5c1 --- /dev/null +++ b/tests/acceptance/features/apiLocks/unlockFiles.feature @@ -0,0 +1,22 @@ +Feature: unlock locked items + As a user + I want to unlock the resources previously locked by myself + So that other users can make changes to the resources + + Background: + Given user "Alice" has been created with default attributes and without skeleton files + + @issue-7696 + Scenario Outline: unlock a locked file in project space + Given using spaces DAV path + And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API + And user "Alice" has created a space "project-space" with the default quota using the Graph API + And user "Alice" has uploaded a file inside space "project-space" with content "some data" to "textfile.txt" + And user "Alice" has locked file "textfile.txt" inside space "project-space" setting the following properties + | lockscope | | + When user "Alice" unlocks the last created lock of file "textfile.txt" inside space "project-space" using the WebDAV API + Then the HTTP status code should be "204" + Examples: + | lock-scope | + | shared | + | exclusive | diff --git a/tests/acceptance/features/bootstrap/WebDavLockingContext.php b/tests/acceptance/features/bootstrap/WebDavLockingContext.php index c734058ea1..045b936caf 100644 --- a/tests/acceptance/features/bootstrap/WebDavLockingContext.php +++ b/tests/acceptance/features/bootstrap/WebDavLockingContext.php @@ -237,6 +237,22 @@ class WebDavLockingContext implements Context { $this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response); } + /** + * @Given user :user has locked file :file inside space :spaceName setting the following properties + * + * @param string $user + * @param string $file + * @param string $spaceName + * @param TableNode $properties table with no heading with | property | value | + * + * @return void + */ + public function userHasLockedFileInsideSpaceSettingTheFollowingProperties(string $user, string $file, string $spaceName, TableNode $properties) { + $this->spacesContext->setSpaceIDByName($this->featureContext->getActualUsername($user), $spaceName); + $response = $this->lockFile($user, $file, $properties); + $this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response); + } + /** * @Given user :user has locked file :file using file-id path :path setting the following properties * @@ -355,6 +371,26 @@ class WebDavLockingContext implements Context { $this->featureContext->setResponse($response); } + /** + * @When user :user unlocks the last created lock of file :file inside space :spaceName using the WebDAV API + * + * @param string $user + * @param string $spaceName + * @param string $file + * + * @return void + */ + public function userUnlocksTheLastCreatedLockOfFileInsideSpaceUsingTheWebdavApi(string $user, string $spaceName, string $file) { + $this->spacesContext->setSpaceIDByName($this->featureContext->getActualUsername($user), $spaceName); + $response = $this->unlockItemWithLastLockOfUserAndItemUsingWebDavAPI( + $user, + $file, + $user, + $file + ); + $this->featureContext->setResponse($response); + } + /** * @When user :user unlocks file :itemToUnlock with the last created lock of file :itemToUseLockOf using the WebDAV API *