abstracted and simplified tests

This commit is contained in:
mfrances 2021-03-02 10:23:21 -05:00
parent bfef63081b
commit de5765ae6f
2 changed files with 49 additions and 48 deletions

View file

@ -63,8 +63,7 @@ describe("User Fed LDAP tests", () => {
}); });
it("Create Ldap provider from empty state", () => { it("Create Ldap provider from empty state", () => {
cy.get("[data-testid=ldap-card]").click(); providersPage.clickNewCard("ldap");
providersPage.fillLdapRequiredGeneralData(firstLdapName, firstLdapVendor); providersPage.fillLdapRequiredGeneralData(firstLdapName, firstLdapVendor);
providersPage.fillLdapRequiredConnectionData( providersPage.fillLdapRequiredConnectionData(
connectionUrl, connectionUrl,
@ -87,18 +86,12 @@ describe("User Fed LDAP tests", () => {
}); });
it("Update an existing LDAP provider and save", () => { it("Update an existing LDAP provider and save", () => {
providersPage.clickProviderCard(firstLdapName); providersPage.clickExistingCard(firstLdapName);
providersPage.selectCacheType(newPolicy); providersPage.selectCacheType(newPolicy);
cy.contains(defaultLdapDay).click(); providersPage.changeTime(defaultLdapDay, newLdapDay);
cy.contains(newLdapDay).click(); providersPage.changeTime(defaultLdapHour, newLdapHour);
providersPage.changeTime(defaultLdapMinute, newLdapMinute);
cy.contains(defaultLdapHour).click();
cy.contains(newLdapHour).click();
cy.contains(defaultLdapMinute).click();
cy.contains(newLdapMinute).click();
providersPage.save(); providersPage.save();
masthead.checkNotificationMessage(savedSuccessMessage); masthead.checkNotificationMessage(savedSuccessMessage);
@ -106,29 +99,24 @@ describe("User Fed LDAP tests", () => {
sidebarPage.goToUserFederation(); sidebarPage.goToUserFederation();
cy.wait(1000); cy.wait(1000);
providersPage.clickProviderCard(firstLdapName); providersPage.clickExistingCard(firstLdapName);
expect(cy.contains(newPolicy).should("exist")); expect(cy.contains(newPolicy).should("exist"));
expect(cy.contains(defaultPolicy).should("not.exist")); expect(cy.contains(defaultPolicy).should("not.exist"));
}); });
it("Change existing LDAP provider and click button to cancel", () => { it("Change existing LDAP provider and click button to cancel", () => {
providersPage.clickProviderCard(firstLdapName); providersPage.clickExistingCard(firstLdapName);
providersPage.selectCacheType(newPolicy); providersPage.selectCacheType(newPolicy);
cy.contains(newLdapDay).click(); providersPage.changeTime(newLdapDay, defaultLdapDay);
cy.contains(defaultLdapDay).click(); providersPage.changeTime(newLdapHour, defaultLdapHour);
providersPage.changeTime(newLdapMinute, defaultLdapMinute);
cy.contains(newLdapHour).click();
cy.contains(defaultLdapHour).click();
cy.contains(newLdapMinute).click();
cy.contains(defaultLdapMinute).click();
providersPage.cancel(); providersPage.cancel();
cy.wait(1000); cy.wait(1000);
providersPage.clickProviderCard(firstLdapName); providersPage.clickExistingCard(firstLdapName);
providersPage.selectCacheType(newPolicy); providersPage.selectCacheType(newPolicy);
expect(cy.contains(newLdapDay).should("exist")); expect(cy.contains(newLdapDay).should("exist"));
@ -140,41 +128,33 @@ describe("User Fed LDAP tests", () => {
}); });
it("Disable an existing LDAP provider", () => { it("Disable an existing LDAP provider", () => {
providersPage.clickProviderCard(firstLdapName); providersPage.clickExistingCard(firstLdapName);
providersPage.disableEnabledSwitch(); providersPage.disableEnabledSwitch();
modalUtils.checkModalTitle(disableModalTitle).confirmModal(); modalUtils.checkModalTitle(disableModalTitle).confirmModal();
masthead.checkNotificationMessage(savedSuccessMessage); masthead.checkNotificationMessage(savedSuccessMessage);
sidebarPage.goToUserFederation(); sidebarPage.goToUserFederation();
masthead.checkNotificationMessage(savedSuccessMessage); masthead.checkNotificationMessage(savedSuccessMessage);
sidebarPage.goToUserFederation(); sidebarPage.goToUserFederation();
cy.wait(1000); cy.wait(1000);
expect(cy.contains("Disabled").should("exist")); expect(cy.contains("Disabled").should("exist"));
}); });
it("Enable an existing previously-disabled LDAP provider", () => { it("Enable an existing previously-disabled LDAP provider", () => {
providersPage.clickProviderCard(firstLdapName); providersPage.clickExistingCard(firstLdapName);
providersPage.enableEnabledSwitch(); providersPage.enableEnabledSwitch();
masthead.checkNotificationMessage(savedSuccessMessage); masthead.checkNotificationMessage(savedSuccessMessage);
sidebarPage.goToUserFederation(); sidebarPage.goToUserFederation();
cy.wait(1000); cy.wait(1000);
expect(cy.contains("Enabled").should("exist")); expect(cy.contains("Enabled").should("exist"));
}); });
it("Create new LDAP provider using the New Provider dropdown", () => { it("Create new LDAP provider using the New Provider dropdown", () => {
// cy get contains providersPage.clickMenuCommand("Add new provider", "LDAP");
cy.contains("button", "Add new provider").click();
cy.contains("li", "LDAP").click();
providersPage.fillLdapRequiredGeneralData(secondLdapName, secondLdapVendor); providersPage.fillLdapRequiredGeneralData(secondLdapName, secondLdapVendor);
providersPage.fillLdapRequiredConnectionData( providersPage.fillLdapRequiredConnectionData(
connectionUrl, connectionUrl,
@ -189,30 +169,20 @@ describe("User Fed LDAP tests", () => {
secondUuidLdapAtt, secondUuidLdapAtt,
secondUserObjClasses secondUserObjClasses
); );
providersPage.save(); providersPage.save();
masthead.checkNotificationMessage(createdSuccessMessage); masthead.checkNotificationMessage(createdSuccessMessage);
sidebarPage.goToUserFederation(); sidebarPage.goToUserFederation();
}); });
it("Delete an LDAP provider from card view using the card's menu", () => { it("Delete an LDAP provider from card view using the card's menu", () => {
cy.get('[data-testid="my-ldap-2-dropdown"]').click(); providersPage.deleteCardFromCard(secondLdapName);
cy.get('[data-testid="card-delete"]').click();
modalUtils.checkModalTitle(deleteModalTitle).confirmModal(); modalUtils.checkModalTitle(deleteModalTitle).confirmModal();
masthead.checkNotificationMessage(deletedSuccessMessage); masthead.checkNotificationMessage(deletedSuccessMessage);
}); });
it("Delete an LDAP provider using the Settings view's Action menu", () => { it("Delete an LDAP provider using the Settings view's Action menu", () => {
providersPage.clickProviderCard(firstLdapName); providersPage.deleteCardFromMenu(firstLdapName);
cy.get('[data-testid="action-dropdown"]').click();
cy.get('[data-testid="delete-ldap-cmd"]').click();
modalUtils.checkModalTitle(deleteModalTitle).confirmModal(); modalUtils.checkModalTitle(deleteModalTitle).confirmModal();
masthead.checkNotificationMessage(deletedSuccessMessage); masthead.checkNotificationMessage(deletedSuccessMessage);
}); });
}); });

View file

@ -67,7 +67,26 @@ export default class CreateLdapProviderPage {
this.cancelBtn = "data-testid=ldap-cancel"; this.cancelBtn = "data-testid=ldap-cancel";
} }
// Required fields - these always must be filled out when testing a save, everything else can feasibly be left blank (TEST THIS) 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(card: string) {
this.clickExistingCard(card);
cy.get('[data-testid="action-dropdown"]').click();
cy.get('[data-testid="delete-ldap-cmd"]').click();
return this;
}
// Required fields - these always must be filled out when testing a save
fillLdapRequiredGeneralData(name: string, vendor: string) { fillLdapRequiredGeneralData(name: string, vendor: string) {
if (name) { if (name) {
cy.get(`[${this.ldapNameInput}]`).type(name); cy.get(`[${this.ldapNameInput}]`).type(name);
@ -132,12 +151,24 @@ export default class CreateLdapProviderPage {
return this; return this;
} }
clickProviderCard(cardName: string) { clickExistingCard(cardName: string) {
cy.get('[data-testid="keycloak-card-title"]').contains(cardName).click(); cy.get('[data-testid="keycloak-card-title"]').contains(cardName).click();
cy.wait(1000); cy.wait(1000);
return this; 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() { disableEnabledSwitch() {
cy.get(this.ldapEnabledInput).uncheck({ force: true }); cy.get(this.ldapEnabledInput).uncheck({ force: true });
return this; return this;