search tests for ldap mappers (#2275)

This commit is contained in:
mfrances17 2022-03-21 02:45:34 -04:00 committed by GitHub
parent 44f0306840
commit 73958176f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -45,9 +45,22 @@ const mapperDeleteTitle = "Delete mapping?";
const msadUserAcctMapper = "msad-user-account-control-mapper"; const msadUserAcctMapper = "msad-user-account-control-mapper";
const msadLdsUserAcctMapper = "msad-lds-user-account-control-mapper"; const msadLdsUserAcctMapper = "msad-lds-user-account-control-mapper";
const userAttLdapMapper = "user-attribute-ldap-mapper"; const userAttLdapMapper = "user-attribute-ldap-mapper";
const certLdapMapper = "certificate-ldap-mapper";
const fullNameLdapMapper = "full-name-ldap-mapper"; const fullNameLdapMapper = "full-name-ldap-mapper";
const groupLdapMapper = "group-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 // Used by "Delete default mappers" test
const creationDateMapper = "creation date"; const creationDateMapper = "creation date";
@ -170,7 +183,8 @@ describe("User Fed LDAP mapper tests", () => {
masthead.checkNotificationMessage(mapperDeletedSuccess); 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", () => { it("Create user account control mapper", () => {
providersPage.clickExistingCard(ldapName); providersPage.clickExistingCard(ldapName);
providersPage.goToMappers(); providersPage.goToMappers();
@ -189,15 +203,6 @@ describe("User Fed LDAP mapper tests", () => {
listingPage.itemExist(msadLdsUserAcctMapper, true); 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", () => { it("Create user attribute ldap mapper", () => {
providersPage.clickExistingCard(ldapName); providersPage.clickExistingCard(ldapName);
providersPage.goToMappers(); providersPage.goToMappers();
@ -225,6 +230,34 @@ describe("User Fed LDAP mapper tests", () => {
listingPage.itemExist(groupLdapMapper, true); 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 *** // *** test cleanup ***
it("Cleanup - delete LDAP provider", () => { it("Cleanup - delete LDAP provider", () => {
providersPage.deleteCardFromMenu(ldapName); providersPage.deleteCardFromMenu(ldapName);