fixed UI tests broken by KEYCLOAK-1431

This commit is contained in:
Tomas Kyjovsky 2015-06-11 14:15:05 +02:00
parent 30359b51fa
commit 08f2b0dea9
3 changed files with 89 additions and 90 deletions

View file

@ -15,7 +15,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.keycloak.testsuite.ui.fragment;
import org.jboss.arquillian.drone.api.annotation.Drone;
@ -34,8 +33,8 @@ import org.openqa.selenium.WebElement;
*/
public class Navigation {
@Drone
private WebDriver driver;
@Drone
private WebDriver driver;
@FindByJQuery("a:contains('Settings')")
private WebElement settingsLink;
@ -55,7 +54,7 @@ public class Navigation {
@FindByJQuery("a:contains('Tokens')")
private WebElement tokensLink;
@FindByJQuery("a:contains('Sessions')")
@FindByJQuery("a:contains('Sessions')")
private WebElement sessionLink;
@FindByJQuery("a:contains('Security Defenses')")
@ -64,30 +63,30 @@ public class Navigation {
@FindByJQuery("a:contains('Events')")
private WebElement eventsLink;
@FindByJQuery("a:contains('Login')")
@FindByJQuery("a:contains('Login')")
private WebElement loginLink;
@FindByJQuery("a:contains('Themes')")
private WebElement themesLink;
@FindByJQuery("a:contains('Role Mappings')")
@FindByJQuery("a:contains('Role Mappings')")
private WebElement usersRoleMappings;
@FindByJQuery("a:contains('Add Realm')")
@FindByJQuery("a:contains('Add Realm')")
private WebElement addRealm;
@FindByJQuery("a:contains('Credentials')")
@FindByJQuery("a:contains('Credentials')")
private WebElement credentials;
@FindByJQuery("a:contains('Attributes')")
@FindByJQuery("a:contains('Attributes')")
private WebElement attributes;
@FindBy(css = "div h1")
private WebElement currentHeader;
public void selectRealm(String realmName) {
driver.findElement(By.linkText(realmName)).click();
}
public void selectRealm(String realmName) {
driver.findElement(By.linkText(realmName)).click();
}
public void settings() {
openPage(settingsLink, "Settings");
@ -113,9 +112,9 @@ public class Navigation {
openPage(tokensLink, "Settings");
}
public void sessions() {
openPage(sessionLink, "Sessions");
}
public void sessions() {
openPage(sessionLink, "Sessions");
}
public void security() {
openPage(securityLink, "Settings");
@ -125,29 +124,31 @@ public class Navigation {
openPage(eventsLink, "Events");
}
public void login() {
openPage(loginLink, "Settings");
}
public void login() {
openPage(loginLink, "Settings");
}
public void themes() {
openPage(themesLink, "Settings");
}
openPage(themesLink, "Settings");
}
public void roleMappings() {
openPage(usersRoleMappings, "User");
}
public void roleMappings(String username) {
String usernameCapitalized = Character.toUpperCase(username.charAt(0))
+ username.substring(1);
openPage(usersRoleMappings, usernameCapitalized);
}
public void addRealm() {
openPage(addRealm, "Add Realm");
}
public void addRealm() {
openPage(addRealm, "Add Realm");
}
public void credentials() {
openPage(credentials, "Settings");
}
public void credentials() {
openPage(credentials, "Settings");
}
public void attributes() {
openPage(attributes, "Attributes");
}
public void attributes() {
openPage(attributes, "Attributes");
}
private void openPage(WebElement page, String headerText) {
waitGuiForElement(page);

View file

@ -3,7 +3,6 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.keycloak.testsuite.ui.test.role;
import org.jboss.arquillian.graphene.findby.FindByJQuery;
@ -21,36 +20,35 @@ import org.keycloak.testsuite.ui.page.settings.user.UserPage;
import static org.openqa.selenium.By.id;
import org.openqa.selenium.support.ui.Select;
/**
*
* @author Petr Mensik
*/
public class AddNewRoleTest extends AbstractKeyCloakTest<RolesPage> {
@Page
private UserPage userPage;
@Page
private UserPage userPage;
@FindByJQuery(".alert")
@FindByJQuery(".alert")
private FlashMessage flashMessage;
@Before
public void beforeTestAddNewRole() {
navigation.roles();
}
@Before
public void beforeTestAddNewRole() {
navigation.roles();
}
@Test
public void testAddNewRole() {
Role role = new Role("role1");
page.addRole(role);
flashMessage.waitUntilPresent();
assertTrue(flashMessage.getText(), flashMessage.isSuccess());
navigation.roles();
flashMessage.waitUntilPresent();
assertTrue(flashMessage.getText(), flashMessage.isSuccess());
navigation.roles();
assertEquals("role1", page.findRole(role.getName()).getName());
page.deleteRole(role);
}
@Ignore
@Ignore
@Test
public void testAddNewRoleWithLongName() {
String name = "hjewr89y1894yh98(*&*&$jhjkashd)*(&y8934h*&@#hjkahsdj";
@ -64,31 +62,31 @@ public class AddNewRoleTest extends AbstractKeyCloakTest<RolesPage> {
public void testAddExistingRole() {
Role role = new Role("role2");
page.addRole(role);
flashMessage.waitUntilPresent();
assertTrue(flashMessage.getText(), flashMessage.isSuccess());
flashMessage.waitUntilPresent();
assertTrue(flashMessage.getText(), flashMessage.isSuccess());
navigation.roles();
page.addRole(role);
flashMessage.waitUntilPresent();
assertTrue(flashMessage.getText(), flashMessage.isDanger());
flashMessage.waitUntilPresent();
assertTrue(flashMessage.getText(), flashMessage.isDanger());
navigation.roles();
page.deleteRole(role);
}
@Test
public void testRoleIsAvailableForUsers() {
Role role = new Role("User role");
page.addRole(role);
flashMessage.waitUntilPresent();
assertTrue(flashMessage.getText(), flashMessage.isSuccess());
navigation.users();
userPage.showAllUsers();
userPage.goToUser("admin");
navigation.roleMappings();
Select rolesSelect = new Select(driver.findElement(id("available")));
assertEquals("User role should be present in admin role mapping",
role.getName(), rolesSelect.getOptions().get(0).getText());
navigation.roles();
page.deleteRole(role);
}
@Test
public void testRoleIsAvailableForUsers() {
Role role = new Role("User role");
page.addRole(role);
flashMessage.waitUntilPresent();
assertTrue(flashMessage.getText(), flashMessage.isSuccess());
navigation.users();
userPage.showAllUsers();
userPage.goToUser("admin");
navigation.roleMappings("Admin");
Select rolesSelect = new Select(driver.findElement(id("available")));
assertEquals("User role should be present in admin role mapping",
role.getName(), rolesSelect.getOptions().get(0).getText());
navigation.roles();
page.deleteRole(role);
}
}

View file

@ -40,7 +40,7 @@ public class RoleMappingsTest extends AbstractKeyCloakTest<RoleMappingsPage> {
navigation.users();
userPage.findUser(testUsername);
driver.findElement(linkText(testUsername)).click();
navigation.roleMappings();
navigation.roleMappings(testUsername);
page.addAvailableRole("create-realm");
assertTrue(flashMessage.getText(), flashMessage.isSuccess());
@ -58,7 +58,7 @@ public class RoleMappingsTest extends AbstractKeyCloakTest<RoleMappingsPage> {
navigation.users();
userPage.findUser(testUsername);
driver.findElement(linkText(testUsername)).click();
navigation.roleMappings();
navigation.roleMappings(testUsername);
page.addAvailableRole("create-realm");
assertTrue(flashMessage.getText(), flashMessage.isSuccess());