Modify CRUD tests (#325)

This commit is contained in:
Aboullos 2021-01-25 18:17:59 +01:00 committed by GitHub
parent 0dc3f08917
commit 71a41694d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 62 additions and 88 deletions

View file

@ -5,7 +5,7 @@ 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";
describe("Client Scopes test", function () { describe("Client Scopes test", function () {
const itemId = "client_scope_1"; let itemId = "client_scope_crud";
const loginPage = new LoginPage(); const loginPage = new LoginPage();
const masthead = new Masthead(); const masthead = new Masthead();
const sidebarPage = new SidebarPage(); const sidebarPage = new SidebarPage();
@ -14,14 +14,13 @@ describe("Client Scopes test", function () {
describe("Client Scope creation", function () { describe("Client Scope creation", function () {
beforeEach(function () { beforeEach(function () {
cy.clearCookies();
cy.visit(""); cy.visit("");
loginPage.logIn();
sidebarPage.goToClientScopes();
}); });
it("should fail creating client scope", function () { it("should fail creating client scope", function () {
loginPage.logIn();
sidebarPage.goToClientScopes();
listingPage.goToCreateItem(); listingPage.goToCreateItem();
createClientScopePage.save().checkClientNameRequiredMessage(); createClientScopePage.save().checkClientNameRequiredMessage();
@ -37,38 +36,31 @@ describe("Client Scopes test", function () {
); );
}); });
it("should create client scope", function () { it('Client scope CRUD test',async function () {
loginPage.logIn(); itemId += "_" + (Math.random() + 1).toString(36).substring(7);
// Create
listingPage
.itemExist(itemId, false)
.goToCreateItem();
createClientScopePage
.fillClientScopeData(itemId)
.save();
masthead.checkNotificationMessage('Client scope created');
sidebarPage.goToClientScopes(); sidebarPage.goToClientScopes();
listingPage.itemExist(itemId, false).goToCreateItem(); // Delete
listingPage
.itemExist(itemId)
.deleteItem(itemId); // There should be a confirmation pop-up
createClientScopePage.fillClientScopeData(itemId).save(); masthead.checkNotificationMessage('The client scope has been deleted');
masthead.checkNotificationMessage("Client scope created"); listingPage // It is not refreshing after delete
.itemExist(itemId, false);
sidebarPage.goToClientScopes();
listingPage.itemExist(itemId).searchItem(itemId).itemExist(itemId);
});
});
describe("Client scope elimination", function () {
beforeEach(function () {
cy.visit("");
});
it("should delete client scope", function () {
loginPage.logIn();
sidebarPage.goToClientScopes();
listingPage.itemExist(itemId).deleteItem(itemId); // There should be a confirmation pop-up
masthead.checkNotificationMessage("The client scope has been deleted");
listingPage.itemExist(itemId, false);
});
}); });
}); });
})

View file

@ -5,7 +5,7 @@ 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";
describe("Clients test", function () { describe("Clients test", function () {
const itemId = "client_1"; let itemId = "client_crud";
const loginPage = new LoginPage(); const loginPage = new LoginPage();
const masthead = new Masthead(); const masthead = new Masthead();
const sidebarPage = new SidebarPage(); const sidebarPage = new SidebarPage();
@ -14,14 +14,13 @@ describe("Clients test", function () {
describe("Client creation", function () { describe("Client creation", function () {
beforeEach(function () { beforeEach(function () {
cy.clearCookies();
cy.visit(""); cy.visit("");
loginPage.logIn();
sidebarPage.goToClients();
}); });
it("should fail creating client", function () { it("should fail creating client", function () {
loginPage.logIn();
sidebarPage.goToClients();
listingPage.goToCreateItem(); listingPage.goToCreateItem();
createClientPage createClientPage
@ -50,11 +49,10 @@ describe("Clients test", function () {
); );
}); });
it("should create client", function () { it("Client CRUD test", function () {
loginPage.logIn(); itemId += "_" + (Math.random() + 1).toString(36).substring(7);
sidebarPage.goToClients();
// Create
listingPage.itemExist(itemId, false).goToCreateItem(); listingPage.itemExist(itemId, false).goToCreateItem();
createClientPage createClientPage
@ -67,21 +65,13 @@ describe("Clients test", function () {
sidebarPage.goToClients(); sidebarPage.goToClients();
listingPage.itemExist(itemId).searchItem(itemId).itemExist(itemId); listingPage
}); .searchItem(itemId)
}); .itemExist(itemId);
describe("Client elimination", function () { // Delete
beforeEach(function () { listingPage
cy.visit(""); .deleteItem(itemId); // There should be a confirmation pop-up
});
it("should delete client", function () {
loginPage.logIn();
sidebarPage.goToClients();
listingPage.itemExist(itemId).deleteItem(itemId); // There should be a confirmation pop-up
masthead.checkNotificationMessage("The client has been deleted"); masthead.checkNotificationMessage("The client has been deleted");

View file

@ -24,6 +24,7 @@ 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();
}); });
@ -51,6 +52,7 @@ 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);

View file

@ -6,7 +6,7 @@ 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";
describe("Realm roles test", function () { describe("Realm roles test", function () {
const itemId = "realm_role_1"; let itemId = "realm_role_crud";
const loginPage = new LoginPage(); const loginPage = new LoginPage();
const masthead = new Masthead(); const masthead = new Masthead();
const modalUtils = new ModalUtils(); const modalUtils = new ModalUtils();
@ -16,14 +16,13 @@ describe("Realm roles test", function () {
describe("Realm roles creation", function () { describe("Realm roles creation", function () {
beforeEach(function () { beforeEach(function () {
cy.clearCookies();
cy.visit(""); cy.visit("");
loginPage.logIn();
sidebarPage.goToRealmRoles();
}); });
it("should fail creating realm role", function () { it("should fail creating realm role", function () {
loginPage.logIn();
sidebarPage.goToRealmRoles();
listingPage.goToCreateItem(); listingPage.goToCreateItem();
createRealmRolePage.save().checkRealmRoleNameRequiredMessage(); createRealmRolePage.save().checkRealmRoleNameRequiredMessage();
@ -36,12 +35,13 @@ describe("Realm roles test", function () {
); );
}); });
it("should create realm role", function () { it("Realm role CRUD test", function () {
loginPage.logIn(); itemId += "_" + (Math.random() + 1).toString(36).substring(7);
sidebarPage.goToRealmRoles(); // Create
listingPage
listingPage.itemExist(itemId, false).goToCreateItem(); .itemExist(itemId, false)
.goToCreateItem();
createRealmRolePage.fillRealmRoleData(itemId).save(); createRealmRolePage.fillRealmRoleData(itemId).save();
@ -49,21 +49,15 @@ describe("Realm roles test", function () {
sidebarPage.goToRealmRoles(); sidebarPage.goToRealmRoles();
listingPage.itemExist(itemId).searchItem(itemId).itemExist(itemId); listingPage
}); .searchItem(itemId)
}); .itemExist(itemId);
describe("Realm roles elimination", function () { // Update
beforeEach(function () {
cy.visit("");
});
it("should delete realm role", function () { // Delete
loginPage.logIn(); listingPage
.deleteItem(itemId);
sidebarPage.goToRealmRoles();
listingPage.itemExist(itemId).deleteItem(itemId);
modalUtils.checkModalTitle("Delete role?").confirmModal(); modalUtils.checkModalTitle("Delete role?").confirmModal();

View file

@ -11,12 +11,12 @@ describe("Realms test", function () {
describe("Realm creation", function () { describe("Realm creation", function () {
beforeEach(function () { beforeEach(function () {
cy.clearCookies();
cy.visit(""); cy.visit("");
loginPage.logIn();
}); });
it("should fail creating Master realm", function () { it("should fail creating Master realm", function () {
loginPage.logIn();
sidebarPage.goToCreateRealm(); sidebarPage.goToCreateRealm();
createRealmPage.fillRealmName("master").createRealm(); createRealmPage.fillRealmName("master").createRealm();
@ -26,8 +26,6 @@ describe("Realms test", function () {
}); });
it("should create Test realm", function () { it("should create Test realm", function () {
loginPage.logIn();
sidebarPage.goToCreateRealm(); sidebarPage.goToCreateRealm();
createRealmPage.fillRealmName("Test").createRealm(); createRealmPage.fillRealmName("Test").createRealm();
@ -35,8 +33,6 @@ describe("Realms test", function () {
}); });
it("should change to Test realm", function () { it("should change to Test realm", function () {
loginPage.logIn();
sidebarPage.getCurrentRealm().should("eq", "Master"); sidebarPage.getCurrentRealm().should("eq", "Master");
sidebarPage.goToRealm("Test").getCurrentRealm().should("eq", "Test"); sidebarPage.goToRealm("Test").getCurrentRealm().should("eq", "Test");

View file

@ -2,7 +2,7 @@ export default class ListingPage {
constructor() { constructor() {
this.searchInput = '.pf-c-toolbar__item [type="search"]'; this.searchInput = '.pf-c-toolbar__item [type="search"]';
this.itemsRows = '.pf-c-page__main-section tbody > tr'; this.itemsRows = '.pf-c-page__main-section table';
this.itemRowDrpDwn = '.pf-c-dropdown > button'; this.itemRowDrpDwn = '.pf-c-dropdown > button';
this.exportBtn = '[role="menuitem"]:nth-child(1)'; this.exportBtn = '[role="menuitem"]:nth-child(1)';
this.deleteBtn = '[role="menuitem"]:nth-child(2)'; this.deleteBtn = '[role="menuitem"]:nth-child(2)';