]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add acceptance tests for showing the input field for tags
authorDaniel Calviño Sánchez <danxuliu@gmail.com>
Fri, 9 Jun 2017 01:02:33 +0000 (03:02 +0200)
committerDaniel Calviño Sánchez <danxuliu@gmail.com>
Tue, 13 Jun 2017 14:41:20 +0000 (16:41 +0200)
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
tests/acceptance/features/app-files.feature
tests/acceptance/features/bootstrap/FilesAppContext.php

index 6779b37e14542cada071c1212b3d1cdb446f0210..8d32508513aaf6e8b795aae9c20366884b01077e 100644 (file)
@@ -52,3 +52,19 @@ Feature: app-files
     And I authenticate with password "fedcba"
     Then I see that the current page is the Authenticate page for the shared link I wrote down
     And I see that a wrong password for the shared file message is shown
+
+  Scenario: show the input field for tags in the details view
+    Given I am logged in
+    And I open the details view for "welcome.txt"
+    And I see that the details view for "All files" section is open
+    When I open the input field for tags in the details view
+    Then I see that the input field for tags in the details view is shown
+
+  Scenario: show the input field for tags in the details view after the sharing tab has loaded
+    Given I am logged in
+    And I open the details view for "welcome.txt"
+    And I see that the details view for "All files" section is open
+    And I open the "Sharing" tab in the details view
+    And I see that the "Sharing" tab in the details view is eventually loaded
+    When I open the input field for tags in the details view
+    Then I see that the input field for tags in the details view is shown
index 5916fd4bec692a75a4e62d00fb3ad8d2b2504dd2..9d8e05a1325c0f75a1a466f40b86417f825bf6ff 100644 (file)
@@ -102,6 +102,69 @@ class FilesAppContext implements Context, ActorAwareInterface {
                                describedAs("Current section details view in Files app");
        }
 
+       /**
+        * @return Locator
+        */
+       public static function fileDetailsInCurrentSectionDetailsViewWithText($fileDetailsText) {
+               return Locator::forThe()->xpath("//span[normalize-space() = '$fileDetailsText']")->
+                               descendantOf(self::fileDetailsInCurrentSectionDetailsView())->
+                               describedAs("File details with text \"$fileDetailsText\" in current section details view in Files app");
+       }
+
+       /**
+        * @return Locator
+        */
+       private static function fileDetailsInCurrentSectionDetailsView() {
+               return Locator::forThe()->css(".file-details")->
+                               descendantOf(self::currentSectionDetailsView())->
+                               describedAs("File details in current section details view in Files app");
+       }
+
+       /**
+        * @return Locator
+        */
+       public static function inputFieldForTagsInCurrentSectionDetails() {
+               return Locator::forThe()->css(".systemTagsInfoView")->
+                               descendantOf(self::currentSectionDetailsView())->
+                               describedAs("Input field for tags in current section details view in Files app");
+       }
+
+       /**
+        * @return Locator
+        */
+       public static function tabHeaderInCurrentSectionDetailsViewNamed($tabHeaderName) {
+               return Locator::forThe()->xpath("//li[normalize-space() = '$tabHeaderName']")->
+                               descendantOf(self::tabHeadersInCurrentSectionDetailsView())->
+                               describedAs("Tab header named $tabHeaderName in current section details view in Files app");
+       }
+
+       /**
+        * @return Locator
+        */
+       private static function tabHeadersInCurrentSectionDetailsView() {
+               return Locator::forThe()->css(".tabHeaders")->
+                               descendantOf(self::currentSectionDetailsView())->
+                               describedAs("Tab headers in current section details view in Files app");
+       }
+
+       /**
+        * @return Locator
+        */
+       public static function tabInCurrentSectionDetailsViewNamed($tabName) {
+               return Locator::forThe()->xpath("//div[@id=//*[contains(concat(' ', normalize-space(@class), ' '), ' tabHeader ') and normalize-space() = '$tabName']/@data-tabid]")->
+                               descendantOf(self::currentSectionDetailsView())->
+                               describedAs("Tab named $tabName in current section details view in Files app");
+       }
+
+       /**
+        * @return Locator
+        */
+       public static function loadingIconForTabInCurrentSectionDetailsViewNamed($tabName) {
+               return Locator::forThe()->css(".loading")->
+                               descendantOf(self::tabInCurrentSectionDetailsViewNamed($tabName))->
+                               describedAs("Loading icon for tab named $tabName in current section details view in Files app");
+       }
+
        /**
         * @return Locator
         */
@@ -246,6 +309,20 @@ class FilesAppContext implements Context, ActorAwareInterface {
                $this->actor->find(self::detailsMenuItem(), 2)->click();
        }
 
+       /**
+        * @Given I open the input field for tags in the details view
+        */
+       public function iOpenTheInputFieldForTagsInTheDetailsView() {
+               $this->actor->find(self::fileDetailsInCurrentSectionDetailsViewWithText("Tags"), 10)->click();
+       }
+
+       /**
+        * @Given I open the :tabName tab in the details view
+        */
+       public function iOpenTheTabInTheDetailsView($tabName) {
+               $this->actor->find(self::tabHeaderInCurrentSectionDetailsViewNamed($tabName), 10)->click();
+       }
+
        /**
         * @Given I mark :fileName as favorite
         */
@@ -343,6 +420,36 @@ class FilesAppContext implements Context, ActorAwareInterface {
                PHPUnit_Framework_Assert::assertNotNull($this->actor->find(self::favoritedStateIconForFile($fileName), 10));
        }
 
+       /**
+        * @Then I see that the input field for tags in the details view is shown
+        */
+       public function iSeeThatTheInputFieldForTagsInTheDetailsViewIsShown() {
+               PHPUnit_Framework_Assert::assertTrue(
+                               $this->actor->find(self::inputFieldForTagsInCurrentSectionDetails(), 10)->isVisible());
+       }
+
+       /**
+        * @When I see that the :tabName tab in the details view is eventually loaded
+        */
+       public function iSeeThatTheTabInTheDetailsViewIsEventuallyLoaded($tabName) {
+               $timeout = 10;
+               $timeoutStep = 1;
+
+               $actor = $this->actor;
+               $loadingIcon = self::loadingIconForTabInCurrentSectionDetailsViewNamed($tabName);
+
+               $loadingIconNotFoundCallback = function() use ($actor, $loadingIcon) {
+                       try {
+                               return !$actor->find($loadingIcon)->isVisible();
+                       } catch (NoSuchElementException $exception) {
+                               return true;
+                       }
+               };
+               if (!Utils::waitFor($loadingIconNotFoundCallback, $timeout, $timeoutStep)) {
+                       PHPUnit_Framework_Assert::fail("The $tabName tab in the details view has not been loaded after $timeout seconds");
+               }
+       }
+
        /**
         * @Then I see that the working icon for password protect is shown
         */