From 312927e3d27948396f820a48fe6e1d92cfa500ec Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Thu, 6 May 2021 10:37:55 +0200 Subject: [PATCH 1/5] removed invalid default value --- src/user-federation/ldap/LdapSettingsGeneral.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/user-federation/ldap/LdapSettingsGeneral.tsx b/src/user-federation/ldap/LdapSettingsGeneral.tsx index b3b3ac86ca..f47dd7fc03 100644 --- a/src/user-federation/ldap/LdapSettingsGeneral.tsx +++ b/src/user-federation/ldap/LdapSettingsGeneral.tsx @@ -83,7 +83,7 @@ export const LdapSettingsGeneral = ({ type="text" id="kc-console-display-name" name="name" - defaultValue="ldap" + defaultValue="" ref={form.register({ required: { value: true, From f6357ccc7cf9fb94b078afae7f9a7645d1cfbd9f Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Thu, 6 May 2021 10:38:45 +0200 Subject: [PATCH 2/5] put assign and initialize into one line --- cypress/support/pages/LoginPage.ts | 24 +-- .../support/pages/admin_console/Masthead.ts | 20 +-- .../manage/providers/ProviderPage.ts | 161 ++++++------------ cypress/support/util/ModalUtils.ts | 17 +- 4 files changed, 71 insertions(+), 151 deletions(-) diff --git a/cypress/support/pages/LoginPage.ts b/cypress/support/pages/LoginPage.ts index 7b0c9f3dcf..687ace17e4 100644 --- a/cypress/support/pages/LoginPage.ts +++ b/cypress/support/pages/LoginPage.ts @@ -1,22 +1,12 @@ export default class LoginPage { - userNameInput: string; - passwordInput: string; - submitBtn: string; - errorText: string; - userDrpDwn: string; - oldLoadContainer: string; - loadContainer: string; + private userNameInput = "#username"; + private passwordInput = "#password"; + private submitBtn = "#kc-login"; + private userDrpDwn = "#user-dropdown"; - constructor() { - this.userNameInput = "#username"; - this.passwordInput = "#password"; - this.submitBtn = "#kc-login"; - this.userDrpDwn = "#user-dropdown"; - - this.errorText = ".kc-feedback-text"; - this.oldLoadContainer = "#loading"; - this.loadContainer = "div.keycloak__loading-container"; - } + private errorText = ".kc-feedback-text"; + private oldLoadContainer = "#loading"; + private loadContainer = "div.keycloak__loading-container"; isLogInPage() { cy.get(this.userNameInput).should("exist"); diff --git a/cypress/support/pages/admin_console/Masthead.ts b/cypress/support/pages/admin_console/Masthead.ts index 23e184b05e..d752a2d111 100644 --- a/cypress/support/pages/admin_console/Masthead.ts +++ b/cypress/support/pages/admin_console/Masthead.ts @@ -1,19 +1,11 @@ export default class Masthead { - menuBtn: string; - logoBtn: string; - helpBtn: string; - userDrpDwn: string; - userDrpDwnKebab: string; - isMobile: boolean; - constructor() { - this.menuBtn = "#nav-toggle"; - this.logoBtn = "#masthead-logo"; - this.helpBtn = "#help"; + private menuBtn = "#nav-toggle"; + private logoBtn = "#masthead-logo"; + private helpBtn = "#help"; - this.userDrpDwn = "#user-dropdown"; - this.userDrpDwnKebab = "#user-dropdown-kebab"; - this.isMobile = false; - } + private userDrpDwn = "#user-dropdown"; + private userDrpDwnKebab = "#user-dropdown-kebab"; + private isMobile = false; isAdminConsole() { cy.get(this.logoBtn).should("exist"); diff --git a/cypress/support/pages/admin_console/manage/providers/ProviderPage.ts b/cypress/support/pages/admin_console/manage/providers/ProviderPage.ts index 2dc3386185..43470e3ae7 100644 --- a/cypress/support/pages/admin_console/manage/providers/ProviderPage.ts +++ b/cypress/support/pages/admin_console/manage/providers/ProviderPage.ts @@ -1,119 +1,64 @@ export default class ProviderPage { - kerberosNameInput: string; - kerberosRealmInput: string; - kerberosPrincipalInput: string; - kerberosKeytabInput: string; + // KerberosSettingsRequired required input values + private kerberosNameInput = "data-testid=kerberos-name"; + private kerberosRealmInput = "data-testid=kerberos-realm"; + private kerberosPrincipalInput = "data-testid=kerberos-principal"; + private kerberosKeytabInput = "data-testid=kerberos-keytab"; - ldapNameInput: string; - ldapVendorInput: string; - ldapVendorList: string; + // LdapSettingsGeneral required input values + private ldapNameInput = "data-testid=ldap-name"; + private ldapVendorInput = "#kc-vendor"; + private ldapVendorList = "#kc-vendor + ul"; - ldapConnectionUrlInput: string; - ldapBindTypeInput: string; - ldapBindTypeList: string; - ldapBindDnInput: string; - ldapBindCredsInput: string; + // LdapSettingsConnection required input values + private ldapConnectionUrlInput = "data-testid=ldap-connection-url"; + private ldapBindTypeInput = "#kc-bind-type"; + private ldapBindTypeList = "#kc-bind-type + ul"; + private ldapBindDnInput = "data-testid=ldap-bind-dn"; + private ldapBindCredsInput = "data-testid=ldap-bind-credentials"; - ldapUsersDnInput: string; - ldapUserLdapAttInput: string; - ldapRdnLdapAttInput: string; - ldapUuidLdapAttInput: string; - ldapUserObjClassesInput: string; + // LdapSettingsSearching required input values + private ldapUsersDnInput = "data-testid=ldap-users-dn"; + private ldapUserLdapAttInput = "data-testid=ldap-username-attribute"; + private ldapRdnLdapAttInput = "data-testid=ldap-rdn-attribute"; + private ldapUuidLdapAttInput = "data-testid=ldap-uuid-attribute"; + private ldapUserObjClassesInput = "data-testid=ldap-user-object-classes"; - cacheDayInput: string; - cacheDayList: string; - cacheHourInput: string; - cacheHourList: string; - cacheMinuteInput: string; - cacheMinuteList: string; - cachePolicyInput: string; - cachePolicyList: string; + // SettingsCache input values + private cacheDayInput = "#kc-eviction-day"; + private cacheDayList = "#kc-eviction-day + ul"; + private cacheHourInput = "#kc-eviction-hour"; + private cacheHourList = "#kc-eviction-hour + ul"; + private cacheMinuteInput = "#kc-eviction-minute"; + private cacheMinuteList = "#kc-eviction-minute + ul"; + private cachePolicyInput = "#kc-cache-policy"; + private cachePolicyList = "#kc-cache-policy + ul"; - userModelAttInput: string; - ldapAttInput: string; - userModelAttNameInput: string; - attValueInput: string; - ldapFullNameAttInput: string; - ldapAttNameInput: string; - ldapAttValueInput: string; - groupInput: string; + // Mapper required input values + private userModelAttInput = "data-testid=mapper-userModelAttribute-fld"; + private ldapAttInput = "data-testid=mapper-ldapAttribute-fld"; + private userModelAttNameInput = + "data-testid=mapper-userModelAttributeName-fld"; + private attValueInput = "data-testid=mapper-attributeValue-fld"; + private ldapFullNameAttInput = "data-testid=mapper-fullNameAttribute-fld"; + private ldapAttNameInput = "data-testid=mapper-ldapAttributeName-fld"; + private ldapAttValueInput = "data-testid=mapper-ldapAttributeValue-fld"; + private groupInput = "data-testid=mapper-group-fld"; - msadUserAcctMapper: string; - msadLdsUserAcctMapper: string; - userAttLdapMapper: string; - hcAttMapper: string; - certLdapMapper: string; - fullNameLdapMapper: string; - hcLdapAttMapper: string; - hcLdapGroupMapper: string; - // roleMapper: string; - // groupLdapMapper: string; - // hcLdapRoleMapper string; + // mapper types + private msadUserAcctMapper = "msad-user-account-control-mapper"; + private msadLdsUserAcctMapper = "msad-lds-user-account-control-mapper"; + private userAttLdapMapper = "user-attribute-ldap-mapper"; + private hcAttMapper = "hardcoded-attribute-mapper"; + private certLdapMapper = "certificate-ldap-mapper"; + private fullNameLdapMapper = "full-name-ldap-mapper"; + private hcLdapAttMapper = "hardcoded-ldap-attribute-mapper"; + private hcLdapGroupMapper = "hardcoded-ldap-group-mapper"; + // this.groupLdapMapper = "group-ldap-mapper"; + // this.roleMapper = "role-ldap-mapper"; + // this.hcLdapRoleMapper = "hardcoded-ldap-role-mapper"; - groupName: 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"; - - // LdapSettingsGeneral required input values - this.ldapNameInput = "data-testid=ldap-name"; - this.ldapVendorInput = "#kc-vendor"; - this.ldapVendorList = "#kc-vendor + ul"; - - // LdapSettingsConnection required input values - this.ldapConnectionUrlInput = "data-testid=ldap-connection-url"; - this.ldapBindTypeInput = "#kc-bind-type"; - this.ldapBindTypeList = "#kc-bind-type + ul"; - this.ldapBindDnInput = "data-testid=ldap-bind-dn"; - this.ldapBindCredsInput = "data-testid=ldap-bind-credentials"; - - // LdapSettingsSearching required input values - this.ldapUsersDnInput = "data-testid=ldap-users-dn"; - this.ldapUserLdapAttInput = "data-testid=ldap-username-attribute"; - this.ldapRdnLdapAttInput = "data-testid=ldap-rdn-attribute"; - this.ldapUuidLdapAttInput = "data-testid=ldap-uuid-attribute"; - this.ldapUserObjClassesInput = "data-testid=ldap-user-object-classes"; - - // SettingsCache input values - this.cacheDayInput = "#kc-eviction-day"; - this.cacheDayList = "#kc-eviction-day + ul"; - this.cacheHourInput = "#kc-eviction-hour"; - this.cacheHourList = "#kc-eviction-hour + ul"; - this.cacheMinuteInput = "#kc-eviction-minute"; - this.cacheMinuteList = "#kc-eviction-minute + ul"; - this.cachePolicyInput = "#kc-cache-policy"; - this.cachePolicyList = "#kc-cache-policy + ul"; - - // Mapper required input values - this.userModelAttInput = "data-testid=mapper-userModelAttribute-fld"; - this.ldapAttInput = "data-testid=mapper-ldapAttribute-fld"; - this.userModelAttNameInput = - "data-testid=mapper-userModelAttributeName-fld"; - this.attValueInput = "data-testid=mapper-attributeValue-fld"; - this.ldapFullNameAttInput = "data-testid=mapper-fullNameAttribute-fld"; - this.ldapAttNameInput = "data-testid=mapper-ldapAttributeName-fld"; - this.ldapAttValueInput = "data-testid=mapper-ldapAttributeValue-fld"; - this.groupInput = "data-testid=mapper-group-fld"; - - // mapper types - this.msadUserAcctMapper = "msad-user-account-control-mapper"; - this.msadLdsUserAcctMapper = "msad-lds-user-account-control-mapper"; - this.userAttLdapMapper = "user-attribute-ldap-mapper"; - this.hcAttMapper = "hardcoded-attribute-mapper"; - this.certLdapMapper = "certificate-ldap-mapper"; - this.fullNameLdapMapper = "full-name-ldap-mapper"; - this.hcLdapAttMapper = "hardcoded-ldap-attribute-mapper"; - this.hcLdapGroupMapper = "hardcoded-ldap-group-mapper"; - // this.groupLdapMapper = "group-ldap-mapper"; - // this.roleMapper = "role-ldap-mapper"; - // this.hcLdapRoleMapper = "hardcoded-ldap-role-mapper"; - - this.groupName = "my-mappers-group"; - } + private groupName = "my-mappers-group"; changeCacheTime(unit: string, time: string) { switch (unit) { diff --git a/cypress/support/util/ModalUtils.ts b/cypress/support/util/ModalUtils.ts index e7895bcbc0..b1c5ec4ff5 100644 --- a/cypress/support/util/ModalUtils.ts +++ b/cypress/support/util/ModalUtils.ts @@ -1,17 +1,10 @@ export default class ModalUtils { - modalTitle: string; - modalMessage: string; - confirmModalBtn: string; - cancelModalBtn: string; - closeModalBtn: string; - constructor() { - this.modalTitle = ".pf-c-modal-box .pf-c-modal-box__title-text"; - this.modalMessage = ".pf-c-modal-box .pf-c-modal-box__body"; + private modalTitle = ".pf-c-modal-box .pf-c-modal-box__title-text"; + private modalMessage = ".pf-c-modal-box .pf-c-modal-box__body"; - this.confirmModalBtn = "#modal-confirm"; - this.cancelModalBtn = "#modal-cancel"; - this.closeModalBtn = ".pf-c-modal-box .pf-m-plain"; - } + private confirmModalBtn = "#modal-confirm"; + private cancelModalBtn = "#modal-cancel"; + private closeModalBtn = ".pf-c-modal-box .pf-m-plain"; confirmModal() { cy.get(this.confirmModalBtn).click(); From dbd544be376f5c0d082accc3bd8c8542617aac2c Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Thu, 6 May 2021 11:06:20 +0200 Subject: [PATCH 3/5] don't use private fields --- cypress/integration/masthead_test.spec.ts | 3 +-- cypress/support/pages/admin_console/Masthead.ts | 7 +++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cypress/integration/masthead_test.spec.ts b/cypress/integration/masthead_test.spec.ts index 356a651383..ba7ae10b78 100644 --- a/cypress/integration/masthead_test.spec.ts +++ b/cypress/integration/masthead_test.spec.ts @@ -58,8 +58,7 @@ describe("Masthead tests with kebab menu", () => { }); it("shows kabab and hides regular menu", () => { - cy.get(masthead.userDrpDwn).should("not.exist"); - cy.get(masthead.userDrpDwnKebab).should("exist"); + masthead.checkKebabShown(); }); // TODO: Add test for help when using kebab menu. diff --git a/cypress/support/pages/admin_console/Masthead.ts b/cypress/support/pages/admin_console/Masthead.ts index d752a2d111..d8e70dd891 100644 --- a/cypress/support/pages/admin_console/Masthead.ts +++ b/cypress/support/pages/admin_console/Masthead.ts @@ -55,4 +55,11 @@ export default class Masthead { return this; } + + checkKebabShown() { + cy.get(this.userDrpDwn).should("not.exist"); + cy.get(this.userDrpDwnKebab).should("exist"); + + return this; + } } From c036253ac542dd8babaa4fc579ae89467a05d9dd Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Fri, 7 May 2021 09:45:42 +0200 Subject: [PATCH 4/5] fixed test by clearing field first --- .../pages/admin_console/manage/providers/ProviderPage.ts | 2 +- src/user-federation/ldap/LdapSettingsGeneral.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cypress/support/pages/admin_console/manage/providers/ProviderPage.ts b/cypress/support/pages/admin_console/manage/providers/ProviderPage.ts index 43470e3ae7..659cfb7296 100644 --- a/cypress/support/pages/admin_console/manage/providers/ProviderPage.ts +++ b/cypress/support/pages/admin_console/manage/providers/ProviderPage.ts @@ -117,7 +117,7 @@ export default class ProviderPage { fillLdapRequiredGeneralData(name: string, vendor: string) { if (name) { - cy.get(`[${this.ldapNameInput}]`).type(name); + cy.get(`[${this.ldapNameInput}]`).clear().type(name); } if (vendor) { cy.get(this.ldapVendorInput).click(); diff --git a/src/user-federation/ldap/LdapSettingsGeneral.tsx b/src/user-federation/ldap/LdapSettingsGeneral.tsx index f47dd7fc03..b3b3ac86ca 100644 --- a/src/user-federation/ldap/LdapSettingsGeneral.tsx +++ b/src/user-federation/ldap/LdapSettingsGeneral.tsx @@ -83,7 +83,7 @@ export const LdapSettingsGeneral = ({ type="text" id="kc-console-display-name" name="name" - defaultValue="" + defaultValue="ldap" ref={form.register({ required: { value: true, From fc6d2e7ecff14b364c812f4853cb04ddc9e35197 Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Fri, 7 May 2021 12:12:31 +0200 Subject: [PATCH 5/5] fixed test?? --- .../support/pages/admin_console/manage/groups/GroupModal.ts | 3 +-- .../manage/identity_providers/CreateProviderPage.ts | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cypress/support/pages/admin_console/manage/groups/GroupModal.ts b/cypress/support/pages/admin_console/manage/groups/GroupModal.ts index 1650304366..202fdaf67a 100644 --- a/cypress/support/pages/admin_console/manage/groups/GroupModal.ts +++ b/cypress/support/pages/admin_console/manage/groups/GroupModal.ts @@ -10,8 +10,7 @@ export default class GroupModal { } fillGroupForm(name = "") { - cy.get('[data-testid=groupNameInput]').clear(); - cy.get('[data-testid=groupNameInput]').type(name); + cy.getId(this.nameInput).clear().type(name); return this; } diff --git a/cypress/support/pages/admin_console/manage/identity_providers/CreateProviderPage.ts b/cypress/support/pages/admin_console/manage/identity_providers/CreateProviderPage.ts index a2a8a85958..bad24889ae 100644 --- a/cypress/support/pages/admin_console/manage/identity_providers/CreateProviderPage.ts +++ b/cypress/support/pages/admin_console/manage/identity_providers/CreateProviderPage.ts @@ -43,7 +43,7 @@ export default class CreateProviderPage { } clickCreateDropdown() { - cy.getId(this.addProviderDropdown).click(); + cy.getId(this.addProviderDropdown, { timeout: 10000 }).click(); return this; }