Skip to content

Commit

Permalink
Adds test to verify latest release for modules page.
Browse files Browse the repository at this point in the history
  • Loading branch information
hemanik committed Oct 26, 2017
1 parent 06d2aed commit 630a3d6
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void should_navigate_to_documentation_page_if_present() throws Exception
}

@Test
public void should_verify_module_page_lists_the_latest_project_version() throws Exception {
public void should_verify_individual_module_page_lists_the_latest_project_version() throws Exception {
mainPage.menu()
.navigate().to("Modules");

Expand All @@ -112,4 +112,13 @@ public void should_verify_module_page_lists_the_latest_project_version() throws
fetchedModulePage.verify().hasLatestRelease();
}

@Test
public void should_verify_modules_page_lists_modules_with_latest_project_version() throws Exception {
mainPage.menu()
.navigate().to("Modules");

modulesPage.navigationList()
.verify()
.containsEntriesWithLatestVersion("Core", "Smart Testing");
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
package org.arquillian.tests.pom.fragmentObjects;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import org.arquillian.tests.utilities.GitHubProjectVersionExtractor;
import org.arquillian.tests.utilities.PageNavigator;
import org.jboss.arquillian.drone.api.annotation.Drone;
import org.jboss.arquillian.graphene.Graphene;
import org.jboss.arquillian.graphene.fragment.Root;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

import static org.assertj.core.api.Assertions.assertThat;

public class NavigationListFragment {

@Drone
private WebDriver driver;

@Root
private WebElement navListRoot;

Expand All @@ -23,20 +31,43 @@ public class NavigationListVerifier {
public NavigationListVerifier containsEntries(String... expectedItems) {
final List<WebElement> fragmentItems = navListRoot.findElements(By.cssSelector("li a"));
List<String> fragmentItemsTitles =
fragmentItems.stream().map(list -> formatTitle(list.getText())).collect(Collectors.toList());
fragmentItems.stream().map(list -> formatTitle(list.getText())[0].trim()).collect(Collectors.toList());

assertThat(fragmentItemsTitles).contains(expectedItems);

return this;
}

private String formatTitle(String title) {
String version = "SNAPSHOT";
if (title.contains(version)) {
String[] titleArray = title.split(version);
return titleArray[0].trim();
public NavigationListVerifier containsEntriesWithLatestVersion(String... expectedItems) {
Arrays.stream(expectedItems).forEach(expectedItem -> {
List<WebElement> fragmentItems = navListRoot.findElements(By.cssSelector("li a"));
fragmentItems.stream()
.filter(list -> formatTitle(list.getText())[0].trim().contains(expectedItem))
.forEach(list -> {
String latestVersion = formatTitle(list.getText())[1].trim();
String project = getProjectRepo(list);
assertThat(latestVersion)
.isEqualTo(new GitHubProjectVersionExtractor(project).getLatestReleaseFromGitHub());
});
}
);
return this;
}

private String getProjectRepo(WebElement list) {
final By xpath = By.xpath(".//dt[contains(text(),'Web URL')]/following-sibling::dd[1]");
list.click();
Graphene.waitModel().until().element(xpath).is().visible();
String project = driver.findElement(xpath).getText();
driver.navigate().to("http://arquillian.org/modules/");
return project;
}

private String[] formatTitle(String title) {
if (title.contains("SNAPSHOT")) {
return title.split("((?<=SNAPSHOT)|(?=SNAPSHOT))");
}
return title.substring(0, (title.indexOf("–") - 1));
return title.split("–");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ public IndividualModulePageVerifier hasDocumentation(Boolean value) {

public IndividualModulePageVerifier hasLatestRelease() {
String latestRelease = contentRoot.findElement(By.className("label")).getText();
String project = contentRoot.findElement(By.cssSelector("div div.span3 div dl dd:nth-child(8) a")).getText();
String project = contentRoot
.findElement(By.xpath(".//dt[contains(text(),'Web URL')]/following-sibling::dd[1]")).getText();

assertThat(latestRelease)
.isEqualTo(new GitHubProjectVersionExtractor(project).getLatestReleaseFromGitHub());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

import static org.jboss.arquillian.graphene.Graphene.waitGui;

public class PageNavigator {

private WebElement fragmentRoot;
Expand Down

0 comments on commit 630a3d6

Please sign in to comment.