Skip to content

Commit

Permalink
Use WebAssert to validate text
Browse files Browse the repository at this point in the history
  • Loading branch information
strangelookingnerd committed Sep 13, 2024
1 parent 7ee22e2 commit 4671161
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/test/java/jenkins/plugins/foldericon/UITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.time.Duration;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.htmlunit.WebAssert;
import org.htmlunit.html.HtmlForm;
import org.htmlunit.html.HtmlOption;
import org.htmlunit.html.HtmlPage;
Expand All @@ -35,10 +36,9 @@ void testCustomFolderIconGlobalConfiguration(JenkinsRule r) throws Throwable {

try (JenkinsRule.WebClient webClient = r.createWebClient()) {
HtmlPage appearance = webClient.goTo("manage/appearance");
assertTrue(StringUtils.contains(appearance.getVisibleText(), "Custom Folder Icons"));
assertTrue(StringUtils.contains(
appearance.getVisibleText(),
"Disk usage of icons: " + FileUtils.byteCountToDisplaySize(file.length())));
WebAssert.assertTextPresent(appearance, "Custom Folder Icons");
WebAssert.assertTextPresent(
appearance, "Disk usage of icons: " + FileUtils.byteCountToDisplaySize(file.length()));

appearance.getElementsByTagName("input").stream()
.filter(input -> StringUtils.equals(input.getAttribute("value"), "Cleanup unused icons"))
Expand All @@ -54,8 +54,7 @@ void testCustomFolderIconGlobalConfiguration(JenkinsRule r) throws Throwable {
assertFalse(file.exists());

appearance = (HtmlPage) appearance.refresh();
assertTrue(StringUtils.contains(
appearance.getVisibleText(), "Disk usage of icons: " + FileUtils.byteCountToDisplaySize(0L)));
WebAssert.assertTextPresent(appearance, "Disk usage of icons: " + FileUtils.byteCountToDisplaySize(0L));
}
}

Expand Down

0 comments on commit 4671161

Please sign in to comment.