Skip to content

Commit

Permalink
refactoring the tag creating step using data table (#7074)
Browse files Browse the repository at this point in the history
  • Loading branch information
nabim777 authored Aug 21, 2023
1 parent c5cec60 commit 7c20b18
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 22 deletions.
38 changes: 18 additions & 20 deletions tests/acceptance/features/apiGraph/fullSearch.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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-version> DAV path
When user "Alice" searches for "Tags:tag1" using the WebDAV API
Then the HTTP status code should be "207"
Expand All @@ -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:
Expand All @@ -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-version> DAV path
When user "Alice" searches for "Tags:tag1" using the WebDAV API
Then the HTTP status code should be "207"
Expand Down
24 changes: 22 additions & 2 deletions tests/acceptance/features/bootstrap/TagContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
*
Expand Down

0 comments on commit 7c20b18

Please sign in to comment.