forked from swisspost/gateleen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
swisspost#162: implemented as cucumber test
- Loading branch information
roggerj
committed
Sep 11, 2017
1 parent
90313a1
commit e66c245
Showing
7 changed files
with
131 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
gateleen-test/src/test/java/org/swisspush/gateleen/hookjs/HookJsSteps.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* ------------------------------------------------------------------------------------------------ | ||
* Copyright 2014 by Swiss Post, Information Technology Services | ||
* ------------------------------------------------------------------------------------------------ | ||
* $Id$ | ||
* ------------------------------------------------------------------------------------------------ | ||
*/ | ||
|
||
package org.swisspush.gateleen.hookjs; | ||
|
||
import com.jayway.awaitility.Duration; | ||
import cucumber.api.java.After; | ||
import cucumber.api.java.en.And; | ||
import cucumber.api.java.en.Given; | ||
import cucumber.api.java.en.Then; | ||
import cucumber.api.java.en.When; | ||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.WebElement; | ||
import org.openqa.selenium.chrome.ChromeDriver; | ||
|
||
import static com.jayway.awaitility.Awaitility.given; | ||
import static org.hamcrest.core.IsEqual.equalTo; | ||
|
||
public class HookJsSteps { | ||
|
||
private static WebDriver webDriver; | ||
|
||
@Given("^Chrome has been started$") | ||
public void chromeHasBeenStarted() throws Throwable { | ||
System.setProperty("sel_chrome_driver", "/home/jonas/work/jrepo-local/tools/chromedrivers/chromedriver2-32"); | ||
System.setProperty("webdriver.chrome.driver", System.getProperty("sel_chrome_driver")); | ||
webDriver = new ChromeDriver(); | ||
} | ||
|
||
@And("^the hook-js UI is displayed$") | ||
public void theHookJsUIIsDisplayed() throws Throwable { | ||
webDriver.get("http://localhost:7012/playground/hooktest.html"); | ||
// TODO: Check that page really is displayed. | ||
} | ||
|
||
@When("^we click on the button \"([^\"]*)\"$") | ||
public void weClickOnTheButton(String button) throws Throwable { | ||
|
||
String buttonId; | ||
|
||
switch (button) { | ||
case "Place Single Hook": | ||
buttonId = "psh"; | ||
break; | ||
|
||
case "PUT Single": | ||
buttonId = "ps"; | ||
break; | ||
|
||
default: | ||
buttonId = button; | ||
break; | ||
} | ||
|
||
WebElement webButton = webDriver.findElement(By.id(buttonId)); | ||
webButton.click(); | ||
} | ||
|
||
@Then("^we see the message \"([^\"]*)\" on position (\\d+)$") | ||
public void weSeeTheMessageOnPosition(String message, int indexOfMessage) throws Throwable { | ||
given().await().atMost(Duration.TWO_SECONDS).until(() -> | ||
webDriver.findElement(By.xpath("//*[@id=\"hjsm\"]/li[" + indexOfMessage + "]")).getText(), | ||
equalTo(message)); | ||
} | ||
|
||
@After | ||
public static void quitBrowser(){ | ||
webDriver.quit(); | ||
} | ||
|
||
} |
66 changes: 0 additions & 66 deletions
66
gateleen-test/src/test/java/org/swisspush/gateleen/hookjs/HookJsUITest.java
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
gateleen-test/src/test/java/org/swisspush/gateleen/hookjs/RunCucumberTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* ------------------------------------------------------------------------------------------------ | ||
* Copyright 2014 by Swiss Post, Information Technology Services | ||
* ------------------------------------------------------------------------------------------------ | ||
* $Id$ | ||
* ------------------------------------------------------------------------------------------------ | ||
*/ | ||
|
||
package org.swisspush.gateleen.hookjs; | ||
|
||
import cucumber.api.CucumberOptions; | ||
import cucumber.api.junit.Cucumber; | ||
import org.junit.runner.RunWith; | ||
|
||
@RunWith(Cucumber.class) | ||
@CucumberOptions(plugin = {"pretty"}) | ||
public class RunCucumberTests { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
gateleen-test/src/test/resources/org/swisspush/gateleen/hookjs/hook-js-ui-test.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Feature: hook-js UI Test | ||
|
||
Background: | ||
Given Chrome has been started | ||
And the hook-js UI is displayed | ||
|
||
Scenario: Place a sinlge hook and put single | ||
When we click on the button "Place Single Hook" | ||
Then we see the message "Installing listener 1" on position 1 | ||
When we click on the button "PUT Single" | ||
Then we see the message "Listener 1 received:<Message 1>" on position 2 |