From 73958176f575fc0d928d998c06829b3821afbc31 Mon Sep 17 00:00:00 2001 From: mfrances17 <39063664+mfrances17@users.noreply.github.com> Date: Mon, 21 Mar 2022 02:45:34 -0400 Subject: [PATCH] search tests for ldap mappers (#2275) --- .../user_fed_ldap_mapper_test.spec.ts | 55 +++++++++++++++---- 1 file changed, 44 insertions(+), 11 deletions(-) diff --git a/cypress/integration/user_fed_ldap_mapper_test.spec.ts b/cypress/integration/user_fed_ldap_mapper_test.spec.ts index e88e8e34ff..98e8445b76 100644 --- a/cypress/integration/user_fed_ldap_mapper_test.spec.ts +++ b/cypress/integration/user_fed_ldap_mapper_test.spec.ts @@ -45,9 +45,22 @@ const mapperDeleteTitle = "Delete mapping?"; const msadUserAcctMapper = "msad-user-account-control-mapper"; const msadLdsUserAcctMapper = "msad-lds-user-account-control-mapper"; const userAttLdapMapper = "user-attribute-ldap-mapper"; -const certLdapMapper = "certificate-ldap-mapper"; const fullNameLdapMapper = "full-name-ldap-mapper"; const groupLdapMapper = "group-ldap-mapper"; +const certLdapMapper = "certificate-ldap-mapper"; + +const mapperNames = [ + `${msadUserAcctMapper}-test`, + `${msadLdsUserAcctMapper}-test`, + `${userAttLdapMapper}-test`, + `${fullNameLdapMapper}-test`, + `${groupLdapMapper}-test`, +]; +const multiMapperNames = mapperNames.slice(2); +const singleMapperName = mapperNames.slice(4); +const uniqueSearchTerm = "group"; +const multipleSearchTerm = "ldap"; +const nonexistingSearchTerm = "redhat"; // Used by "Delete default mappers" test const creationDateMapper = "creation date"; @@ -170,7 +183,8 @@ describe("User Fed LDAP mapper tests", () => { masthead.checkNotificationMessage(mapperDeletedSuccess); }); - // create one of each mapper type + // create one of each non-hardcoded mapper type except + // certificate ldap mapper which was already tested in CRUD section it("Create user account control mapper", () => { providersPage.clickExistingCard(ldapName); providersPage.goToMappers(); @@ -189,15 +203,6 @@ describe("User Fed LDAP mapper tests", () => { listingPage.itemExist(msadLdsUserAcctMapper, true); }); - it("Create certificate ldap mapper", () => { - providersPage.clickExistingCard(ldapName); - providersPage.goToMappers(); - providersPage.createNewMapper(certLdapMapper); - providersPage.save("ldap-mapper"); - masthead.checkNotificationMessage(mapperCreatedSuccess); - listingPage.itemExist(certLdapMapper, true); - }); - it("Create user attribute ldap mapper", () => { providersPage.clickExistingCard(ldapName); providersPage.goToMappers(); @@ -225,6 +230,34 @@ describe("User Fed LDAP mapper tests", () => { listingPage.itemExist(groupLdapMapper, true); }); + it("Should return one search result for mapper with unique string", () => { + providersPage.clickExistingCard(ldapName); + providersPage.goToMappers(); + listingPage.searchItem(uniqueSearchTerm, false); + singleMapperName.map((mapperName) => listingPage.itemExist(mapperName)); + }); + + it("Should return multiple search results for mappers that share common string", () => { + providersPage.clickExistingCard(ldapName); + providersPage.goToMappers(); + listingPage.searchItem(multipleSearchTerm, false); + multiMapperNames.map((mapperName) => listingPage.itemExist(mapperName)); + }); + + it("Should return all mappers in search results when no string is specified", () => { + providersPage.clickExistingCard(ldapName); + providersPage.goToMappers(); + listingPage.searchItem("", false); + mapperNames.map((mapperName) => listingPage.itemExist(mapperName)); + }); + + it("Should return no search results for string that does not exist in any mappers", () => { + providersPage.clickExistingCard(ldapName); + providersPage.goToMappers(); + listingPage.searchItem(nonexistingSearchTerm, false); + cy.findByTestId(listingPage.emptyState).should("exist"); + }); + // *** test cleanup *** it("Cleanup - delete LDAP provider", () => { providersPage.deleteCardFromMenu(ldapName);