From b19b3a40ada3650b434394d9a9e2885798c6b623 Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Wed, 29 Apr 2020 10:49:05 +0200 Subject: [PATCH] KEYCLOAK-14004 fixed the test --- .../testsuite/ui/account2/MyResourcesTest.java | 13 ++++++++++++- .../ui/account2/page/MyResourcesPage.java | 14 ++++++-------- .../account/messages/messages_en.properties | 2 +- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/testsuite/integration-arquillian/tests/other/base-ui/src/test/java/org/keycloak/testsuite/ui/account2/MyResourcesTest.java b/testsuite/integration-arquillian/tests/other/base-ui/src/test/java/org/keycloak/testsuite/ui/account2/MyResourcesTest.java index 958d27e96b..5724d36a24 100644 --- a/testsuite/integration-arquillian/tests/other/base-ui/src/test/java/org/keycloak/testsuite/ui/account2/MyResourcesTest.java +++ b/testsuite/integration-arquillian/tests/other/base-ui/src/test/java/org/keycloak/testsuite/ui/account2/MyResourcesTest.java @@ -32,9 +32,14 @@ import java.util.List; import java.util.Map; import static java.util.Collections.singletonList; +import static org.hamcrest.core.StringEndsWith.endsWith; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; import static org.keycloak.representations.idm.CredentialRepresentation.PASSWORD; import static org.keycloak.testsuite.auth.page.AuthRealm.TEST; +import static org.keycloak.testsuite.util.WaitUtils.pause; +import static org.keycloak.testsuite.util.WaitUtils.waitForModalFadeIn; +import static org.keycloak.testsuite.util.WaitUtils.waitForModalFadeOut; public class MyResourcesTest extends AbstractAccountTest { private static final String[] userNames = new String[]{"alice", "jdoe"}; @@ -136,11 +141,14 @@ public class MyResourcesTest extends AbstractAccountTest { final int row = 2; myResourcesPage.clickExpandButton(row); + pause(2000); assertEquals("Resource is shared with alice.", myResourcesPage.getSharedWith(row)); myResourcesPage.clickEditButton(row); + waitForModalFadeIn(); myResourcesPage.removeAllPermissions(); + waitForModalFadeOut(); assertEquals("This resource is not shared.", myResourcesPage.getSharedWith(row)); } @@ -153,13 +161,16 @@ public class MyResourcesTest extends AbstractAccountTest { final int row = 3; myResourcesPage.clickExpandButton(row); + pause(2000); assertEquals("Resource is shared with jdoe.", myResourcesPage.getSharedWith(row)); myResourcesPage.clickShareButton(row); + waitForModalFadeIn(); myResourcesPage.createShare("alice"); + waitForModalFadeOut(); - assertEquals("Resource is shared with alice and 1 other users.", myResourcesPage.getSharedWith(row)); + assertThat(myResourcesPage.getSharedWith(row), endsWith("and 1 other users.")); } private AuthzClient createAuthzClient(ClientRepresentation client) { diff --git a/testsuite/integration-arquillian/tests/other/base-ui/src/test/java/org/keycloak/testsuite/ui/account2/page/MyResourcesPage.java b/testsuite/integration-arquillian/tests/other/base-ui/src/test/java/org/keycloak/testsuite/ui/account2/page/MyResourcesPage.java index cd780f9ac8..a8a2db77c4 100644 --- a/testsuite/integration-arquillian/tests/other/base-ui/src/test/java/org/keycloak/testsuite/ui/account2/page/MyResourcesPage.java +++ b/testsuite/integration-arquillian/tests/other/base-ui/src/test/java/org/keycloak/testsuite/ui/account2/page/MyResourcesPage.java @@ -30,19 +30,17 @@ public class MyResourcesPage extends AbstractLoggedInPage { } public void clickShareButton(int row) { - //first row is the header - final WebElement webElement = resourcesList.get(row + 1); + final WebElement webElement = driver.findElement(By.id("ex-expand" + row)); - //first button is the toggle second is share - webElement.findElements(By.tagName("button")).get(1).click(); + //first button is share + webElement.findElements(By.tagName("button")).get(0).click(); } public void clickEditButton(int row) { - //first row is the header - final WebElement webElement = resourcesList.get(row + 1); + final WebElement webElement = driver.findElement(By.id("ex-expand" + row)); - //first button is the toggle second is share 3rd is the edit button - webElement.findElements(By.tagName("button")).get(2).click(); + //first button share 2rd is the edit button + webElement.findElements(By.tagName("button")).get(1).click(); } public void createShare(String userName) { diff --git a/themes/src/main/resources/theme/keycloak-preview/account/messages/messages_en.properties b/themes/src/main/resources/theme/keycloak-preview/account/messages/messages_en.properties index e3a92c9daf..6ef8dc571a 100644 --- a/themes/src/main/resources/theme/keycloak-preview/account/messages/messages_en.properties +++ b/themes/src/main/resources/theme/keycloak-preview/account/messages/messages_en.properties @@ -37,7 +37,7 @@ nextPage=Next previousPage=Previous firstPage=First Page resourceSharedWith=Resource is shared with {0} -and= and {0} other users +and=\ and {0} other users add=Add shareSuccess=Resource successfully shared. resourceAlreadyShared=Resource is already shared with this user.