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 WelcomePage from '../support/pages/WelcomePage.js'
|
||||||
import OldClientPage from '../support/pages/admin_console/manage/clients/OldClientPage.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();
|
describe("Set up test", function () {
|
||||||
const welcomePage = new WelcomePage();
|
beforeEach(function () {
|
||||||
const oldClientPage = new OldClientPage();
|
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 () {
|
it("Create admin user and adds admin console client", function () {
|
||||||
welcomePage
|
welcomePage
|
||||||
.createAdminUser()
|
.createAdminUser()
|
||||||
.goToAdminConsole();
|
.goToAdminConsole();
|
||||||
|
|
||||||
loginPage.logIn();
|
loginPage.logIn();
|
||||||
|
|
||||||
oldClientPage
|
oldClientPage
|
||||||
.goToClients()
|
.goToClients()
|
||||||
.addNewAdminConsole();
|
.addNewAdminConsole();
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
})
|
|
|
@ -4,17 +4,17 @@ import ListingPage from "../support/pages/admin_console/ListingPage.js";
|
||||||
import SidebarPage from "../support/pages/admin_console/SidebarPage.js";
|
import SidebarPage from "../support/pages/admin_console/SidebarPage.js";
|
||||||
import CreateClientScopePage from "../support/pages/admin_console/manage/client_scopes/CreateClientScopePage.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 () {
|
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 () {
|
describe("Client Scope creation", function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
cy.clearCookies();
|
|
||||||
cy.visit("");
|
cy.visit("");
|
||||||
loginPage.logIn();
|
loginPage.logIn();
|
||||||
sidebarPage.goToClientScopes();
|
sidebarPage.goToClientScopes();
|
||||||
|
@ -48,7 +48,7 @@ describe("Client Scopes test", function () {
|
||||||
.fillClientScopeData(itemId)
|
.fillClientScopeData(itemId)
|
||||||
.save();
|
.save();
|
||||||
|
|
||||||
masthead.checkNotificationMessage('Client scope created');
|
masthead.checkNotificationMessage("Client scope created");
|
||||||
|
|
||||||
sidebarPage.goToClientScopes();
|
sidebarPage.goToClientScopes();
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ describe("Client Scopes test", function () {
|
||||||
.itemExist(itemId)
|
.itemExist(itemId)
|
||||||
.deleteItem(itemId); // There should be a confirmation pop-up
|
.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
|
listingPage // It is not refreshing after delete
|
||||||
.itemExist(itemId, false);
|
.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 SidebarPage from "../support/pages/admin_console/SidebarPage.js";
|
||||||
import CreateClientPage from "../support/pages/admin_console/manage/clients/CreateClientPage.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 () {
|
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 () {
|
describe("Client creation", function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
cy.clearCookies();
|
|
||||||
cy.visit("");
|
cy.visit("");
|
||||||
loginPage.logIn();
|
loginPage.logIn();
|
||||||
sidebarPage.goToClients();
|
sidebarPage.goToClients();
|
||||||
|
|
|
@ -1,31 +1,32 @@
|
||||||
import LoginPage from "./../support/pages/LoginPage.js";
|
import LoginPage from "./../support/pages/LoginPage.js";
|
||||||
import Masthead from "./../support/pages/admin_console/Masthead.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 () {
|
describe("Logging In", function () {
|
||||||
const username = "admin";
|
|
||||||
const password = "admin";
|
|
||||||
|
|
||||||
const loginPage = new LoginPage();
|
beforeEach(function () {
|
||||||
const masthead = new Masthead();
|
cy.visit("");
|
||||||
|
});
|
||||||
|
|
||||||
describe("Login form submission", function () {
|
it("displays errors on wrong credentials", function () {
|
||||||
beforeEach(function () {
|
loginPage
|
||||||
cy.visit("");
|
.logIn("wrong", "user{enter}");
|
||||||
});
|
|
||||||
|
loginPage
|
||||||
|
.checkErrorMessage("Invalid username or password.")
|
||||||
|
.isLogInPage();
|
||||||
|
});
|
||||||
|
|
||||||
it("displays errors on login", function () {
|
it("logs in", function () {
|
||||||
loginPage
|
loginPage.logIn(username, password);
|
||||||
.logIn("wrong", "user{enter}")
|
|
||||||
.checkErrorMessage("Invalid username or password.")
|
|
||||||
.isLogInPage();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("redirects to admin console on success", function () {
|
masthead.isAdminConsole();
|
||||||
loginPage.logIn(username, password);
|
|
||||||
|
|
||||||
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", () => {
|
describe("Masthead tests in desktop mode", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.clearCookies();
|
|
||||||
cy.visit("");
|
cy.visit("");
|
||||||
loginPage.logIn();
|
loginPage.logIn();
|
||||||
});
|
});
|
||||||
|
@ -52,7 +51,6 @@ describe("Masthead tests in desktop mode", () => {
|
||||||
|
|
||||||
describe("Masthead tests with kebab menu", () => {
|
describe("Masthead tests with kebab menu", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.clearCookies();
|
|
||||||
cy.visit("");
|
cy.visit("");
|
||||||
loginPage.logIn();
|
loginPage.logIn();
|
||||||
masthead.setMobileMode(true);
|
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 SidebarPage from "../support/pages/admin_console/SidebarPage.js";
|
||||||
import CreateRealmRolePage from "../support/pages/admin_console/manage/realm_roles/CreateRealmRolePage.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 () {
|
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 () {
|
describe("Realm roles creation", function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
cy.clearCookies();
|
|
||||||
cy.visit("");
|
cy.visit("");
|
||||||
loginPage.logIn();
|
loginPage.logIn();
|
||||||
sidebarPage.goToRealmRoles();
|
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 CreateRealmPage from "../support/pages/admin_console/CreateRealmPage.js";
|
||||||
import Masthead from "../support/pages/admin_console/Masthead.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 () {
|
describe("Realms test", function () {
|
||||||
const loginPage = new LoginPage();
|
|
||||||
const sidebarPage = new SidebarPage();
|
|
||||||
const createRealmPage = new CreateRealmPage();
|
|
||||||
const masthead = new Masthead();
|
|
||||||
|
|
||||||
describe("Realm creation", function () {
|
describe("Realm creation", function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
cy.clearCookies();
|
|
||||||
cy.visit("");
|
cy.visit("");
|
||||||
loginPage.logIn();
|
loginPage.logIn();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,38 +1,45 @@
|
||||||
export default class LoginPage {
|
export default class LoginPage {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.userNameInput = "#username";
|
this.userNameInput = "#username";
|
||||||
this.passwordInput = "#password";
|
this.passwordInput = "#password";
|
||||||
this.submitBtn = "#kc-login";
|
this.submitBtn = "#kc-login";
|
||||||
|
|
||||||
this.errorText = ".kc-feedback-text";
|
this.errorText = ".kc-feedback-text";
|
||||||
}
|
this.oldLoadContainer = "#loading";
|
||||||
|
this.loadContainer = "div.keycloak__loading-container";
|
||||||
|
}
|
||||||
|
|
||||||
isLogInPage() {
|
isLogInPage() {
|
||||||
cy.get(this.userNameInput).should('exist');
|
cy.get(this.userNameInput).should("exist");
|
||||||
cy.url().should('include', '/auth');
|
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.userNameInput).type(userName);
|
||||||
cy.get(this.passwordInput).type(password);
|
cy.get(this.passwordInput).type(password);
|
||||||
|
|
||||||
cy.get(this.submitBtn).click();
|
cy.get(this.submitBtn).click();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return this;
|
checkErrorIsDisplayed() {
|
||||||
}
|
cy.get(this.userDrpDwn).should("exist");
|
||||||
|
|
||||||
checkErrorIsDisplayed() {
|
return this;
|
||||||
cy.get(this.userDrpDwn).should('exist');
|
}
|
||||||
|
|
||||||
return this;
|
checkErrorMessage(message) {
|
||||||
}
|
cy.get(this.errorText).invoke("text").should("contain", message);
|
||||||
|
|
||||||
checkErrorMessage(message) {
|
return this;
|
||||||
cy.get(this.errorText).invoke('text').should('contain', message);
|
}
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -9,6 +9,6 @@
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"cypress": "^5.6.0"
|
"cypress": "6.2.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue