-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
β
: convert SeleniumIT to Cucumber tests
- Loading branch information
Showing
13 changed files
with
208 additions
and
170 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Feature: Basic Navigation | ||
|
||
Background: | ||
Given I go on the Gaia login page | ||
# And Percy takes a snapshot named 'Login Page' | ||
And I login with user 'admin' and password 'admin123' | ||
|
||
Scenario: View Dashboard | ||
When I arrive on the Dashboard page | ||
Then Percy takes a snapshot named 'Dashboard' | ||
|
||
Scenario: View modules | ||
When I go on the modules page | ||
Then Percy takes a snapshot named 'Modules' | ||
|
||
Scenario: View module details | ||
When I go on the module 'e01f9925-a559-45a2-8a55-f93dc434c676' page | ||
Then Percy takes a snapshot named 'Module Details' | ||
|
||
Scenario: View stack details | ||
When I go on the stack 'de28a01f-257a-448d-8e1b-00e4e3a41db2' page | ||
Then Percy takes a snapshot named 'Stack Details' | ||
|
||
Scenario: View job details | ||
When I go on the job '5e856dc7-6bed-465f-abf1-02980206ab2a' for stack 'de28a01f-257a-448d-8e1b-00e4e3a41db2' page | ||
Then Percy takes a snapshot named 'Job Details' |
43 changes: 43 additions & 0 deletions
43
src/test/java/io/gaia_app/e2e/CucumberContextConfiguration.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,43 @@ | ||
package io.gaia_app.e2e; | ||
|
||
import io.cucumber.java.After; | ||
import io.cucumber.java.Before; | ||
import io.gaia_app.e2e.stepDefs.StepDefs; | ||
import io.gaia_app.test.SharedMongoContainerTest; | ||
import org.openqa.selenium.Dimension; | ||
import org.openqa.selenium.firefox.FirefoxDriver; | ||
import org.openqa.selenium.firefox.FirefoxOptions; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | ||
public class CucumberContextConfiguration extends SharedMongoContainerTest { | ||
|
||
@Before | ||
public void setup_cucumber_spring_context() { | ||
FirefoxOptions options = new FirefoxOptions(); | ||
options.addArguments("-headless"); | ||
|
||
FirefoxDriver firefoxDriver = new FirefoxDriver(options); | ||
firefoxDriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); | ||
firefoxDriver.manage().window().setSize(new Dimension(1280,800)); | ||
|
||
StepDefs.driver = firefoxDriver; | ||
|
||
mongo.emptyDatabase(); | ||
mongo.runScript("src/test/resources/db/00_team.js"); | ||
mongo.runScript("src/test/resources/db/10_user.js"); | ||
mongo.runScript("src/test/resources/db/20_module.js"); | ||
mongo.runScript("src/test/resources/db/30_stack.js"); | ||
mongo.runScript("src/test/resources/db/40_job.js"); | ||
mongo.runScript("src/test/resources/db/50_step.js"); | ||
mongo.runScript("src/test/resources/db/60_terraformState.js"); | ||
} | ||
|
||
@After | ||
public void tearDown(){ | ||
StepDefs.driver.close(); | ||
} | ||
|
||
} |
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,13 @@ | ||
package io.gaia_app.e2e; | ||
|
||
import io.cucumber.junit.Cucumber; | ||
import io.cucumber.junit.CucumberOptions; | ||
import org.junit.jupiter.api.Tag; | ||
import org.junit.runner.RunWith; | ||
|
||
@RunWith(Cucumber.class) | ||
@CucumberOptions(plugin = "pretty", features = "src/test/features") | ||
@Tag("e2e") | ||
public class CucumberIT { | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
4 changes: 1 addition & 3 deletions
4
...est/java/io/gaia_app/e2e/DashboardPage.kt β ...va/io/gaia_app/e2e/pages/DashboardPage.kt
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
2 changes: 1 addition & 1 deletion
2
src/test/java/io/gaia_app/e2e/JobPage.kt β ...est/java/io/gaia_app/e2e/pages/JobPage.kt
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
2 changes: 1 addition & 1 deletion
2
src/test/java/io/gaia_app/e2e/#Page.kt β ...t/java/io/gaia_app/e2e/pages/#Page.kt
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
2 changes: 1 addition & 1 deletion
2
src/test/java/io/gaia_app/e2e/ModulePage.kt β .../java/io/gaia_app/e2e/pages/ModulePage.kt
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
2 changes: 1 addition & 1 deletion
2
src/test/java/io/gaia_app/e2e/ModulesPage.kt β ...java/io/gaia_app/e2e/pages/ModulesPage.kt
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
2 changes: 1 addition & 1 deletion
2
src/test/java/io/gaia_app/e2e/StackPage.kt β ...t/java/io/gaia_app/e2e/pages/StackPage.kt
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
91 changes: 91 additions & 0 deletions
91
src/test/java/io/gaia_app/e2e/stepDefs/ModuleStepDefs.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,91 @@ | ||
package io.gaia_app.e2e.stepDefs; | ||
|
||
import io.cucumber.java.en.Given; | ||
import io.cucumber.java.en.Then; | ||
import io.cucumber.java.en.When; | ||
import io.gaia_app.e2e.pages.*; | ||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.support.PageFactory; | ||
import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class ModuleStepDefs extends StepDefs { | ||
|
||
@Given("I go on the Gaia login page") | ||
public void i_go_on_the_gaia_login_page() { | ||
driver.get(baseUrl()); | ||
|
||
var page = new LoginPage(driver); | ||
PageFactory.initElements(new AjaxElementLocatorFactory(driver, 10), page); | ||
} | ||
|
||
@Given("I login with user {string} and password {string}") | ||
public void i_login_onto_Gaia_with_user_and_password(String login, String password) { | ||
driver.get(baseUrl()); | ||
|
||
// print html here ! | ||
System.out.println(driver.findElement(By.tagName("body")).getAttribute("outerHTML")); | ||
|
||
var page = new LoginPage(driver); | ||
PageFactory.initElements(new AjaxElementLocatorFactory(driver, 10), page); | ||
|
||
page.login(login, password); | ||
} | ||
|
||
@Then("I arrive on the Dashboard page") | ||
public void i_arrive_on_the_dashboard_page() { | ||
var page = new DashboardPage(driver); | ||
PageFactory.initElements(new AjaxElementLocatorFactory(driver, 10), page); | ||
page.waitForPageLoaded(); | ||
|
||
assertEquals(3, page.modulesCount()); | ||
assertEquals(1, page.stacksCount()); | ||
assertEquals(0, page.stacksToUpdateCount()); | ||
} | ||
|
||
@When("I go on the modules page") | ||
public void i_go_on_the_modules_page() { | ||
driver.get(baseUrl()+"/modules"); | ||
|
||
var page = new ModulesPage(driver); | ||
PageFactory.initElements(new AjaxElementLocatorFactory(driver, 10), page); | ||
page.waitForPageLoaded(); | ||
|
||
assertEquals(3, page.modulesCount()); | ||
} | ||
|
||
@When("I go on the module {string} page") | ||
public void iGoOnTheModulePage(String moduleId) { | ||
driver.get(baseUrl()+"/modules/" + moduleId); | ||
|
||
var page = new ModulePage(driver); | ||
PageFactory.initElements(new AjaxElementLocatorFactory(driver, 10), page); | ||
|
||
assertThat(page.moduleName()).isEqualTo("terraform-docker-mongo"); | ||
assertThat(page.moduleDescription()).contains("A sample terraform"); | ||
assertThat(page.terraformImageTag()).isEqualTo("0.11.14"); | ||
} | ||
|
||
@When("I go on the stack {string} page") | ||
public void iGoOnTheStackPage(String stackId) { | ||
driver.get(baseUrl()+"/stacks/"+stackId+"/edit"); | ||
|
||
var page = new StackPage(driver); | ||
PageFactory.initElements(new AjaxElementLocatorFactory(driver, 10), page); | ||
|
||
assertThat(page.stackName()).isEqualTo("local-mongo"); | ||
} | ||
|
||
@When("I go on the job {string} for stack {string} page") | ||
public void iGoOnTheJobForStackPage(String jobId, String stackId) { | ||
driver.get(baseUrl()+"/stacks/"+stackId+"/jobs/"+jobId); | ||
|
||
var page = new JobPage(driver); | ||
PageFactory.initElements(new AjaxElementLocatorFactory(driver, 10), page); | ||
|
||
assertThat(page.jobDetailTitle()).isEqualTo("Job " + jobId); | ||
} | ||
|
||
} |
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,12 @@ | ||
package io.gaia_app.e2e.stepDefs; | ||
|
||
import io.cucumber.java.en.Then; | ||
import io.percy.selenium.Percy; | ||
|
||
public class PercyStepDef extends StepDefs{ | ||
|
||
@Then("Percy takes a snapshot named {string}") | ||
public void percyTakesASnapshotNamedDashboardPage(String snapshotName) { | ||
new Percy(driver).snapshot(snapshotName); | ||
} | ||
} |
Oops, something went wrong.