From 7c20b189d3307458911b46b1fcee05c67d064366 Mon Sep 17 00:00:00 2001 From: Nalem7 <61624650+nabim777@users.noreply.github.com> Date: Mon, 21 Aug 2023 13:12:52 +0545 Subject: [PATCH] refactoring the tag creating step using data table (#7074) --- .../features/apiGraph/fullSearch.feature | 38 +++++++++---------- .../features/bootstrap/TagContext.php | 24 +++++++++++- 2 files changed, 40 insertions(+), 22 deletions(-) diff --git a/tests/acceptance/features/apiGraph/fullSearch.feature b/tests/acceptance/features/apiGraph/fullSearch.feature index 41d434c67a0..9243b557523 100644 --- a/tests/acceptance/features/apiGraph/fullSearch.feature +++ b/tests/acceptance/features/apiGraph/fullSearch.feature @@ -18,12 +18,11 @@ Feature: full text search | fileInRootLevel.txt | | folderWithFile/fileInsideFolder.txt | | folderWithFile/subFolder/fileInsideSubFolder.txt | - And user "Alice" has created the following tags for file "fileInRootLevel.txt" of the space "Personal": - | tag1 | - And user "Alice" has created the following tags for file "folderWithFile/fileInsideFolder.txt" of the space "Personal": - | tag1 | - And user "Alice" has created the following tags for file "folderWithFile/subFolder/fileInsideSubFolder.txt" of the space "Personal": - | tag1 | + And user "Alice" has tagged the following files of the space "Personal": + | path | tagName | + | fileInRootLevel.txt | tag1 | + | folderWithFile/fileInsideFolder.txt | tag1 | + | folderWithFile/subFolder/fileInsideSubFolder.txt | tag1 | When user "Alice" searches for "Tags:tag1" using the WebDAV API Then the HTTP status code should be "207" And the search result of user "Alice" should contain only these files: @@ -46,12 +45,11 @@ Feature: full text search And user "Alice" has uploaded a file inside space "tag-space" with content "untagged file" to "spacesFileWithoutTag.txt" And user "Alice" has uploaded a file inside space "tag-space" with content "tagged file in folder" to "spacesFolderWithFile/spacesFileInsideFolder.txt" And user "Alice" has uploaded a file inside space "tag-space" with content "tagged file in subfolder" to "spacesFolderWithFile/spacesSubFolder/spacesFileInsideSubFolder.txt" - And user "Alice" has created the following tags for file "spacesFile.txt" of the space "tag-space": - | tag1 | - And user "Alice" has created the following tags for file "spacesFolderWithFile/spacesFileInsideFolder.txt" of the space "tag-space": - | tag1 | - And user "Alice" has created the following tags for file "spacesFolderWithFile/spacesSubFolder/spacesFileInsideSubFolder.txt" of the space "tag-space": - | tag1 | + And user "Alice" has tagged the following files of the space "tag-space": + | path | tagName | + | spacesFile.txt | tag1 | + | spacesFolderWithFile/spacesFileInsideFolder.txt | tag1 | + | spacesFolderWithFile/spacesSubFolder/spacesFileInsideSubFolder.txt | tag1 | And using DAV path When user "Alice" searches for "Tags:tag1" using the WebDAV API Then the HTTP status code should be "207" @@ -75,10 +73,10 @@ Feature: full text search And user "Alice" has created folder "uploadFolder1" And user "Alice" has created folder "uploadFolder2" And user "Alice" has created folder "uploadFolder3" - And user "Alice" has created the following tags for folder "uploadFolder1" of the space "Personal": - | tag1 | - And user "Alice" has created the following tags for folder "uploadFolder2" of the space "Personal": - | tag1 | + And user "Alice" has tagged the following folders of the space "Personal": + | path | tagName | + | uploadFolder1 | tag1 | + | uploadFolder2 | tag1 | When user "Alice" searches for "Tags:tag1" using the WebDAV API Then the HTTP status code should be "207" And the search result of user "Alice" should contain only these entries: @@ -97,10 +95,10 @@ Feature: full text search And user "Alice" has created a space "tag-space" with the default quota using the GraphApi And user "Alice" has created a folder "spacesFolder/spacesSubFolder" in space "tag-space" And user "Alice" has created a folder "unTagSpacesFolder/unTagSpacesSubFolder" in space "tag-space" - And user "Alice" has created the following tags for folder "spacesFolder" of the space "tag-space": - | tag1 | - And user "Alice" has created the following tags for folder "spacesFolder/spacesSubFolder" of the space "tag-space": - | tag1 | + And user "Alice" has tagged the following folders of the space "tag-space": + | path | tagName | + | spacesFolder | tag1 | + | spacesFolder/spacesSubFolder | tag1 | And using DAV path When user "Alice" searches for "Tags:tag1" using the WebDAV API Then the HTTP status code should be "207" diff --git a/tests/acceptance/features/bootstrap/TagContext.php b/tests/acceptance/features/bootstrap/TagContext.php index 25be97258fb..4f51cf9401f 100644 --- a/tests/acceptance/features/bootstrap/TagContext.php +++ b/tests/acceptance/features/bootstrap/TagContext.php @@ -69,8 +69,7 @@ public function theUserCreatesFollowingTags(string $user, string $fileOrFolder, foreach ($table->getRows() as $value) { $tagNameArray[] = $value[0]; } - - if ($fileOrFolder === 'folder') { + if ($fileOrFolder === 'folder' || $fileOrFolder === 'folders') { $resourceId = $this->spacesContext->getResourceId($user, $space, $resource); } else { $resourceId = $this->spacesContext->getFileId($user, $space, $resource); @@ -104,6 +103,27 @@ public function theUserHasCreatedFollowingTags(string $user, string $fileOrFolde $this->featureContext->theHttpStatusCodeShouldBe(200); } + /** + * @Given /^user "([^"]*)" has tagged the following (folders|files) of the space "([^"]*)":$/ + * + * @param string $user + * @param string $filesOrFolders (files|folders) + * @param string $space + * @param TableNode $table + * + * @return void + * @throws Exception + */ + public function userHasCreatedTheFollowingTagsForFilesOfTheSpace(string $user, string $filesOrFolders, string $space, TableNode $table):void { + $this->featureContext->verifyTableNodeColumns($table, ["path", "tagName"]); + $rows = $table->getHash(); + foreach ($rows as $row) { + $resource = $row['path']; + $tags = explode(',', $row['tagName']); + $this->theUserHasCreatedFollowingTags($user, $filesOrFolders, $resource, $space, new TableNode([$tags])); + } + } + /** * @When user :user lists all available tag(s) via the GraphApi *