From bc63c2cbd75e69db8085550984a12fee5da90b96 Mon Sep 17 00:00:00 2001 From: Saw-jan Date: Wed, 27 Nov 2024 11:59:10 +0545 Subject: [PATCH] test: merge similar steps --- tests/acceptance/bootstrap/Sharing.php | 55 +++++++------------ tests/acceptance/bootstrap/WebDav.php | 2 +- .../apiSpacesShares/copySpaces.feature | 16 +++--- .../shareSubItemOfSpace.feature | 10 ++-- .../coreApiWebdavProperties/copyFile.feature | 16 +++--- 5 files changed, 41 insertions(+), 58 deletions(-) diff --git a/tests/acceptance/bootstrap/Sharing.php b/tests/acceptance/bootstrap/Sharing.php index 7290f788b3..0191bc8368 100755 --- a/tests/acceptance/bootstrap/Sharing.php +++ b/tests/acceptance/bootstrap/Sharing.php @@ -1858,7 +1858,7 @@ trait Sharing { } /** - * @Then the information about the last share for user :user should include + * @Then as user :user the last share should include the following properties: * * @param string $user * @param TableNode $table @@ -1868,8 +1868,24 @@ trait Sharing { */ public function userGetsTheLastShareSharedWithHimUsingTheSharingApi(string $user, TableNode $table):void { $user = $this->getActualUsername($user); - $shareId = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId(); - $response = $this->getShareData($user, $shareId); + $this->verifyTableNodeRows($table, [], $this->shareResponseFields); + $share_id = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId(); + + $response = $this->getShareData($user, $share_id); + $this->theHTTPStatusCodeShouldBe( + 200, + "Error getting info of last share for user $user", + $response + ); + $this->ocsContext->assertOCSResponseIndicatesSuccess( + __METHOD__ . + ' Error getting info of last share for user $user\n' . + $this->ocsContext->getOCSResponseStatusMessage( + $response + ) . '"', + $response + ); + $this->checkTheFields($user, $table, $response); } @@ -2031,39 +2047,6 @@ trait Sharing { $this->setResponse($this->getAllShares($user, "?path=$path&subfiles=true")); } - /** - * @Then /^the response when user "([^"]*)" gets the info of the last share should include$/ - * - * @param string $user - * @param TableNode|null $body - * - * @return void - * @throws Exception - */ - public function theResponseWhenUserGetsInfoOfLastShareShouldInclude( - string $user, - ?TableNode $body - ):void { - $user = $this->getActualUsername($user); - $this->verifyTableNodeRows($body, [], $this->shareResponseFields); - $share_id = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId(); - $response = $this->getShareData($user, $share_id); - $this->theHTTPStatusCodeShouldBe( - 200, - "Error getting info of last share for user $user", - $response - ); - $this->ocsContext->assertOCSResponseIndicatesSuccess( - __METHOD__ . - ' Error getting info of last share for user $user\n' . - $this->ocsContext->getOCSResponseStatusMessage( - $response - ) . '"', - $response - ); - $this->checkTheFields($user, $body, $response); - } - /** * @Then /^the response when user "([^"]*)" gets the info of the last public link share should include$/ * diff --git a/tests/acceptance/bootstrap/WebDav.php b/tests/acceptance/bootstrap/WebDav.php index e4ca9d87b8..19999d18e6 100644 --- a/tests/acceptance/bootstrap/WebDav.php +++ b/tests/acceptance/bootstrap/WebDav.php @@ -100,7 +100,7 @@ trait WebDav { * @return void */ public function setFilePreviewContent(string $user, string $previewContent): void { - $filePreviews[$user] = $previewContent; + $this->filePreviews[$user] = $previewContent; } /** diff --git a/tests/acceptance/features/apiSpacesShares/copySpaces.feature b/tests/acceptance/features/apiSpacesShares/copySpaces.feature index 30e5f96a96..36baf2b3c4 100644 --- a/tests/acceptance/features/apiSpacesShares/copySpaces.feature +++ b/tests/acceptance/features/apiSpacesShares/copySpaces.feature @@ -760,7 +760,7 @@ Feature: copy file | sample-folder-c | And for user "Brian" folder "BRIAN-FOLDER/second-level-folder/third-level-folder" of the space "Personal" should contain these entries: | sample-folder-c | - And the response when user "Alice" gets the info of the last share should include + And as user "Alice" the last share should include the following properties: | file_target | /Shares/BRIAN-FOLDER | @@ -789,7 +789,7 @@ Feature: copy file | /second-level-folder | And for user "Alice" the content of the file "/BRIAN-FOLDER/second-level-folder" of the space "Shares" should be "sample file-c" And for user "Brian" the content of the file "/BRIAN-FOLDER/second-level-folder" of the space "Personal" should be "sample file-c" - And the response when user "Alice" gets the info of the last share should include + And as user "Alice" the last share should include the following properties: | file_target | /Shares/BRIAN-FOLDER | @@ -817,7 +817,7 @@ Feature: copy file | /textfile-c.txt | And for user "Alice" the content of the file "/BRIAN-FOLDER/second-level-file.txt" of the space "Shares" should be "sample file-c" And for user "Brian" the content of the file "/BRIAN-FOLDER/second-level-file.txt" of the space "Personal" should be "sample file-c" - And the response when user "Alice" gets the info of the last share should include + And as user "Alice" the last share should include the following properties: | file_target | /Shares/BRIAN-FOLDER | @@ -843,7 +843,7 @@ Feature: copy file | third-level-folder | But for user "Alice" folder "BRIAN-FOLDER/second-level-folder" of the space "Shares" should not contain these entries: | second-level-folder | - And the response when user "Alice" gets the info of the last share should include + And as user "Alice" the last share should include the following properties: | file_target | /Shares/BRIAN-FOLDER | @@ -871,7 +871,7 @@ Feature: copy file And as "Alice" folder "/Sample-Folder-A/sample-folder-b/sample-folder-c" should exist And for user "Alice" folder "BRIAN-FOLDER/second-level-folder/third-level-folder" of the space "Shares" should contain these entries: | sample-folder-c | - And the response when user "Alice" gets the info of the last share should include + And as user "Alice" the last share should include the following properties: | file_target | /Shares/BRIAN-FOLDER | @@ -900,7 +900,7 @@ Feature: copy file | third-level-folder | And for user "Alice" the content of the file "/BRIAN-FOLDER/second-level-folder" of the space "Shares" should be "sample file-c" And for user "Brian" the content of the file "/BRIAN-FOLDER/second-level-folder" of the space "Personal" should be "sample file-c" - And the response when user "Alice" gets the info of the last share should include + And as user "Alice" the last share should include the following properties: | file_target | /Shares/BRIAN-FOLDER | @@ -930,7 +930,7 @@ Feature: copy file And as "Alice" file "/Sample-Folder-A/sample-folder-b/textfile-c.txt" should exist And for user "Alice" the content of the file "/BRIAN-FOLDER/second-level-file.txt" of the space "Shares" should be "sample file-c" And for user "Brian" the content of the file "/BRIAN-FOLDER/second-level-file.txt" of the space "Personal" should be "sample file-c" - And the response when user "Alice" gets the info of the last share should include + And as user "Alice" the last share should include the following properties: | file_target | /Shares/BRIAN-FOLDER | @@ -962,7 +962,7 @@ Feature: copy file And as "Alice" folder "FOLDER/second-level-folder/third-level-folder" should exist And for user "Alice" folder "BRIAN-FOLDER" of the space "Shares" should not contain these files: | /second-level-folder/second-level-folder | - And the response when user "Alice" gets the info of the last share should include + And as user "Alice" the last share should include the following properties: | file_target | /Shares/BRIAN-FOLDER | diff --git a/tests/acceptance/features/apiSpacesShares/shareSubItemOfSpace.feature b/tests/acceptance/features/apiSpacesShares/shareSubItemOfSpace.feature index aa0a21c732..93e5605901 100644 --- a/tests/acceptance/features/apiSpacesShares/shareSubItemOfSpace.feature +++ b/tests/acceptance/features/apiSpacesShares/shareSubItemOfSpace.feature @@ -30,7 +30,7 @@ Feature: Share a file or folder that is inside a space And the OCS status code should be "200" And the OCS status message should be "OK" And as "Brian" "Shares/" should exist - And the information about the last share for user "Brian" should include + And as user "Brian" the last share should include the following properties: | expiration | | Examples: | resource | resource-type | space-role | expire-date | expiration | @@ -55,7 +55,7 @@ Feature: Share a file or folder that is inside a space And the OCS status code should be "200" And the OCS status message should be "OK" And as "Bob" "Shares/" should exist - And the information about the last share for user "Brian" should include + And as user "Brian" the last share should include the following properties: | expiration | | Examples: | resource | resource-type | space-role | expire-date | expiration | @@ -118,7 +118,7 @@ Feature: Share a file or folder that is inside a space And the OCS status code should be "200" And the OCS status message should be "OK" And as "Brian" folder "Shares/folder" should exist - And the information about the last share for user "Brian" should include + And as user "Brian" the last share should include the following properties: | expiration | 2042-01-01 | @@ -135,7 +135,7 @@ Feature: Share a file or folder that is inside a space | expireDate | 2044-01-01T23:59:59.999+01:00 | | role | viewer | Then the HTTP status code should be "200" - And the information about the last share for user "Brian" should include + And as user "Brian" the last share should include the following properties: | expiration | 2044-01-01 | @@ -152,7 +152,7 @@ Feature: Share a file or folder that is inside a space | expireDate | | | role | viewer | Then the HTTP status code should be "200" - And the information about the last share for user "Brian" should include + And as user "Brian" the last share should include the following properties: | expiration | | @issue-8747 diff --git a/tests/acceptance/features/coreApiWebdavProperties/copyFile.feature b/tests/acceptance/features/coreApiWebdavProperties/copyFile.feature index 9ff25cedba..952b463859 100644 --- a/tests/acceptance/features/coreApiWebdavProperties/copyFile.feature +++ b/tests/acceptance/features/coreApiWebdavProperties/copyFile.feature @@ -338,7 +338,7 @@ Feature: copy file Then the HTTP status code should be "204" And as "Alice" folder "/Sample-Folder-A/sample-folder-b/sample-folder-c" should exist And as "Alice" folder "/Shares/BRIAN-FOLDER/second-level-folder/third-level-folder/sample-folder-c" should exist - And the response when user "Alice" gets the info of the last share should include + And as user "Alice" the last share should include the following properties: | file_target | /Shares/BRIAN-FOLDER | Examples: | dav-path-version | @@ -370,7 +370,7 @@ Feature: copy file And as "Alice" file "Sample-Folder-A/sample-folder-b/textfile-c.txt" should exist And as "Alice" file "Shares/BRIAN-FOLDER/second-level-folder" should exist And the content of file "Shares/BRIAN-FOLDER/second-level-folder" for user "Alice" should be "sample file-c" - And the response when user "Alice" gets the info of the last share should include + And as user "Alice" the last share should include the following properties: | file_target | /Shares/BRIAN-FOLDER | Examples: | dav-path-version | @@ -401,7 +401,7 @@ Feature: copy file And as "Alice" file "Shares/BRIAN-FOLDER/second-level-file.txt" should exist And as "Alice" file "Shares/BRIAN-FOLDER/textfile-c.txt" should not exist And the content of file "Shares/BRIAN-FOLDER/second-level-file.txt" for user "Alice" should be "sample file-c" - And the response when user "Alice" gets the info of the last share should include + And as user "Alice" the last share should include the following properties: | file_target | /Shares/BRIAN-FOLDER | Examples: | dav-path-version | @@ -432,7 +432,7 @@ Feature: copy file And as "Alice" folder "FOLDER/second-level-folder/third-level-folder" should exist And as "Alice" folder "Shares/BRIAN-FOLDER/second-level-folder/third-level-file.txt/third-level-folder" should exist And as "Alice" folder "Shares/BRIAN-FOLDER/second-level-folder/second-level-folder" should not exist - And the response when user "Alice" gets the info of the last share should include + And as user "Alice" the last share should include the following properties: | file_target | /Shares/BRIAN-FOLDER | Examples: | dav-path-version | @@ -521,7 +521,7 @@ Feature: copy file Then the HTTP status code should be "204" And as "Alice" folder "/Sample-Folder-A/sample-folder-b/sample-folder-c" should exist And as "Alice" folder "/Shares/BRIAN-FOLDER/second-level-folder/third-level-folder/sample-folder-c" should exist - And the response when user "Alice" gets the info of the last share should include + And as user "Alice" the last share should include the following properties: | file_target | /Shares/BRIAN-FOLDER | Examples: | dav-path-version | @@ -556,7 +556,7 @@ Feature: copy file And as "Alice" file "Sample-Folder-A/sample-folder-b/textfile-c.txt" should exist And as "Alice" file "Shares/BRIAN-FOLDER/second-level-folder" should exist And the content of file "Shares/BRIAN-FOLDER/second-level-folder" for user "Alice" should be "sample file-c" - And the response when user "Alice" gets the info of the last share should include + And as user "Alice" the last share should include the following properties: | file_target | /Shares/BRIAN-FOLDER | Examples: | dav-path-version | @@ -590,7 +590,7 @@ Feature: copy file And as "Alice" file "Shares/BRIAN-FOLDER/second-level-file.txt" should exist And as "Alice" file "Shares/BRIAN-FOLDER/textfile-c.txt" should not exist And the content of file "Shares/BRIAN-FOLDER/second-level-file.txt" for user "Alice" should be "sample file-c" - And the response when user "Alice" gets the info of the last share should include + And as user "Alice" the last share should include the following properties: | file_target | /Shares/BRIAN-FOLDER | Examples: | dav-path-version | @@ -624,7 +624,7 @@ Feature: copy file And as "Alice" folder "FOLDER/second-level-folder/third-level-folder" should exist And as "Alice" folder "Shares/BRIAN-FOLDER/second-level-folder/third-level-file.txt/third-level-folder" should exist And as "Alice" folder "Shares/BRIAN-FOLDER/second-level-folder/second-level-folder" should not exist - And the response when user "Alice" gets the info of the last share should include + And as user "Alice" the last share should include the following properties: | file_target | /Shares/BRIAN-FOLDER | Examples: | dav-path-version |