Ignore login when user is already logged (#329)
* Add cookie check on Log in * Change cookie check to body children check * Add loadingContainer element * Add old load container element * Change quotes * Disable video recording * Replace quotes * Refactor * Change Cypress version
This commit is contained in:
parent
b9de247569
commit
0cf9d3e578
9 changed files with 99 additions and 96 deletions
|
@ -2,27 +2,24 @@ import LoginPage from '../support/pages/LoginPage.js'
|
|||
import WelcomePage from '../support/pages/WelcomePage.js'
|
||||
import OldClientPage from '../support/pages/admin_console/manage/clients/OldClientPage.js'
|
||||
|
||||
describe('Set up test', function () {
|
||||
const loginPage = new LoginPage();
|
||||
const welcomePage = new WelcomePage();
|
||||
const oldClientPage = new OldClientPage();
|
||||
|
||||
const loginPage = new LoginPage();
|
||||
const welcomePage = new WelcomePage();
|
||||
const oldClientPage = new OldClientPage();
|
||||
|
||||
describe('Set up test', function () {
|
||||
beforeEach(function () {
|
||||
cy.visit('http://localhost:8180/auth')
|
||||
})
|
||||
describe("Set up test", function () {
|
||||
beforeEach(function () {
|
||||
cy.visit("http://localhost:8180/auth")
|
||||
})
|
||||
|
||||
it('Create admin user and adds admin console client', function () {
|
||||
welcomePage
|
||||
.createAdminUser()
|
||||
.goToAdminConsole();
|
||||
it("Create admin user and adds admin console client", function () {
|
||||
welcomePage
|
||||
.createAdminUser()
|
||||
.goToAdminConsole();
|
||||
|
||||
loginPage.logIn();
|
||||
loginPage.logIn();
|
||||
|
||||
oldClientPage
|
||||
.goToClients()
|
||||
.addNewAdminConsole();
|
||||
});
|
||||
})
|
||||
})
|
||||
oldClientPage
|
||||
.goToClients()
|
||||
.addNewAdminConsole();
|
||||
});
|
||||
})
|
|
@ -4,17 +4,17 @@ import ListingPage from "../support/pages/admin_console/ListingPage.js";
|
|||
import SidebarPage from "../support/pages/admin_console/SidebarPage.js";
|
||||
import CreateClientScopePage from "../support/pages/admin_console/manage/client_scopes/CreateClientScopePage.js";
|
||||
|
||||
let itemId = "client_scope_crud";
|
||||
const loginPage = new LoginPage();
|
||||
const masthead = new Masthead();
|
||||
const sidebarPage = new SidebarPage();
|
||||
const listingPage = new ListingPage();
|
||||
const createClientScopePage = new CreateClientScopePage();
|
||||
|
||||
describe("Client Scopes test", function () {
|
||||
let itemId = "client_scope_crud";
|
||||
const loginPage = new LoginPage();
|
||||
const masthead = new Masthead();
|
||||
const sidebarPage = new SidebarPage();
|
||||
const listingPage = new ListingPage();
|
||||
const createClientScopePage = new CreateClientScopePage();
|
||||
|
||||
describe("Client Scope creation", function () {
|
||||
beforeEach(function () {
|
||||
cy.clearCookies();
|
||||
cy.visit("");
|
||||
loginPage.logIn();
|
||||
sidebarPage.goToClientScopes();
|
||||
|
@ -48,7 +48,7 @@ describe("Client Scopes test", function () {
|
|||
.fillClientScopeData(itemId)
|
||||
.save();
|
||||
|
||||
masthead.checkNotificationMessage('Client scope created');
|
||||
masthead.checkNotificationMessage("Client scope created");
|
||||
|
||||
sidebarPage.goToClientScopes();
|
||||
|
||||
|
@ -57,7 +57,7 @@ describe("Client Scopes test", function () {
|
|||
.itemExist(itemId)
|
||||
.deleteItem(itemId); // There should be a confirmation pop-up
|
||||
|
||||
masthead.checkNotificationMessage('The client scope has been deleted');
|
||||
masthead.checkNotificationMessage("The client scope has been deleted");
|
||||
|
||||
listingPage // It is not refreshing after delete
|
||||
.itemExist(itemId, false);
|
||||
|
|
|
@ -4,17 +4,17 @@ import ListingPage from "../support/pages/admin_console/ListingPage.js";
|
|||
import SidebarPage from "../support/pages/admin_console/SidebarPage.js";
|
||||
import CreateClientPage from "../support/pages/admin_console/manage/clients/CreateClientPage.js";
|
||||
|
||||
let itemId = "client_crud";
|
||||
const loginPage = new LoginPage();
|
||||
const masthead = new Masthead();
|
||||
const sidebarPage = new SidebarPage();
|
||||
const listingPage = new ListingPage();
|
||||
const createClientPage = new CreateClientPage();
|
||||
|
||||
describe("Clients test", function () {
|
||||
let itemId = "client_crud";
|
||||
const loginPage = new LoginPage();
|
||||
const masthead = new Masthead();
|
||||
const sidebarPage = new SidebarPage();
|
||||
const listingPage = new ListingPage();
|
||||
const createClientPage = new CreateClientPage();
|
||||
|
||||
describe("Client creation", function () {
|
||||
beforeEach(function () {
|
||||
cy.clearCookies();
|
||||
cy.visit("");
|
||||
loginPage.logIn();
|
||||
sidebarPage.goToClients();
|
||||
|
|
|
@ -1,31 +1,32 @@
|
|||
import LoginPage from "./../support/pages/LoginPage.js";
|
||||
import Masthead from "./../support/pages/admin_console/Masthead.js";
|
||||
|
||||
const username = "admin";
|
||||
const password = "admin";
|
||||
|
||||
const loginPage = new LoginPage();
|
||||
const masthead = new Masthead();
|
||||
|
||||
describe("Logging In", function () {
|
||||
const username = "admin";
|
||||
const password = "admin";
|
||||
|
||||
const loginPage = new LoginPage();
|
||||
const masthead = new Masthead();
|
||||
beforeEach(function () {
|
||||
cy.visit("");
|
||||
});
|
||||
|
||||
describe("Login form submission", function () {
|
||||
beforeEach(function () {
|
||||
cy.visit("");
|
||||
});
|
||||
it("displays errors on wrong credentials", function () {
|
||||
loginPage
|
||||
.logIn("wrong", "user{enter}");
|
||||
|
||||
loginPage
|
||||
.checkErrorMessage("Invalid username or password.")
|
||||
.isLogInPage();
|
||||
});
|
||||
|
||||
it("displays errors on login", function () {
|
||||
loginPage
|
||||
.logIn("wrong", "user{enter}")
|
||||
.checkErrorMessage("Invalid username or password.")
|
||||
.isLogInPage();
|
||||
});
|
||||
it("logs in", function () {
|
||||
loginPage.logIn(username, password);
|
||||
|
||||
it("redirects to admin console on success", function () {
|
||||
loginPage.logIn(username, password);
|
||||
masthead.isAdminConsole();
|
||||
|
||||
masthead.isAdminConsole();
|
||||
|
||||
cy.getCookie("KEYCLOAK_SESSION_LEGACY").should("exist");
|
||||
});
|
||||
cy.getCookie("KEYCLOAK_SESSION_LEGACY").should("exist");
|
||||
});
|
||||
});
|
||||
|
|
|
@ -24,7 +24,6 @@ const goToAcctMgtTest = () => {
|
|||
|
||||
describe("Masthead tests in desktop mode", () => {
|
||||
beforeEach(() => {
|
||||
cy.clearCookies();
|
||||
cy.visit("");
|
||||
loginPage.logIn();
|
||||
});
|
||||
|
@ -52,7 +51,6 @@ describe("Masthead tests in desktop mode", () => {
|
|||
|
||||
describe("Masthead tests with kebab menu", () => {
|
||||
beforeEach(() => {
|
||||
cy.clearCookies();
|
||||
cy.visit("");
|
||||
loginPage.logIn();
|
||||
masthead.setMobileMode(true);
|
||||
|
|
|
@ -5,18 +5,18 @@ import ListingPage from "../support/pages/admin_console/ListingPage.js";
|
|||
import SidebarPage from "../support/pages/admin_console/SidebarPage.js";
|
||||
import CreateRealmRolePage from "../support/pages/admin_console/manage/realm_roles/CreateRealmRolePage.js";
|
||||
|
||||
let itemId = "realm_role_crud";
|
||||
const loginPage = new LoginPage();
|
||||
const masthead = new Masthead();
|
||||
const modalUtils = new ModalUtils();
|
||||
const sidebarPage = new SidebarPage();
|
||||
const listingPage = new ListingPage();
|
||||
const createRealmRolePage = new CreateRealmRolePage();
|
||||
|
||||
describe("Realm roles test", function () {
|
||||
let itemId = "realm_role_crud";
|
||||
const loginPage = new LoginPage();
|
||||
const masthead = new Masthead();
|
||||
const modalUtils = new ModalUtils();
|
||||
const sidebarPage = new SidebarPage();
|
||||
const listingPage = new ListingPage();
|
||||
const createRealmRolePage = new CreateRealmRolePage();
|
||||
|
||||
describe("Realm roles creation", function () {
|
||||
beforeEach(function () {
|
||||
cy.clearCookies();
|
||||
cy.visit("");
|
||||
loginPage.logIn();
|
||||
sidebarPage.goToRealmRoles();
|
||||
|
|
|
@ -3,15 +3,15 @@ import SidebarPage from "../support/pages/admin_console/SidebarPage.js";
|
|||
import CreateRealmPage from "../support/pages/admin_console/CreateRealmPage.js";
|
||||
import Masthead from "../support/pages/admin_console/Masthead.js";
|
||||
|
||||
const masthead = new Masthead();
|
||||
const loginPage = new LoginPage();
|
||||
const sidebarPage = new SidebarPage();
|
||||
const createRealmPage = new CreateRealmPage();
|
||||
|
||||
describe("Realms test", function () {
|
||||
const loginPage = new LoginPage();
|
||||
const sidebarPage = new SidebarPage();
|
||||
const createRealmPage = new CreateRealmPage();
|
||||
const masthead = new Masthead();
|
||||
|
||||
describe("Realm creation", function () {
|
||||
beforeEach(function () {
|
||||
cy.clearCookies();
|
||||
cy.visit("");
|
||||
loginPage.logIn();
|
||||
});
|
||||
|
|
|
@ -1,38 +1,45 @@
|
|||
export default class LoginPage {
|
||||
|
||||
constructor() {
|
||||
this.userNameInput = "#username";
|
||||
this.passwordInput = "#password";
|
||||
this.submitBtn = "#kc-login";
|
||||
constructor() {
|
||||
this.userNameInput = "#username";
|
||||
this.passwordInput = "#password";
|
||||
this.submitBtn = "#kc-login";
|
||||
|
||||
this.errorText = ".kc-feedback-text";
|
||||
}
|
||||
this.errorText = ".kc-feedback-text";
|
||||
this.oldLoadContainer = "#loading";
|
||||
this.loadContainer = "div.keycloak__loading-container";
|
||||
}
|
||||
|
||||
isLogInPage() {
|
||||
cy.get(this.userNameInput).should('exist');
|
||||
cy.url().should('include', '/auth');
|
||||
isLogInPage() {
|
||||
cy.get(this.userNameInput).should("exist");
|
||||
cy.url().should("include", "/auth");
|
||||
|
||||
return this;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
logIn(userName = "admin", password = "admin") {
|
||||
logIn(userName = "admin", password = "admin") {
|
||||
cy.get(this.oldLoadContainer).should("not.exist");
|
||||
cy.get(this.loadContainer).should("not.exist");
|
||||
|
||||
cy.get("body").children().then((children) => {
|
||||
if(children.length == 1) {
|
||||
cy.get(this.userNameInput).type(userName);
|
||||
cy.get(this.passwordInput).type(password);
|
||||
|
||||
|
||||
cy.get(this.submitBtn).click();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
checkErrorIsDisplayed() {
|
||||
cy.get(this.userDrpDwn).should("exist");
|
||||
|
||||
checkErrorIsDisplayed() {
|
||||
cy.get(this.userDrpDwn).should('exist');
|
||||
return this;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
checkErrorMessage(message) {
|
||||
cy.get(this.errorText).invoke("text").should("contain", message);
|
||||
|
||||
checkErrorMessage(message) {
|
||||
cy.get(this.errorText).invoke('text').should('contain', message);
|
||||
|
||||
return this;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -9,6 +9,6 @@
|
|||
"author": "",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"cypress": "^5.6.0"
|
||||
"cypress": "6.2.1"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue