Improve stability of JS-console tests
This commit is contained in:
parent
dcc9e30e8d
commit
09d1c8bafc
2 changed files with 28 additions and 24 deletions
|
@ -113,11 +113,15 @@ public class JSConsoleExample extends AbstractPageWithInjectedUrl {
|
||||||
responseModeSelect.selectByValue(value);
|
responseModeSelect.selectByValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOutputText() {
|
public WebElement getOutputElement() {
|
||||||
return outputArea.getText();
|
return outputArea;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEventsText() {
|
public WebElement getEventsElement() {
|
||||||
return eventsArea.getText();
|
return eventsArea;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WebElement getInitButtonElement() {
|
||||||
|
return initButton;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ import static org.keycloak.testsuite.util.IOUtil.loadRealm;
|
||||||
import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlDoesntStartWith;
|
import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlDoesntStartWith;
|
||||||
import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlStartsWith;
|
import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlStartsWith;
|
||||||
import static org.keycloak.testsuite.util.WaitUtils.pause;
|
import static org.keycloak.testsuite.util.WaitUtils.pause;
|
||||||
|
import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;
|
||||||
|
|
||||||
public abstract class AbstractJSConsoleExampleAdapterTest extends AbstractExampleAdapterTest {
|
public abstract class AbstractJSConsoleExampleAdapterTest extends AbstractExampleAdapterTest {
|
||||||
|
|
||||||
|
@ -94,7 +95,7 @@ public abstract class AbstractJSConsoleExampleAdapterTest extends AbstractExampl
|
||||||
jsConsoleExamplePage.navigateTo();
|
jsConsoleExamplePage.navigateTo();
|
||||||
assertCurrentUrlStartsWith(jsConsoleExamplePage);
|
assertCurrentUrlStartsWith(jsConsoleExamplePage);
|
||||||
|
|
||||||
pause(1000);
|
waitUntilElement(jsConsoleExamplePage.getInitButtonElement()).is().present();
|
||||||
|
|
||||||
jsConsoleExamplePage.init();
|
jsConsoleExamplePage.init();
|
||||||
jsConsoleExamplePage.logIn();
|
jsConsoleExamplePage.logIn();
|
||||||
|
@ -107,16 +108,15 @@ public abstract class AbstractJSConsoleExampleAdapterTest extends AbstractExampl
|
||||||
testRealmLoginPage.form().login("user", "password");
|
testRealmLoginPage.form().login("user", "password");
|
||||||
assertCurrentUrlStartsWith(jsConsoleExamplePage);
|
assertCurrentUrlStartsWith(jsConsoleExamplePage);
|
||||||
jsConsoleExamplePage.init();
|
jsConsoleExamplePage.init();
|
||||||
assertTrue(jsConsoleExamplePage.getOutputText().contains("Init Success (Authenticated)"));
|
|
||||||
assertTrue(jsConsoleExamplePage.getEventsText().contains("Auth Success"));
|
|
||||||
|
|
||||||
pause(1000);
|
waitUntilElement(jsConsoleExamplePage.getOutputElement()).text().contains("Init Success (Authenticated)");
|
||||||
|
waitUntilElement(jsConsoleExamplePage.getEventsElement()).text().contains("Auth Success");
|
||||||
|
|
||||||
jsConsoleExamplePage.logOut();
|
jsConsoleExamplePage.logOut();
|
||||||
assertCurrentUrlStartsWith(jsConsoleExamplePage);
|
assertCurrentUrlStartsWith(jsConsoleExamplePage);
|
||||||
jsConsoleExamplePage.init();
|
jsConsoleExamplePage.init();
|
||||||
|
|
||||||
assertTrue(jsConsoleExamplePage.getOutputText().contains("Init Success (Not Authenticated)"));
|
waitUntilElement(jsConsoleExamplePage.getOutputElement()).text().contains("Init Success (Not Authenticated)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -126,16 +126,16 @@ public abstract class AbstractJSConsoleExampleAdapterTest extends AbstractExampl
|
||||||
|
|
||||||
jsConsoleExamplePage.init();
|
jsConsoleExamplePage.init();
|
||||||
jsConsoleExamplePage.refreshToken();
|
jsConsoleExamplePage.refreshToken();
|
||||||
assertTrue(jsConsoleExamplePage.getOutputText().contains("Failed to refresh token"));
|
waitUntilElement(jsConsoleExamplePage.getOutputElement()).text().contains("Failed to refresh token");
|
||||||
|
|
||||||
jsConsoleExamplePage.logIn();
|
jsConsoleExamplePage.logIn();
|
||||||
testRealmLoginPage.form().login("user", "password");
|
testRealmLoginPage.form().login("user", "password");
|
||||||
assertCurrentUrlStartsWith(jsConsoleExamplePage);
|
assertCurrentUrlStartsWith(jsConsoleExamplePage);
|
||||||
jsConsoleExamplePage.init();
|
jsConsoleExamplePage.init();
|
||||||
assertTrue(jsConsoleExamplePage.getEventsText().contains("Auth Success"));
|
waitUntilElement(jsConsoleExamplePage.getEventsElement()).text().contains("Auth Success");
|
||||||
|
|
||||||
jsConsoleExamplePage.refreshToken();
|
jsConsoleExamplePage.refreshToken();
|
||||||
assertTrue(jsConsoleExamplePage.getEventsText().contains("Auth Refresh Success"));
|
waitUntilElement(jsConsoleExamplePage.getEventsElement()).text().contains("Auth Refresh Success");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -144,21 +144,21 @@ public abstract class AbstractJSConsoleExampleAdapterTest extends AbstractExampl
|
||||||
assertCurrentUrlStartsWith(jsConsoleExamplePage);
|
assertCurrentUrlStartsWith(jsConsoleExamplePage);
|
||||||
jsConsoleExamplePage.init();
|
jsConsoleExamplePage.init();
|
||||||
jsConsoleExamplePage.refreshToken();
|
jsConsoleExamplePage.refreshToken();
|
||||||
assertTrue(jsConsoleExamplePage.getOutputText().contains("Failed to refresh token"));
|
waitUntilElement(jsConsoleExamplePage.getOutputElement()).text().contains("Failed to refresh token");
|
||||||
|
|
||||||
jsConsoleExamplePage.logIn();
|
jsConsoleExamplePage.logIn();
|
||||||
testRealmLoginPage.form().login("user", "password");
|
testRealmLoginPage.form().login("user", "password");
|
||||||
assertCurrentUrlStartsWith(jsConsoleExamplePage);
|
assertCurrentUrlStartsWith(jsConsoleExamplePage);
|
||||||
jsConsoleExamplePage.init();
|
jsConsoleExamplePage.init();
|
||||||
assertTrue(jsConsoleExamplePage.getEventsText().contains("Auth Success"));
|
waitUntilElement(jsConsoleExamplePage.getEventsElement()).text().contains("Auth Success");
|
||||||
|
|
||||||
jsConsoleExamplePage.refreshTokenIfUnder30s();
|
jsConsoleExamplePage.refreshTokenIfUnder30s();
|
||||||
assertTrue(jsConsoleExamplePage.getOutputText().contains("Token not refreshed, valid for"));
|
waitUntilElement(jsConsoleExamplePage.getOutputElement()).text().contains("Token not refreshed, valid for");
|
||||||
|
|
||||||
pause((TOKEN_LIFESPAN_LEEWAY + 2) * 1000);
|
pause((TOKEN_LIFESPAN_LEEWAY + 2) * 1000);
|
||||||
|
|
||||||
jsConsoleExamplePage.refreshTokenIfUnder30s();
|
jsConsoleExamplePage.refreshTokenIfUnder30s();
|
||||||
assertTrue(jsConsoleExamplePage.getEventsText().contains("Auth Refresh Success"));
|
waitUntilElement(jsConsoleExamplePage.getEventsElement()).text().contains("Auth Refresh Success");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -168,17 +168,16 @@ public abstract class AbstractJSConsoleExampleAdapterTest extends AbstractExampl
|
||||||
|
|
||||||
jsConsoleExamplePage.init();
|
jsConsoleExamplePage.init();
|
||||||
jsConsoleExamplePage.getProfile();
|
jsConsoleExamplePage.getProfile();
|
||||||
pause(500);
|
waitUntilElement(jsConsoleExamplePage.getOutputElement()).text().contains("Failed to load profile");
|
||||||
assertTrue(jsConsoleExamplePage.getOutputText().contains("Failed to load profile"));
|
|
||||||
|
|
||||||
jsConsoleExamplePage.logIn();
|
jsConsoleExamplePage.logIn();
|
||||||
testRealmLoginPage.form().login("user", "password");
|
testRealmLoginPage.form().login("user", "password");
|
||||||
assertCurrentUrlStartsWith(jsConsoleExamplePage);
|
assertCurrentUrlStartsWith(jsConsoleExamplePage);
|
||||||
jsConsoleExamplePage.init();
|
jsConsoleExamplePage.init();
|
||||||
assertTrue(jsConsoleExamplePage.getEventsText().contains("Auth Success"));
|
waitUntilElement(jsConsoleExamplePage.getEventsElement()).text().contains("Auth Success");
|
||||||
|
|
||||||
jsConsoleExamplePage.getProfile();
|
jsConsoleExamplePage.getProfile();
|
||||||
assertTrue(jsConsoleExamplePage.getOutputText().contains("\"username\": \"user\""));
|
waitUntilElement(jsConsoleExamplePage.getOutputElement()).text().contains("\"username\": \"user\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -212,7 +211,8 @@ public abstract class AbstractJSConsoleExampleAdapterTest extends AbstractExampl
|
||||||
oAuthGrantPage.accept();
|
oAuthGrantPage.accept();
|
||||||
|
|
||||||
jsConsoleExamplePage.init();
|
jsConsoleExamplePage.init();
|
||||||
assertTrue(jsConsoleExamplePage.getOutputText().contains("Init Success (Authenticated)"));
|
|
||||||
|
waitUntilElement(jsConsoleExamplePage.getOutputElement()).text().contains("Init Success (Authenticated)");
|
||||||
|
|
||||||
applicationsPage.navigateTo();
|
applicationsPage.navigateTo();
|
||||||
applicationsPage.revokeGrantForApplication("js-console");
|
applicationsPage.revokeGrantForApplication("js-console");
|
||||||
|
@ -271,7 +271,7 @@ public abstract class AbstractJSConsoleExampleAdapterTest extends AbstractExampl
|
||||||
|
|
||||||
logInAndInit("implicit");
|
logInAndInit("implicit");
|
||||||
|
|
||||||
assertTrue(jsConsoleExamplePage.getOutputText().contains("Init Success (Authenticated)"));
|
waitUntilElement(jsConsoleExamplePage.getOutputElement()).text().contains("Init Success (Authenticated)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -294,7 +294,7 @@ public abstract class AbstractJSConsoleExampleAdapterTest extends AbstractExampl
|
||||||
|
|
||||||
jsConsoleExamplePage.refreshToken();
|
jsConsoleExamplePage.refreshToken();
|
||||||
|
|
||||||
assertTrue(jsConsoleExamplePage.getOutputText().contains("Failed to refresh token"));
|
waitUntilElement(jsConsoleExamplePage.getOutputElement()).text().contains("Failed to refresh token");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -309,7 +309,7 @@ public abstract class AbstractJSConsoleExampleAdapterTest extends AbstractExampl
|
||||||
|
|
||||||
pause(6000);
|
pause(6000);
|
||||||
|
|
||||||
assertTrue(jsConsoleExamplePage.getEventsText().contains("Access token expired"));
|
waitUntilElement(jsConsoleExamplePage.getEventsElement()).text().contains("Access token expired");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setImplicitFlowFroClient() {
|
private void setImplicitFlowFroClient() {
|
||||||
|
|
Loading…
Reference in a new issue