Repository: zeppelin
Updated Branches:
  refs/heads/branch-0.7 b50340eca -> 53e905786


[ZEPPELIN-1720] Adding tests to verify behaviour of dynamic forms

### What is this PR for?
Adding Selenium tests to ensure proper behaviour of dynamic forms.

### What type of PR is it?
Test

### Todos
N/A

### What is the Jira issue?
[ZEPPELIN-1720](https://issues.apache.org/jira/browse/ZEPPELIN-1720)

### How should this be tested?

1. Once should first get Firefox v. 41 as it is the latest version that works 
with the current version of Selenium in Apache Zeppelin.
2. You can then run the tests with following command:

`TEST_SELENIUM="true" mvn package -DfailIfNoTests=false -pl 
'zeppelin-interpreter,zeppelin-zengine,zeppelin-server' 
-Dtest=ParagraphActionsIT
`
### Screenshots (if appropriate)
N/A

### Questions:
* Does the licenses files need update? no
* Is there breaking changes for older versions? no
* Does this needs documentation? no

Author: Guillermo Cabrera <guic...@gmail.com>

Closes #2141 from guicaro/ZEPPELIN-1720-AddingTestsForDynamicForms and squashes 
the following commits:

a5bc7db [Guillermo Cabrera] Updated tests to work with new paragraph behaviour
3fa2033 [Guillermo Cabrera] Updated testMultipleDynamicFormsSameType based on 
new behaviour of paragraphs
92102bd [Guillermo Cabrera] Updated testSingleDynamicFormSelectForm for "Run on 
selection change" option
f194979 [Guillermo Cabrera] Fixing other issues on test case messages for 
readability
f7e99ca [Guillermo Cabrera] Corrected grammar in a test case output message
bc1e7f9 [Guillermo Cabrera] Removed unused import, alignment and removed 
unnecesary condition in test case
274b2c1 [Guillermo Cabrera] Added tests that cover behaviour of dynamic forms
eed42f0 [Guillermo Cabrera] Completed and verified corrct behaviour of 
testSingleDynamicFormTextInput
7a4f121 [Guillermo Cabrera] Added method stubbs for new UI tests checking 
correct behaviour of dynamic forms

(cherry picked from commit f76ac8807eaf3a0875d859e4ef896b770b4df01a)
Signed-off-by: ahyoungryu <ahyoung...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/53e90578
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/53e90578
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/53e90578

Branch: refs/heads/branch-0.7
Commit: 53e90578621574f466a58ad02a6577bca6335a5a
Parents: b50340e
Author: Guillermo Cabrera <guic...@gmail.com>
Authored: Mon Mar 20 16:00:52 2017 +0300
Committer: ahyoungryu <ahyoung...@apache.org>
Committed: Fri Mar 24 13:35:17 2017 +0900

----------------------------------------------------------------------
 .../integration/ParagraphActionsIT.java         | 161 ++++++++++++++++++-
 1 file changed, 160 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/53e90578/zeppelin-server/src/test/java/org/apache/zeppelin/integration/ParagraphActionsIT.java
----------------------------------------------------------------------
diff --git 
a/zeppelin-server/src/test/java/org/apache/zeppelin/integration/ParagraphActionsIT.java
 
b/zeppelin-server/src/test/java/org/apache/zeppelin/integration/ParagraphActionsIT.java
index dac9028..e826e23 100644
--- 
a/zeppelin-server/src/test/java/org/apache/zeppelin/integration/ParagraphActionsIT.java
+++ 
b/zeppelin-server/src/test/java/org/apache/zeppelin/integration/ParagraphActionsIT.java
@@ -513,4 +513,163 @@ public class ParagraphActionsIT extends 
AbstractZeppelinIT {
       handleException("Exception in ParagraphActionsIT while 
testEditOnDoubleClick ", e);
     }
   }
-}
+
+  @Test
+  public void testSingleDynamicFormTextInput() throws Exception {
+    if (!endToEndTestEnabled()) {
+      return;
+    }
+    try {
+      createNewNote();
+
+      setTextOfParagraph(1, "%spark println(\"Hello \"+z.input(\"name\", 
\"world\")) ");
+
+      runParagraph(1);
+      waitForParagraph(1, "FINISHED");
+      collector.checkThat("Output text is equal to value specified initially",
+              driver.findElement(By.xpath(getParagraphXPath(1) + 
"//div[contains(@class, 'text plainTextContent')]")).getText(),
+              CoreMatchers.equalTo("Hello world"));
+
+      driver.findElement(By.xpath(getParagraphXPath(1) + "//input")).clear();
+      driver.findElement(By.xpath(getParagraphXPath(1) + 
"//input")).sendKeys("Zeppelin");
+
+      collector.checkThat("After new data in text input form, output should 
not be changed",
+              driver.findElement(By.xpath(getParagraphXPath(1) + 
"//div[contains(@class, 'text plainTextContent')]")).getText(),
+              CoreMatchers.equalTo("Hello world"));
+
+      runParagraph(1);
+      waitForParagraph(1, "FINISHED");
+      collector.checkThat("Only after running the paragraph, we can see the 
newly updated output",
+              driver.findElement(By.xpath(getParagraphXPath(1) + 
"//div[contains(@class, 'text plainTextContent')]")).getText(),
+              CoreMatchers.equalTo("Hello Zeppelin"));
+
+      deleteTestNotebook(driver);
+
+    } catch (Exception e) {
+      handleException("Exception in ParagraphActionsIT while 
testSingleDynamicFormTextInput  ", e);
+    }
+  }
+
+  @Test
+  public void testSingleDynamicFormSelectForm() throws Exception {
+    if (!endToEndTestEnabled()) {
+      return;
+    }
+    try {
+      createNewNote();
+
+      setTextOfParagraph(1, "%spark println(\"Howdy \"+z.select(\"names\", 
Seq((\"1\",\"Alice\"), " +
+              "(\"2\",\"Bob\"),(\"3\",\"stranger\"))))");
+
+      runParagraph(1);
+      waitForParagraph(1, "FINISHED");
+      collector.checkThat("Output text should not display any of the options 
in select form",
+              driver.findElement(By.xpath(getParagraphXPath(1) + 
"//div[contains(@class, 'text plainTextContent')]")).getText(),
+              CoreMatchers.equalTo("Howdy "));
+
+      Select dropDownMenu = new Select(driver.findElement(By.xpath("(" + 
(getParagraphXPath(1) + "//select)[1]"))));
+      dropDownMenu.selectByVisibleText("Alice");
+      collector.checkThat("After selection in drop down menu, output should 
display the newly selected option",
+              driver.findElement(By.xpath(getParagraphXPath(1) + 
"//div[contains(@class, 'text plainTextContent')]")).getText(),
+              CoreMatchers.equalTo("Howdy 1"));
+
+      driver.findElement(By.xpath(getParagraphXPath(1) + 
"//span[@class='icon-settings']")).click();
+      clickAndWait(By.xpath(getParagraphXPath(1) + 
"//ul/li/form/input[contains(@ng-checked, 'true')]"));
+
+      Select sameDropDownMenu = new Select(driver.findElement(By.xpath("(" + 
(getParagraphXPath(1) + "//select)[1]"))));
+      sameDropDownMenu.selectByVisibleText("Bob");
+      collector.checkThat("After 'Run on selection change' checkbox is 
unchecked, the paragraph should not run if selecting a different option",
+              driver.findElement(By.xpath(getParagraphXPath(1) + 
"//div[contains(@class, 'text plainTextContent')]")).getText(),
+              CoreMatchers.equalTo("Howdy 1"));
+
+      deleteTestNotebook(driver);
+
+    } catch (Exception e) {
+      handleException("Exception in ParagraphActionsIT while 
testSingleDynamicFormSelectForm  ", e);
+    }
+  }
+
+  @Test
+  public void testSingleDynamicFormCheckboxForm() throws Exception {
+    if (!endToEndTestEnabled()) {
+      return;
+    }
+    try {
+      createNewNote();
+
+      setTextOfParagraph(1, "%spark val options = Seq((\"han\",\"Han\"), 
(\"leia\",\"Leia\"), " +
+              "(\"luke\",\"Luke\")); println(\"Greetings 
\"+z.checkbox(\"skywalkers\",options).mkString(\" and \"))");
+
+      runParagraph(1);
+      waitForParagraph(1, "FINISHED");
+      collector.checkThat("Output text should display all of the options 
included in check boxes",
+              driver.findElement(By.xpath(getParagraphXPath(1) + 
"//div[contains(@class, 'text plainTextContent')]")).getText(),
+              CoreMatchers.containsString("Greetings han and leia and luke"));
+
+      WebElement firstCheckbox = driver.findElement(By.xpath("(" + 
getParagraphXPath(1) + "//input[@type='checkbox'])[1]"));
+      firstCheckbox.click();
+      collector.checkThat("After unchecking one of the boxes, we can see the 
newly updated output without the option we unchecked",
+              driver.findElement(By.xpath(getParagraphXPath(1) + 
"//div[contains(@class, 'text plainTextContent')]")).getText(),
+              CoreMatchers.containsString("Greetings leia and luke"));
+
+      driver.findElement(By.xpath(getParagraphXPath(1) + 
"//span[@class='icon-settings']")).click();
+      clickAndWait(By.xpath(getParagraphXPath(1) + 
"//ul/li/form/input[contains(@ng-checked, 'true')]"));
+
+      WebElement secondCheckbox = driver.findElement(By.xpath("(" + 
getParagraphXPath(1) + "//input[@type='checkbox'])[2]"));
+      secondCheckbox.click();
+      collector.checkThat("After 'Run on selection change' checkbox is 
unchecked, the paragraph should not run if check box state is modified",
+              driver.findElement(By.xpath(getParagraphXPath(1) + 
"//div[contains(@class, 'text plainTextContent')]")).getText(),
+              CoreMatchers.containsString("Greetings leia and luke"));
+
+      runParagraph(1);
+      waitForParagraph(1, "FINISHED");
+
+
+      deleteTestNotebook(driver);
+
+    } catch (Exception e) {
+      handleException("Exception in ParagraphActionsIT while 
testSingleDynamicFormCheckboxForm  ", e);
+    }
+  }
+
+  @Test
+  public void testMultipleDynamicFormsSameType() throws Exception {
+    if (!endToEndTestEnabled()) {
+      return;
+    }
+    try {
+      createNewNote();
+
+      setTextOfParagraph(1, "%spark println(\"Howdy \"+z.select(\"fruits\", 
Seq((\"1\",\"Apple\")," +
+              "(\"2\",\"Orange\"),(\"3\",\"Peach\")))); println(\"Howdy 
\"+z.select(\"planets\", " +
+              "Seq((\"1\",\"Venus\"),(\"2\",\"Earth\"),(\"3\",\"Mars\"))))");
+
+      runParagraph(1);
+      waitForParagraph(1, "FINISHED");
+      collector.checkThat("Output text should not display any of the options 
in select form",
+              driver.findElement(By.xpath(getParagraphXPath(1) + 
"//div[contains(@class, 'text plainTextContent')]")).getText(),
+              CoreMatchers.equalTo("Howdy \nHowdy "));
+
+      Select dropDownMenu = new Select(driver.findElement(By.xpath("(" + 
(getParagraphXPath(1) + "//select)[1]"))));
+      dropDownMenu.selectByVisibleText("Apple");
+      collector.checkThat("After selection in drop down menu, output should 
display the new option we selected",
+              driver.findElement(By.xpath(getParagraphXPath(1) + 
"//div[contains(@class, 'text plainTextContent')]")).getText(),
+              CoreMatchers.equalTo("Howdy 1\nHowdy "));
+
+      driver.findElement(By.xpath(getParagraphXPath(1) + 
"//span[@class='icon-settings']")).click();
+      clickAndWait(By.xpath(getParagraphXPath(1) + 
"//ul/li/form/input[contains(@ng-checked, 'true')]"));
+
+      Select sameDropDownMenu = new Select(driver.findElement(By.xpath("(" + 
(getParagraphXPath(1) + "//select)[2]"))));
+      sameDropDownMenu.selectByVisibleText("Earth");
+      waitForParagraph(1, "FINISHED");
+      collector.checkThat("After 'Run on selection change' checkbox is 
unchecked, the paragraph should not run if selecting a different option",
+              driver.findElement(By.xpath(getParagraphXPath(1) + 
"//div[contains(@class, 'text plainTextContent')]")).getText(),
+              CoreMatchers.equalTo("Howdy 1\nHowdy "));
+
+      deleteTestNotebook(driver);
+
+    } catch (Exception e) {
+      handleException("Exception in ParagraphActionsIT while 
testMultipleDynamicFormsSameType  ", e);
+    }
+  }
+}
\ No newline at end of file

Reply via email to