Repository: zeppelin Updated Branches: refs/heads/branch-0.7 d77a6e6f0 -> 341944462
[ZEPPELIN-2287] Add more test to ensure 'RunOnSelectionChange' works well ### What is this PR for? To address this feedback https://github.com/apache/zeppelin/pull/2100#issuecomment-286780437, I added more test cases to ensure `RunOnSelectionChange` works well. The newly added test cases are like below. When we run this paragraph, one dropdown menu will be shown: ``` %md My selection is ${my selection=1,1|2|3} ```  1. When `RunOnSelectionChange` is **true** (default) if we select "2" in the dropdown menu, the result text will be updated to "My selection is 2" right after the selection change. [See here](https://github.com/apache/zeppelin/compare/master...AhyoungRyu:ZEPPELIN-2287/addTestForRunOnSelectionChange?expand=1#diff-48409cf8ca5ddb1aea1a62ada3cd091dR282) 2. When `RunOnSelectionChange` is **false** If we select "1" in the dropdown menu, the result text won't be updated to "My selection is 1" right after the selection change instead it'll be remained as "My selection is 2". [See here](https://github.com/apache/zeppelin/compare/master...AhyoungRyu:ZEPPELIN-2287/addTestForRunOnSelectionChange?expand=1#diff-48409cf8ca5ddb1aea1a62ada3cd091dR295) But we can run the paragraph by pressing `Enter`. After running the paragraph manually using `Enter`, then the result text will be updated to "My selection is 1" [See here](https://github.com/apache/zeppelin/compare/master...AhyoungRyu:ZEPPELIN-2287/addTestForRunOnSelectionChange?expand=1#diff-48409cf8ca5ddb1aea1a62ada3cd091dR301) ### What type of PR is it? Add test case ### What is the Jira issue? [ZEPPELIN-2287](https://issues.apache.org/jira/browse/ZEPPELIN-2287) ### How should this be tested? After applying this patch, run ``` TEST_SELENIUM="true" mvn package -DfailIfNoTests=false -pl 'zeppelin-interpreter,zeppelin-zengine,zeppelin-server' -Dtest=ParagraphActionsIT#testRunOnSelectionChange ``` ### Questions: * Does the licenses files need update? no * Is there breaking changes for older versions? no * Does this needs documentation? no Author: AhyoungRyu <fbdkdu...@hanmail.net> Closes #2163 from AhyoungRyu/ZEPPELIN-2287/addTestForRunOnSelectionChange and squashes the following commits: 79efddc [AhyoungRyu] Add 'waitForParagraph' before every selection change 01ea57a [AhyoungRyu] Try to refresh after running paragraph run by Enter 795410c [AhyoungRyu] Replace 'sleep(1000)' with waitForParagraph 84f1b2a [AhyoungRyu] Sleep 1sec after hitting ENRER 77cc5c9 [AhyoungRyu] Add 1 more test to ensure the paragraph can be run with ENTER 1a656db [AhyoungRyu] Add more test to ensure 'RunOnSelectionChange' works well (cherry picked from commit 174244e20188406b307b8e4503444a6a00f164b1) 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/34194446 Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/34194446 Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/34194446 Branch: refs/heads/branch-0.7 Commit: 3419444624d0c5f0b898781acb44ccdbe649d61b Parents: d77a6e6 Author: AhyoungRyu <fbdkdu...@hanmail.net> Authored: Sat Mar 25 13:25:01 2017 +0900 Committer: ahyoungryu <ahyoung...@apache.org> Committed: Tue Mar 28 22:26:51 2017 +0900 ---------------------------------------------------------------------- .../integration/ParagraphActionsIT.java | 35 +++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zeppelin/blob/34194446/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 e826e23..ca1da0f 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 @@ -257,31 +257,58 @@ public class ParagraphActionsIT extends AbstractZeppelinIT { } @Test - public void testRunOnSelectionCheckbox() throws Exception { + public void testRunOnSelectionChange() throws Exception { if (!endToEndTestEnabled()) { return; } try { - String xpathToCheckbox = getParagraphXPath(1) + "//ul/li/form/input[contains(@ng-checked, 'true')]"; + String xpathToRunOnSelectionChangeCheckbox = getParagraphXPath(1) + "//ul/li/form/input[contains(@ng-checked, 'true')]"; + String xpathToDropdownMenu = getParagraphXPath(1) + "//select"; + String xpathToResultText = getParagraphXPath(1) + "//div[contains(@id,\"_html\")]"; createNewNote(); waitForParagraph(1, "READY"); setTextOfParagraph(1, "%md My selection is ${my selection=1,1|2|3}"); runParagraph(1); + waitForParagraph(1, "FINISHED"); + // 1. 'RunOnSelectionChange' is true by default driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); collector.checkThat("'Run on selection change' checkbox will be shown under dropdown menu ", driver.findElement(By.xpath(getParagraphXPath(1) + "//ul/li/form/input[contains(@ng-click, 'turnOnAutoRun(paragraph)')]")).isDisplayed(), CoreMatchers.equalTo(true)); - driver.findElement(By.xpath(xpathToCheckbox)).click(); + Select dropDownMenu = new Select(driver.findElement(By.xpath((xpathToDropdownMenu)))); + dropDownMenu.selectByVisibleText("2"); + waitForParagraph(1, "FINISHED"); + collector.checkThat("If 'RunOnSelectionChange' is true, the paragraph result will be updated right after click any options in the dropdown menu ", + driver.findElement(By.xpath(xpathToResultText)).getText(), + CoreMatchers.equalTo("My selection is 2")); + + // 2. set 'RunOnSelectionChange' to false + driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); + driver.findElement(By.xpath(xpathToRunOnSelectionChangeCheckbox)).click(); collector.checkThat("If 'Run on selection change' checkbox is unchecked, 'paragraph.config.runOnSelectionChange' will be false ", driver.findElement(By.xpath(getParagraphXPath(1) + "//ul/li/span[contains(@ng-if, 'paragraph.config.runOnSelectionChange == false')]")).isDisplayed(), CoreMatchers.equalTo(true)); + Select sameDropDownMenu = new Select(driver.findElement(By.xpath((xpathToDropdownMenu)))); + sameDropDownMenu.selectByVisibleText("1"); + waitForParagraph(1, "FINISHED"); + collector.checkThat("If 'RunOnSelectionChange' is false, the paragraph result won't be updated even if we select any options in the dropdown menu ", + driver.findElement(By.xpath(xpathToResultText)).getText(), + CoreMatchers.equalTo("My selection is 2")); + + // run paragraph manually by pressing ENTER + driver.findElement(By.xpath(xpathToDropdownMenu)).sendKeys(Keys.ENTER); + waitForParagraph(1, "FINISHED"); + collector.checkThat("Even if 'RunOnSelectionChange' is set as false, still can run the paragraph by pressing ENTER ", + driver.findElement(By.xpath(xpathToResultText)).getText(), + CoreMatchers.equalTo("My selection is 1")); + } catch (Exception e) { - handleException("Exception in ParagraphActionsIT while testRunOnSelectionButton ", e); + handleException("Exception in ParagraphActionsIT while testRunOnSelectionChange ", e); } }