refactor cypress tests
This commit is contained in:
parent
7c816736d2
commit
40eb3ede0d
4 changed files with 80 additions and 108 deletions
|
@ -36,13 +36,23 @@ const deleteModalTitle = "Delete user federation provider?";
|
|||
const disableModalTitle = "Disable user federation provider?";
|
||||
|
||||
describe("User Fed Kerberos tests", () => {
|
||||
it("Create Kerberos provider from empty state", () => {
|
||||
beforeEach(() => {
|
||||
/*
|
||||
Prevent unpredictable 401 errors from failing individual tests.
|
||||
These are most often occurring during the login process:
|
||||
GET /admin/serverinfo/
|
||||
GET /admin/master/console/whoami
|
||||
*/
|
||||
cy.on("uncaught:exception", (err, runnable) => {
|
||||
return false;
|
||||
});
|
||||
cy.visit("");
|
||||
loginPage.logIn();
|
||||
|
||||
sidebarPage.goToUserFederation();
|
||||
cy.get("[data-testid=kerberos-card]").click();
|
||||
});
|
||||
|
||||
it("Create Kerberos provider from empty state", () => {
|
||||
providersPage.clickNewCard("kerberos");
|
||||
providersPage.fillKerberosRequiredData(
|
||||
firstKerberosName,
|
||||
firstKerberosRealm,
|
||||
|
@ -56,129 +66,70 @@ describe("User Fed Kerberos tests", () => {
|
|||
});
|
||||
|
||||
it("Update an existing Kerberos provider and save", () => {
|
||||
cy.visit("");
|
||||
loginPage.logIn();
|
||||
sidebarPage.goToUserFederation();
|
||||
|
||||
cy.get('[data-testid="keycloak-card-title"]')
|
||||
.contains(firstKerberosName)
|
||||
.click();
|
||||
cy.wait(1000);
|
||||
providersPage.clickExistingCard(firstKerberosName);
|
||||
providersPage.selectCacheType(newPolicy);
|
||||
|
||||
cy.contains(defaultKerberosDay).click();
|
||||
cy.contains(newKerberosDay).click();
|
||||
|
||||
cy.contains(defaultKerberosHour).click();
|
||||
cy.contains(newKerberosHour).click();
|
||||
|
||||
cy.contains(defaultKerberosMinute).click();
|
||||
cy.contains(newKerberosMinute).click();
|
||||
|
||||
providersPage.changeTime(defaultKerberosDay, newKerberosDay);
|
||||
providersPage.changeTime(defaultKerberosHour, newKerberosHour);
|
||||
providersPage.changeTime(defaultKerberosMinute, newKerberosMinute);
|
||||
providersPage.save();
|
||||
|
||||
masthead.checkNotificationMessage(savedSuccessMessage);
|
||||
|
||||
sidebarPage.goToUserFederation();
|
||||
cy.wait(1000);
|
||||
|
||||
cy.get('[data-testid="keycloak-card-title"]')
|
||||
.contains(firstKerberosName)
|
||||
.click();
|
||||
cy.wait(1000);
|
||||
providersPage.clickExistingCard(firstKerberosName);
|
||||
|
||||
expect(cy.contains(newPolicy).should("exist"));
|
||||
expect(cy.contains(defaultPolicy).should("not.exist"));
|
||||
});
|
||||
|
||||
it("Change existing Kerberos provider and click button to cancel", () => {
|
||||
cy.visit("");
|
||||
loginPage.logIn();
|
||||
sidebarPage.goToUserFederation();
|
||||
|
||||
cy.get('[data-testid="keycloak-card-title"]')
|
||||
.contains(firstKerberosName)
|
||||
.click();
|
||||
cy.wait(1000);
|
||||
providersPage.clickExistingCard(firstKerberosName);
|
||||
providersPage.selectCacheType(newPolicy);
|
||||
|
||||
cy.contains(newKerberosDay).click();
|
||||
cy.contains(defaultKerberosDay).click();
|
||||
|
||||
cy.contains(newKerberosHour).click();
|
||||
cy.contains(defaultKerberosHour).click();
|
||||
|
||||
cy.contains(newKerberosMinute).click();
|
||||
cy.contains(defaultKerberosMinute).click();
|
||||
providersPage.changeTime(newKerberosDay, defaultKerberosDay);
|
||||
providersPage.changeTime(newKerberosHour, defaultKerberosHour);
|
||||
providersPage.changeTime(newKerberosMinute, defaultKerberosMinute);
|
||||
|
||||
providersPage.cancel();
|
||||
cy.wait(1000);
|
||||
|
||||
cy.wait(1000);
|
||||
cy.get('[data-testid="keycloak-card-title"]')
|
||||
.contains(firstKerberosName)
|
||||
.click();
|
||||
cy.wait(1000);
|
||||
providersPage.clickExistingCard(firstKerberosName);
|
||||
providersPage.selectCacheType(newPolicy);
|
||||
|
||||
expect(cy.contains(newKerberosDay).should("exist"));
|
||||
expect(cy.contains(newKerberosHour).should("exist"));
|
||||
expect(cy.contains(newKerberosMinute).should("exist"));
|
||||
|
||||
expect(cy.contains(defaultKerberosMinute).should("not.exist"));
|
||||
|
||||
sidebarPage.goToUserFederation();
|
||||
});
|
||||
|
||||
it("Disable an existing Kerberos provider", () => {
|
||||
cy.visit("");
|
||||
loginPage.logIn();
|
||||
sidebarPage.goToUserFederation();
|
||||
|
||||
cy.get('[data-testid="keycloak-card-title"]')
|
||||
.contains(firstKerberosName)
|
||||
.click();
|
||||
cy.wait(1000);
|
||||
|
||||
providersPage.clickExistingCard(firstKerberosName);
|
||||
providersPage.disableEnabledSwitch();
|
||||
|
||||
modalUtils.checkModalTitle(disableModalTitle).confirmModal();
|
||||
|
||||
masthead.checkNotificationMessage(savedSuccessMessage);
|
||||
|
||||
sidebarPage.goToUserFederation();
|
||||
masthead.checkNotificationMessage(savedSuccessMessage);
|
||||
|
||||
sidebarPage.goToUserFederation();
|
||||
|
||||
cy.wait(1000);
|
||||
expect(cy.contains("Disabled").should("exist"));
|
||||
});
|
||||
|
||||
it("Enable an existing previously-disabled Kerberos provider", () => {
|
||||
cy.visit("");
|
||||
loginPage.logIn();
|
||||
sidebarPage.goToUserFederation();
|
||||
|
||||
cy.get('[data-testid="keycloak-card-title"]')
|
||||
.contains(firstKerberosName)
|
||||
.click();
|
||||
cy.wait(1000);
|
||||
|
||||
providersPage.clickExistingCard(firstKerberosName);
|
||||
providersPage.enableEnabledSwitch();
|
||||
|
||||
masthead.checkNotificationMessage(savedSuccessMessage);
|
||||
|
||||
sidebarPage.goToUserFederation();
|
||||
|
||||
cy.wait(1000);
|
||||
expect(cy.contains("Enabled").should("exist"));
|
||||
});
|
||||
|
||||
it("Create new Kerberos provider using the New Provider dropdown", () => {
|
||||
cy.visit("");
|
||||
loginPage.logIn();
|
||||
sidebarPage.goToUserFederation();
|
||||
providersPage.clickMenuCommand("Add new provider", "Kerberos");
|
||||
|
||||
cy.contains("Add new provider").click();
|
||||
cy.contains("Kerberos").click();
|
||||
providersPage.fillKerberosRequiredData(
|
||||
secondKerberosName,
|
||||
secondKerberosRealm,
|
||||
|
@ -186,39 +137,22 @@ describe("User Fed Kerberos tests", () => {
|
|||
secondKerberosKeytab
|
||||
);
|
||||
providersPage.save();
|
||||
masthead.checkNotificationMessage(createdSuccessMessage);
|
||||
|
||||
masthead.checkNotificationMessage(createdSuccessMessage);
|
||||
sidebarPage.goToUserFederation();
|
||||
});
|
||||
|
||||
it("Delete a Kerberos provider from card view using the card's menu", () => {
|
||||
cy.visit("");
|
||||
loginPage.logIn();
|
||||
sidebarPage.goToUserFederation();
|
||||
|
||||
cy.get('[data-testid="my-kerberos-2-dropdown"]').click();
|
||||
cy.get('[data-testid="card-delete"]').click();
|
||||
providersPage.deleteCardFromCard(secondKerberosName);
|
||||
|
||||
modalUtils.checkModalTitle(deleteModalTitle).confirmModal();
|
||||
|
||||
masthead.checkNotificationMessage(deletedSuccessMessage);
|
||||
});
|
||||
|
||||
it("Delete a Kerberos provider using the Settings view's Action menu", () => {
|
||||
cy.visit("");
|
||||
loginPage.logIn();
|
||||
sidebarPage.goToUserFederation();
|
||||
|
||||
cy.get('[data-testid="keycloak-card-title"]')
|
||||
.contains(firstKerberosName)
|
||||
.click();
|
||||
cy.wait(1000);
|
||||
|
||||
cy.get('[data-testid="action-dropdown"]').click();
|
||||
cy.get('[data-testid="delete-kerberos-cmd"]').click();
|
||||
providersPage.deleteCardFromMenu("kerberos", firstKerberosName);
|
||||
|
||||
modalUtils.checkModalTitle(deleteModalTitle).confirmModal();
|
||||
|
||||
masthead.checkNotificationMessage(deletedSuccessMessage);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -103,8 +103,6 @@ describe("User Fed LDAP tests", () => {
|
|||
masthead.checkNotificationMessage(savedSuccessMessage);
|
||||
|
||||
sidebarPage.goToUserFederation();
|
||||
cy.wait(1000);
|
||||
|
||||
providersPage.clickExistingCard(firstLdapName);
|
||||
|
||||
expect(cy.contains(newPolicy).should("exist"));
|
||||
|
@ -144,7 +142,6 @@ describe("User Fed LDAP tests", () => {
|
|||
masthead.checkNotificationMessage(savedSuccessMessage);
|
||||
|
||||
sidebarPage.goToUserFederation();
|
||||
cy.wait(1000);
|
||||
expect(cy.contains("Disabled").should("exist"));
|
||||
});
|
||||
|
||||
|
@ -155,7 +152,6 @@ describe("User Fed LDAP tests", () => {
|
|||
masthead.checkNotificationMessage(savedSuccessMessage);
|
||||
|
||||
sidebarPage.goToUserFederation();
|
||||
cy.wait(1000);
|
||||
expect(cy.contains("Enabled").should("exist"));
|
||||
});
|
||||
|
||||
|
|
|
@ -113,6 +113,7 @@ export default class SidebarPage {
|
|||
|
||||
goToUserFederation() {
|
||||
cy.get(this.userFederationBtn).click();
|
||||
cy.wait(1000);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -19,13 +19,13 @@ export default class CreateKerberosProviderPage {
|
|||
cancelBtn: string;
|
||||
|
||||
constructor() {
|
||||
// KerberosSettingsRequired required input values
|
||||
this.kerberosNameInput = "data-testid=kerberos-name";
|
||||
this.kerberosRealmInput = "data-testid=kerberos-realm";
|
||||
this.kerberosPrincipalInput = "data-testid=kerberos-principal";
|
||||
this.kerberosKeytabInput = "data-testid=kerberos-keytab";
|
||||
|
||||
this.kerberosEnabledInput = "#Kerberos-switch";
|
||||
|
||||
// SettingsCache input values
|
||||
this.kerberosCacheDayInput = "#kc-eviction-day";
|
||||
this.kerberosCacheDayList = "#kc-eviction-day + ul";
|
||||
this.kerberosCacheHourInput = "#kc-eviction-hour";
|
||||
|
@ -35,11 +35,34 @@ export default class CreateKerberosProviderPage {
|
|||
this.kerberosCachePolicyInput = "#kc-cache-policy";
|
||||
this.kerberosCachePolicyList = "#kc-cache-policy + ul";
|
||||
|
||||
// Kerberos settings enabled switch
|
||||
this.kerberosEnabledInput = "#Kerberos-switch";
|
||||
|
||||
// Kerberos action buttons
|
||||
this.saveBtn = "data-testid=kerberos-save";
|
||||
this.cancelBtn = "data-testid=kerberos-cancel";
|
||||
}
|
||||
|
||||
//#region Required Settings
|
||||
changeTime(oldTime: string, newTime: string) {
|
||||
cy.contains(oldTime).click();
|
||||
cy.contains(newTime).click();
|
||||
return this;
|
||||
}
|
||||
|
||||
deleteCardFromCard(card: string) {
|
||||
cy.get(`[data-testid=${card}-dropdown]`).click();
|
||||
cy.get('[data-testid="card-delete"]').click();
|
||||
return this;
|
||||
}
|
||||
|
||||
deleteCardFromMenu(providerType: string, card: string) {
|
||||
this.clickExistingCard(card);
|
||||
cy.get('[data-testid="action-dropdown"]').click();
|
||||
cy.get(`[data-testid="delete-${providerType}-cmd"]`).click();
|
||||
return this;
|
||||
}
|
||||
|
||||
// Required fields - these always must be filled out when testing a save
|
||||
fillKerberosRequiredData(
|
||||
name: string,
|
||||
realm: string,
|
||||
|
@ -67,6 +90,24 @@ export default class CreateKerberosProviderPage {
|
|||
return this;
|
||||
}
|
||||
|
||||
clickExistingCard(cardName: string) {
|
||||
cy.get('[data-testid="keycloak-card-title"]').contains(cardName).click();
|
||||
cy.wait(1000);
|
||||
return this;
|
||||
}
|
||||
|
||||
clickMenuCommand(menu: string, command: string) {
|
||||
cy.contains("button", menu).click();
|
||||
cy.contains("li", command).click();
|
||||
return this;
|
||||
}
|
||||
|
||||
clickNewCard(providerType: string) {
|
||||
cy.get(`[data-testid=${providerType}-card]`).click();
|
||||
cy.wait(1000);
|
||||
return this;
|
||||
}
|
||||
|
||||
disableEnabledSwitch() {
|
||||
cy.get(this.kerberosEnabledInput).uncheck({ force: true });
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue