Skip to content

Commit

Permalink
waitAjaxMinLoadAnimation
Browse files Browse the repository at this point in the history
  • Loading branch information
jepsar committed Jan 7, 2024
1 parent 9d962c9 commit 2df5406
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class ConfirmDialog001Test extends AbstractPrimePageTest {
void showDialog(Page page) {
// Arrange
ConfirmDialog dialog = page.dialog;
noAjaxMinLoadAnimation();
assertFalse(dialog.isVisible());

// Act
Expand All @@ -65,7 +64,6 @@ void showDialog(Page page) {
void showWidget(Page page) {
// Arrange
ConfirmDialog dialog = page.dialog;
noAjaxMinLoadAnimation();

// Act
dialog.show();
Expand All @@ -80,7 +78,6 @@ void showWidget(Page page) {
void hideWidget(Page page) {
// Arrange
ConfirmDialog dialog = page.dialog;
noAjaxMinLoadAnimation();
dialog.show();
assertTrue(dialog.isVisible());

Expand All @@ -97,7 +94,6 @@ void hideWidget(Page page) {
void confirmNo(Page page) {
// Arrange
ConfirmDialog dialog = page.dialog;
noAjaxMinLoadAnimation();
assertFalse(dialog.isVisible());
page.confirm.click();

Expand All @@ -115,7 +111,6 @@ void confirmNo(Page page) {
void confirmYes(Page page) {
// Arrange
ConfirmDialog dialog = page.dialog;
noAjaxMinLoadAnimation();
page.confirm.click();
assertTrue(dialog.isVisible());

Expand All @@ -133,7 +128,6 @@ void confirmYes(Page page) {
void deleteNo(Page page) {
// Arrange
ConfirmDialog dialog = page.dialog;
noAjaxMinLoadAnimation();
assertFalse(dialog.isVisible());
page.delete.click();

Expand All @@ -151,7 +145,6 @@ void deleteNo(Page page) {
void deleteYes(Page page) {
// Arrange
ConfirmDialog dialog = page.dialog;
noAjaxMinLoadAnimation();
assertFalse(dialog.isVisible());
page.delete.click();

Expand Down Expand Up @@ -216,6 +209,7 @@ private void assertDialog(Page page, boolean visible) {
}
}
else {
waitAjaxMinLoadAnimation();
assertClickable(page.confirm);
assertClickable(page.delete);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class ConfirmDialog002Test extends AbstractPrimePageTest {
void showDialog(Page page) {
// Arrange
ConfirmDialog dialog = page.dialog;
noAjaxMinLoadAnimation();
assertFalse(dialog.isVisible());

// Act
Expand All @@ -65,7 +64,6 @@ void showDialog(Page page) {
void showWidget(Page page) {
// Arrange
ConfirmDialog dialog = page.dialog;
noAjaxMinLoadAnimation();

// Act
dialog.show();
Expand All @@ -80,7 +78,6 @@ void showWidget(Page page) {
void hideWidget(Page page) {
// Arrange
ConfirmDialog dialog = page.dialog;
noAjaxMinLoadAnimation();
dialog.show();
assertTrue(dialog.isVisible());

Expand All @@ -97,7 +94,6 @@ void hideWidget(Page page) {
void confirmNo(Page page) {
// Arrange
ConfirmDialog dialog = page.dialog;
noAjaxMinLoadAnimation();
assertFalse(dialog.isVisible());
page.confirm.click();

Expand All @@ -115,7 +111,6 @@ void confirmNo(Page page) {
void confirmYes(Page page) {
// Arrange
ConfirmDialog dialog = page.dialog;
noAjaxMinLoadAnimation();
page.confirm.click();
assertTrue(dialog.isVisible());

Expand All @@ -133,7 +128,6 @@ void confirmYes(Page page) {
void deleteNo(Page page) {
// Arrange
ConfirmDialog dialog = page.dialog;
noAjaxMinLoadAnimation();
assertFalse(dialog.isVisible());
page.delete.click();

Expand All @@ -151,7 +145,6 @@ void deleteNo(Page page) {
void deleteYes(Page page) {
// Arrange
ConfirmDialog dialog = page.dialog;
noAjaxMinLoadAnimation();
assertFalse(dialog.isVisible());
page.delete.click();

Expand Down Expand Up @@ -216,6 +209,7 @@ private void assertDialog(Page page, boolean visible) {
}
}
else {
waitAjaxMinLoadAnimation();
assertClickable(page.confirm);
assertClickable(page.delete);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
import org.primefaces.selenium.spi.WebDriverProvider;

import java.lang.reflect.InvocationTargetException;
import java.time.Duration;
import java.time.temporal.ChronoUnit;

import static org.junit.jupiter.api.Assertions.*;

Expand Down Expand Up @@ -325,6 +327,13 @@ protected void setAjaxMinLoadAnimation(int milliseconds) {
PrimeSelenium.executeScript("PrimeFaces.ajax.minLoadAnimation = " + milliseconds + ";");
}

/**
* Waits for the default minimal Ajax load animation duration.
*/
protected void waitAjaxMinLoadAnimation() {
getWebDriver().manage().timeouts().implicitlyWait(Duration.of(500, ChronoUnit.MILLIS));
}

/**
* <p>
* Similar to <a href="http://www.w3.org/TR/xpath/#function-normalize-space">http://www.w3.org/TR/xpath/#function-normalize -space</a>
Expand Down

0 comments on commit 2df5406

Please sign in to comment.