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

View file

@ -67,7 +67,26 @@ export default class CreateLdapProviderPage {
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) {
if (name) {
cy.get(`[${this.ldapNameInput}]`).type(name);
@ -132,12 +151,24 @@ export default class CreateLdapProviderPage {
return this;
}
clickProviderCard(cardName: string) {
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.ldapEnabledInput).uncheck({ force: true });
return this;