From e2ad08b25b3a447e1f29cf2f13dc2d9d2026ac20 Mon Sep 17 00:00:00 2001 From: ishabaral Date: Wed, 17 Jul 2024 14:37:19 +0545 Subject: [PATCH] search: reindex command for all spaces --- tests/acceptance/config/behat.yml | 2 ++ .../features/bootstrap/CliContext.php | 29 +++++++++++++++ .../cliCommands/searchReIndex.feature | 35 +++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 tests/acceptance/features/cliCommands/searchReIndex.feature diff --git a/tests/acceptance/config/behat.yml b/tests/acceptance/config/behat.yml index 584b5088e90..0ea587a327f 100644 --- a/tests/acceptance/config/behat.yml +++ b/tests/acceptance/config/behat.yml @@ -401,6 +401,8 @@ default: - OcisConfigContext: - FilesVersionsContext: - SharingNgContext: + - SearchContext: + - TagContext: extensions: rdx\behatvars\BehatVariablesExtension: ~ diff --git a/tests/acceptance/features/bootstrap/CliContext.php b/tests/acceptance/features/bootstrap/CliContext.php index ad5cb910750..3780f0fde85 100644 --- a/tests/acceptance/features/bootstrap/CliContext.php +++ b/tests/acceptance/features/bootstrap/CliContext.php @@ -139,6 +139,35 @@ public function theAdministratorRemovesTheVersionsOfFileUsingFileId($file, $user $this->featureContext->setResponse(CliHelper::runCommand($body)); } + /** + * @When /^the administrator reindexes all spaces using the CLI$/ + * + * @return void + */ + public function theAdministratorReindexesAllSpacesUsingTheCli(): void { + $command = "search index --all-spaces"; + $body = [ + "command" => $command + ]; + $this->featureContext->setResponse(CliHelper::runCommand($body)); + } + + /** + * @When /^the administrator reindexes a space "([^"]*)" using the CLI$/ + * + * @param string $spaceName + * + * @return void + */ + public function theAdministratorReindexesASpaceWithSpacenameUsingTheCli(string $spaceName): void { + $spaceId = $this->featureContext->spacesContext->getSpaceIdByName($this->featureContext->getAdminUsername(), $spaceName); + $command = "search index --space $spaceId"; + $body = [ + "command" => $command + ]; + $this->featureContext->setResponse(CliHelper::runCommand($body)); + } + /** * @Then the command should be successful * diff --git a/tests/acceptance/features/cliCommands/searchReIndex.feature b/tests/acceptance/features/cliCommands/searchReIndex.feature new file mode 100644 index 00000000000..40c42541d8f --- /dev/null +++ b/tests/acceptance/features/cliCommands/searchReIndex.feature @@ -0,0 +1,35 @@ +@env-config +Feature: reindex space via CLI command + As an admin + I want to reindex space + So that I can improve search performance by ensuring that the index is up-to-date + + Background: + Given user "Alice" has been created with default attributes and without skeleton files + And 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 "new-space" with the default quota using the Graph API + And user "Alice" has uploaded a file inside space "new-space" with content "some data" to "textfile.txt" + And using new DAV path + + + Scenario: reindex all spaces + When the administrator reindexes all spaces using the CLI + Then the command should be successful + When user "Alice" searches for "textfile.txt" using the WebDAV API + Then the HTTP status code should be "207" + And the search result of user "Alice" should contain only these entries: + | /textfile.txt | + + + Scenario: reindex a space + Given using spaces DAV path + And user "Alice" has created the following tags for file "textfile.txt" of the space "new-space": + | tag1 | + And user "Alice" has removed the following tags for file "textfile.txt" of space "new-space": + | tag1 | + When the administrator reindexes a space "new-space" using the CLI + Then the command should be successful + When user "Alice" searches for "Tags:tag1" using the WebDAV API + Then the HTTP status code should be "207" + And the search result should contain "0" entries