Skip to content

Commit

Permalink
test: contributor list page
Browse files Browse the repository at this point in the history
  • Loading branch information
jo-elimu committed Sep 29, 2024
1 parent d902197 commit 839dc89
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 10 deletions.
10 changes: 5 additions & 5 deletions TEST.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ First, launch the webapp on localhost:

Then, in another terminal window run all the regression tests against the REST API:

mvn verify -P regression-testing-rest
mvn verify -P regression-test-rest

> [!TIP]
> If you want to run the tests against another URL, set the `base.url` system property:
>
> mvn verify -P regression-testing-rest -D base.url=https://eng.elimu.ai
> mvn verify -P regression-test-rest -D base.url=https://eng.elimu.ai
#### UI

Expand All @@ -44,18 +44,18 @@ First, launch the webapp on localhost:

Then, in another terminal window run all the regression tests against the UI:

mvn verify -P regression-testing-ui
mvn verify -P regression-test-ui

> [!TIP]
> If you want to run the tests against another URL, set the `base.url` system property:
>
> mvn verify -P regression-testing-ui -D base.url=https://eng.elimu.ai
> mvn verify -P regression-test-ui -D base.url=https://eng.elimu.ai
##### Headless 😶‍🌫️

If you don't want the automated test software to open browser windows, you can disable that by setting the `headless` system property:

mvn verify -P regression-testing-ui -D headless=true
mvn verify -P regression-test-ui -D headless=true

![](https://private-user-images.githubusercontent.com/1451036/361187317-35e99a19-f42d-4934-a0ba-f3d1e06ed6f6.png)

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/selenium/WelcomePageTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void setUp() {
ChromeOptions chromeOptions = new ChromeOptions();

// Read "headless" property set on the command line:
// mvn clean verify -P regression-testing-ui -D headless=true
// mvn clean verify -P regression-test-ui -D headless=true
String headlessSystemProperty = System.getProperty("headless");
logger.info("headlessSystemProperty: \"" + headlessSystemProperty + "\"");
if ("true".equals(headlessSystemProperty)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void setUp() {
ChromeOptions chromeOptions = new ChromeOptions();

// Read "headless" property set on the command line:
// mvn clean verify -P regression-testing-ui -D headless=true
// mvn clean verify -P regression-test-ui -D headless=true
String headlessSystemProperty = System.getProperty("headless");
logger.info("headlessSystemProperty: \"" + headlessSystemProperty + "\"");
if ("true".equals(headlessSystemProperty)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void setUp() {
ChromeOptions chromeOptions = new ChromeOptions();

// Read "headless" property set on the command line:
// mvn clean verify -P regression-testing-ui -D headless=true
// mvn clean verify -P regression-test-ui -D headless=true
String headlessSystemProperty = System.getProperty("headless");
logger.info("headlessSystemProperty: \"" + headlessSystemProperty + "\"");
if ("true".equals(headlessSystemProperty)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void setUp() {
ChromeOptions chromeOptions = new ChromeOptions();

// Read "headless" property set on the command line:
// mvn clean verify -P regression-testing-ui -D headless=true
// mvn clean verify -P regression-test-ui -D headless=true
String headlessSystemProperty = System.getProperty("headless");
logger.info("headlessSystemProperty: \"" + headlessSystemProperty + "\"");
if ("true".equals(headlessSystemProperty)) {
Expand Down
19 changes: 19 additions & 0 deletions src/test/java/selenium/contributor/ContributorListPage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package selenium.contributor;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;

import selenium.util.ErrorHelper;

public class ContributorListPage {

private WebDriver driver;

public ContributorListPage(WebDriver driver) {
this.driver = driver;

driver.findElement(By.id("contributorListPage"));

ErrorHelper.verifyNoScriptOrMarkupError(driver);
}
}
52 changes: 52 additions & 0 deletions src/test/java/selenium/contributor/ContributorListPageTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package selenium.contributor;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

import selenium.util.DomainHelper;

public class ContributorListPageTest {

private final Logger logger = LogManager.getLogger();

private WebDriver driver;

@BeforeEach
public void setUp() {
logger.info("setUp");

ChromeOptions chromeOptions = new ChromeOptions();

// Read "headless" property set on the command line:
// mvn clean verify -P regression-test-ui -D headless=true
String headlessSystemProperty = System.getProperty("headless");
logger.info("headlessSystemProperty: \"" + headlessSystemProperty + "\"");
if ("true".equals(headlessSystemProperty)) {
chromeOptions.addArguments("headless");
}

driver = new ChromeDriver(chromeOptions);

driver.get(DomainHelper.getBaseUrl() + "/contributor/list");
}

@AfterEach
public void tearDown() {
logger.info("tearDown");

driver.quit();
}

@Test
public void testContributorListPage() {
logger.info("testContributorListPage");

ContributorListPage contributorListPage = new ContributorListPage(driver);
}
}
2 changes: 1 addition & 1 deletion src/test/java/selenium/util/DomainHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static String getBaseUrl() {
String baseUrl = "http://localhost:8080/webapp";

// Read "base.url" property set on the command line:
// mvn clean verify -P regression-testing-rest -D base.url=https://eng.test.elimu.ai
// mvn clean verify -P regression-test-rest -D base.url=https://eng.test.elimu.ai
String baseUrlSystemProperty = System.getProperty("base.url");
logger.info("baseUrlSystemProperty: \"" + baseUrlSystemProperty + "\"");
if (StringUtils.isNotBlank(baseUrlSystemProperty)) {
Expand Down

0 comments on commit 839dc89

Please sign in to comment.