From b4a5b7b1f813c711b8ea9b1372e90a22118e2735 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= <danxuliu@gmail.com>
Date: Tue, 16 Oct 2018 14:26:35 +0200
Subject: [PATCH] Add acceptance test steps to be used from Talk acceptance
 tests
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
---
 .../features/bootstrap/FilesAppContext.php    | 49 +++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/tests/acceptance/features/bootstrap/FilesAppContext.php b/tests/acceptance/features/bootstrap/FilesAppContext.php
index 744ba104124b3..2d370a6d44ed4 100644
--- a/tests/acceptance/features/bootstrap/FilesAppContext.php
+++ b/tests/acceptance/features/bootstrap/FilesAppContext.php
@@ -293,6 +293,15 @@ public static function passwordProtectByTalkCheckbox() {
 				describedAs("Password protect by Talk checkbox in the details view in Files app");
 	}
 
+	/**
+	 * @return Locator
+	 */
+	public static function passwordProtectByTalkCheckboxInput() {
+		return Locator::forThe()->checkbox("Password protect by Talk")->
+				descendantOf(self::shareLinkMenu())->
+				describedAs("Password protect by Talk checkbox input in the details view in Files app");
+	}
+
 	/**
 	 * @Given I close the details view
 	 */
@@ -375,6 +384,28 @@ public function iProtectTheSharedLinkWithThePassword($password) {
 		$this->actor->find(self::passwordProtectField(), 2)->setValue($password . "\r");
 	}
 
+	/**
+	 * @When I set the password of the shared link as protected by Talk
+	 */
+	public function iSetThePasswordOfTheSharedLinkAsProtectedByTalk() {
+		$this->showShareLinkMenuIfNeeded();
+
+		$this->iSeeThatThePasswordOfTheLinkShareIsNotProtectedByTalk();
+
+		$this->actor->find(self::passwordProtectByTalkCheckbox(), 2)->click();
+	}
+
+	/**
+	 * @When I set the password of the shared link as not protected by Talk
+	 */
+	public function iSetThePasswordOfTheSharedLinkAsNotProtectedByTalk() {
+		$this->showShareLinkMenuIfNeeded();
+
+		$this->iSeeThatThePasswordOfTheLinkShareIsProtectedByTalk();
+
+		$this->actor->find(self::passwordProtectByTalkCheckbox(), 2)->click();
+	}
+
 	/**
 	 * @Then I see that the current page is the Files app
 	 */
@@ -510,6 +541,24 @@ public function iSeeThatTheLinkShareIsPasswordProtected() {
 		PHPUnit_Framework_Assert::assertTrue($this->actor->find(self::passwordProtectField(), 10)->isVisible(), "Password protect field is visible");
 	}
 
+	/**
+	 * @Then I see that the password of the link share is protected by Talk
+	 */
+	public function iSeeThatThePasswordOfTheLinkShareIsProtectedByTalk() {
+		$this->showShareLinkMenuIfNeeded();
+
+		PHPUnit_Framework_Assert::assertTrue($this->actor->find(self::passwordProtectByTalkCheckboxInput(), 10)->isChecked());
+	}
+
+	/**
+	 * @Then I see that the password of the link share is not protected by Talk
+	 */
+	public function iSeeThatThePasswordOfTheLinkShareIsNotProtectedByTalk() {
+		$this->showShareLinkMenuIfNeeded();
+
+		PHPUnit_Framework_Assert::assertFalse($this->actor->find(self::passwordProtectByTalkCheckboxInput(), 10)->isChecked());
+	}
+
 	/**
 	 * @Then I see that the checkbox to protect the password of the link share by Talk is not shown
 	 */