-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
975e710
commit e792799
Showing
4 changed files
with
126 additions
and
75 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
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
71 changes: 71 additions & 0 deletions
71
src/test/java/org/arquillian/tests/utilities/BlogVerifier.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,71 @@ | ||
package org.arquillian.tests.utilities; | ||
|
||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.NoSuchElementException; | ||
import org.openqa.selenium.WebElement; | ||
|
||
import java.util.List; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class BlogVerifier { | ||
|
||
public static void hasTitle(WebElement blog) { | ||
WebElement blogTitle = getBlogTitle(blog); | ||
assertThat(blogTitle.isDisplayed()).isTrue(); | ||
} | ||
|
||
public static void hasReleaseNotes(WebElement item) { | ||
if (hasTypeRelease(item)) { | ||
try { | ||
WebElement releaseNoteTitle = | ||
item.findElement(By.xpath(".//h3[contains(text(),'Release notes and resolved issues')]")); | ||
List<WebElement> releaseNoteContents = item.findElements(By.xpath(".//dl")); | ||
|
||
assertThat(releaseNoteTitle.isDisplayed() && releaseNoteContents.stream() | ||
.allMatch(WebElement::isDisplayed)).isTrue(); | ||
|
||
} catch (NoSuchElementException e) { | ||
throw new NoSuchElementException( | ||
"Missing release notes for blog post titled: " + getBlogTitle(item).getText() + ".\n" + | ||
"If the release was performed manually, this happen because we forgot to: \n" + | ||
"- close the milestone on GitHub or release version on JIRA\n" + | ||
"- push tag to the upstream repo after releasing to Maven Central (git push origin --tags)"); | ||
} | ||
} | ||
} | ||
|
||
public static void haveAnnouncementBanner(WebElement item) { | ||
try { | ||
WebElement announcementBanner = item.findElement(By.partialLinkText("Check our latest announcement")); | ||
assertThat(announcementBanner.isDisplayed()).isTrue(); | ||
} catch (NoSuchElementException e) { | ||
// Ignore if no announcement banner | ||
} | ||
} | ||
|
||
public static void doesNotHaveAnnouncementBanner(WebElement item) { | ||
WebElement announcementBanner = null; | ||
try { | ||
announcementBanner = item.findElement(By.partialLinkText("Check our latest announcement")); | ||
assertThat(announcementBanner.isDisplayed()).isFalse(); | ||
} catch (NoSuchElementException e) { | ||
assertThat(announcementBanner).isNull(); | ||
} | ||
} | ||
|
||
private static boolean hasTypeRelease(WebElement item) { | ||
try { | ||
item.findElement(By.linkText("release")); | ||
return true; | ||
} catch (NoSuchElementException e) { | ||
return false; | ||
} | ||
} | ||
|
||
private static WebElement getBlogTitle(WebElement blog) { | ||
return blog.findElement(By.cssSelector("[class='title'] a")); | ||
} | ||
} | ||
|
||
|