From 557a22968cf36ef67ec02971e3b93c785c5853ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Muzik=C3=A1=C5=99?= Date: Thu, 23 Feb 2023 12:35:08 +0100 Subject: [PATCH] Stabilize Account Console UI tests (#17243) Closes #17178 Closes #17102 Closes #17070 Closes #17045 Closes #17044 Closes #16875 Closes #16870 Closes #16715 Closes #16670 Closes #16646 Closes #16627 Closes #16620 --- .github/workflows/ci.yml | 10 ++-------- .../java/org/keycloak/testsuite/util/WaitUtils.java | 6 ++++-- .../testsuite/ui/account2/page/MyResourcesPage.java | 3 ++- .../testsuite/ui/account2/WelcomeScreenTest.java | 6 ++---- testsuite/integration-arquillian/tests/pom.xml | 2 +- 5 files changed, 11 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 55e81cd4c4..0e47982b93 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -477,23 +477,17 @@ jobs: timeout-minutes: 75 strategy: matrix: - browser: [firefox] # Chrome not working for now + browser: [chrome] fail-fast: false steps: - uses: actions/checkout@v3 - - name: Setup firefox - uses: browser-actions/setup-firefox@latest - with: - firefox-version: latest - - run: firefox --version - - id: integration-test-setup name: Integration test setup uses: ./.github/actions/integration-test-setup - name: Run Account Console IT - run: ./mvnw test -Dsurefire.rerunFailingTestsCount=${{ env.SUREFIRE_RERUN_FAILING_COUNT }} -nsu -B -Pauth-server-quarkus -Dtest=**.account2.**,!SigningInTest#passwordlessWebAuthnTest,!SigningInTest#twoFactorWebAuthnTest -Dbrowser=${{ matrix.browser }} -f testsuite/integration-arquillian/tests/other/base-ui/pom.xml | misc/log/trimmer.sh + run: ./mvnw test -Dsurefire.rerunFailingTestsCount=${{ env.SUREFIRE_RERUN_FAILING_COUNT }} -nsu -B -Pauth-server-quarkus -Dtest=**.account2.**,!SigningInTest#passwordlessWebAuthnTest,!SigningInTest#twoFactorWebAuthnTest -Dbrowser=${{ matrix.browser }} "-Dwebdriver.chrome.driver=$CHROMEWEBDRIVER/chromedriver" -f testsuite/integration-arquillian/tests/other/base-ui/pom.xml | misc/log/trimmer.sh - name: Upload JVM Heapdumps if: always() diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/WaitUtils.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/WaitUtils.java index 3c0fe337fc..7f11e9a062 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/WaitUtils.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/WaitUtils.java @@ -17,6 +17,8 @@ package org.keycloak.testsuite.util; import org.jboss.arquillian.graphene.wait.ElementBuilder; +import org.keycloak.common.Profile; +import org.keycloak.testsuite.ProfileAssume; import org.openqa.selenium.By; import org.openqa.selenium.TimeoutException; import org.openqa.selenium.WebDriver; @@ -51,7 +53,7 @@ public final class WaitUtils { public static final Integer PAGELOAD_TIMEOUT_MILLIS = Integer.parseInt(System.getProperty(PAGELOAD_TIMEOUT_PROP, "10000")); - public static final int IMPLICIT_ELEMENT_WAIT_MILLIS = 1500; // high value means more stable but slower tests; it needs to be balanced + public static final int IMPLICIT_ELEMENT_WAIT_MILLIS = 2000; // high value means more stable but slower tests; it needs to be balanced // Should be no longer necessary for finding elements since we have implicit wait public static ElementBuilder waitUntilElement(By by) { @@ -160,7 +162,7 @@ public final class WaitUtils { + "}"); } else if ( - currentUrl.matches("^[^\\/]+:\\/\\/[^\\/]+\\/auth\\/realms\\/[^\\/]+\\/account\\/.*#/.+$") // check for new Account Console URL + ProfileAssume.isFeatureEnabled(Profile.Feature.ACCOUNT2) && currentUrl.matches("^[^\\/]+:\\/\\/[^\\/]+\\/auth\\/realms\\/[^\\/]+\\/account\\/.*$") // check for new Account Console URL ) { pause(2000); // TODO rework this temporary workaround once KEYCLOAK-11201 and/or KEYCLOAK-8181 are fixed } diff --git a/testsuite/integration-arquillian/tests/other/base-ui/src/main/java/org/keycloak/testsuite/ui/account2/page/MyResourcesPage.java b/testsuite/integration-arquillian/tests/other/base-ui/src/main/java/org/keycloak/testsuite/ui/account2/page/MyResourcesPage.java index f863bcb324..9829e5b279 100644 --- a/testsuite/integration-arquillian/tests/other/base-ui/src/main/java/org/keycloak/testsuite/ui/account2/page/MyResourcesPage.java +++ b/testsuite/integration-arquillian/tests/other/base-ui/src/main/java/org/keycloak/testsuite/ui/account2/page/MyResourcesPage.java @@ -13,6 +13,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.jboss.arquillian.graphene.Graphene.waitGui; import static org.junit.Assert.assertEquals; +import static org.keycloak.testsuite.util.UIUtils.clickLink; public class MyResourcesPage extends AbstractLoggedInPage { @@ -32,7 +33,7 @@ public class MyResourcesPage extends AbstractLoggedInPage { } public void clickRefreshButton() { - refreshButton.click(); + clickLink(refreshButton); } public void clickExpandButton(int row) { diff --git a/testsuite/integration-arquillian/tests/other/base-ui/src/test/java/org/keycloak/testsuite/ui/account2/WelcomeScreenTest.java b/testsuite/integration-arquillian/tests/other/base-ui/src/test/java/org/keycloak/testsuite/ui/account2/WelcomeScreenTest.java index 150f5c107c..e4a81ea728 100644 --- a/testsuite/integration-arquillian/tests/other/base-ui/src/test/java/org/keycloak/testsuite/ui/account2/WelcomeScreenTest.java +++ b/testsuite/integration-arquillian/tests/other/base-ui/src/test/java/org/keycloak/testsuite/ui/account2/WelcomeScreenTest.java @@ -19,7 +19,6 @@ package org.keycloak.testsuite.ui.account2; import org.jboss.arquillian.graphene.page.Page; import org.junit.Test; -import org.keycloak.common.util.Retry; import org.keycloak.representations.idm.RealmRepresentation; import org.keycloak.testsuite.ui.account2.page.ApplicationsPage; import org.keycloak.testsuite.ui.account2.page.DeviceActivityPage; @@ -28,7 +27,6 @@ import org.keycloak.testsuite.ui.account2.page.MyResourcesPage; import org.keycloak.testsuite.ui.account2.page.PersonalInfoPage; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlStartsWithLoginUrlOf; /** @@ -143,10 +141,10 @@ public class WelcomeScreenTest extends AbstractAccountTest { // test my resources appeared accountWelcomeScreen.navigateTo(); - Retry.execute(() -> accountWelcomeScreen.assertMyResourcesCardVisible(true), 10, 500); + accountWelcomeScreen.assertMyResourcesCardVisible(true); accountWelcomeScreen.clickMyResourcesLink(); loginToAccount(); - Retry.execute(() -> myResourcesPage.assertCurrent(), 10, 500); + myResourcesPage.assertCurrent(); // no need to disable user managed access } } diff --git a/testsuite/integration-arquillian/tests/pom.xml b/testsuite/integration-arquillian/tests/pom.xml index 71b9dc9787..63457655e4 100644 --- a/testsuite/integration-arquillian/tests/pom.xml +++ b/testsuite/integration-arquillian/tests/pom.xml @@ -224,7 +224,7 @@ true - --headless + --headless --window-size=1920,1080