From 775885c56b63dfbde75044ae78f561bc175fe567 Mon Sep 17 00:00:00 2001 From: Jon Koops Date: Fri, 17 Sep 2021 15:23:34 +0200 Subject: [PATCH] Configure Cypress to use the correct types (#1168) --- cypress/integration/events_test.spec.ts | 14 +- .../integration/realm_settings_test.spec.ts | 152 +++++++++++------- cypress/integration/users_test.spec.ts | 10 +- cypress/plugins/{index.js => index.ts} | 8 +- cypress/support/{commands.js => commands.ts} | 4 +- cypress/support/{index.js => index.ts} | 0 cypress/support/pages/ViewHeaderPage.ts | 2 +- .../pages/admin_console/RealmSelector.ts | 4 +- .../pages/admin_console/SidebarPage.ts | 12 +- .../realm_settings/PartialImportModal.ts | 24 +-- .../configure/realm_settings/RealmSettings.ts | 2 +- .../admin_console/manage/RoleMappingTab.ts | 12 +- .../authentication/DuplicateFlowModal.ts | 4 +- .../manage/authentication/FlowDetail.ts | 19 ++- .../manage/clients/AdvancedTab.ts | 2 +- .../manage/clients/CreateClientPage.ts | 2 +- .../manage/clients/InitialAccessTokenTab.ts | 14 +- .../admin_console/manage/clients/KeysTab.ts | 19 ++- .../manage/events/AdminEventsTab.ts | 24 +-- .../manage/events/UserEventsTab.ts | 24 +-- .../manage/groups/GroupDetailPage.ts | 10 +- .../admin_console/manage/groups/GroupModal.ts | 8 +- .../manage/groups/MoveGroupModal.ts | 4 +- .../manage/groups/SearchGroup.ts | 4 +- .../identity_providers/AddMapperPage.ts | 32 ++-- .../identity_providers/CreateProviderPage.ts | 35 ++-- .../manage/identity_providers/OrderDialog.ts | 6 +- .../manage/providers/ProviderPage.ts | 2 +- .../manage/realm_roles/AssociatedRolesPage.ts | 24 +-- .../manage/realm_roles/CreateRealmRolePage.ts | 2 +- .../realm_settings/RealmSettingsPage.ts | 88 +++++----- .../manage/sessions/SessionsPage.ts | 40 ++--- .../manage/users/CreateUserPage.ts | 14 +- .../manage/users/UserDetailsPage.ts | 12 +- .../manage/users/UserGroupsPage.ts | 6 +- cypress/tsconfig.json | 2 + package-lock.json | 28 ++++ package.json | 1 + tsconfig.jest.json | 3 + tsconfig.json | 7 +- types/import.d.ts | 11 -- 41 files changed, 381 insertions(+), 310 deletions(-) rename cypress/plugins/{index.js => index.ts} (86%) rename cypress/support/{commands.js => commands.ts} (87%) rename cypress/support/{index.js => index.ts} (100%) delete mode 100644 types/import.d.ts diff --git a/cypress/integration/events_test.spec.ts b/cypress/integration/events_test.spec.ts index 20fe500911..cff28d7699 100644 --- a/cypress/integration/events_test.spec.ts +++ b/cypress/integration/events_test.spec.ts @@ -23,7 +23,7 @@ describe("Events tests", () => { it("Check search dropdown display", () => { sidebarPage.goToRealmSettings(); - cy.getId("rs-realm-events-tab").click(); + cy.findByTestId("rs-realm-events-tab").click(); realmSettingsPage .toggleSwitch(realmSettingsPage.enableEvents) @@ -67,20 +67,20 @@ describe("Events tests", () => { keycloakBefore(); loginPage.logIn(); sidebarPage.goToEvents(); - cy.getId("admin-events-tab").click(); + cy.findByTestId("admin-events-tab").click(); }); it("Check admin events search form fields display", () => { sidebarPage.goToRealmSettings(); - cy.getId("rs-realm-events-tab").click(); - cy.getId("rs-admin-events-tab").click(); + cy.findByTestId("rs-realm-events-tab").click(); + cy.findByTestId("rs-admin-events-tab").click(); realmSettingsPage .toggleSwitch(realmSettingsPage.enableAdminEvents) .save(realmSettingsPage.eventsAdminSave); sidebarPage.goToEvents(); - cy.getId("admin-events-tab").click(); + cy.findByTestId("admin-events-tab").click(); sidebarPage.waitForPageLoad(); adminEventsTab.shouldHaveFormFields(); }); @@ -91,7 +91,7 @@ describe("Events tests", () => { it("Check admin events search and removal work", () => { sidebarPage.goToEvents(); - cy.getId("admin-events-tab").click(); + cy.findByTestId("admin-events-tab").click(); adminEventsTab.shouldDoAdminEventsSearchAndRemoveChips(); }); @@ -109,7 +109,7 @@ describe("Events tests", () => { keycloakBefore(); loginPage.logIn(); sidebarPage.goToEvents(); - cy.getId("admin-events-tab").click(); + cy.findByTestId("admin-events-tab").click(); }); it("Check auth dialog opens and is not empty", () => { diff --git a/cypress/integration/realm_settings_test.spec.ts b/cypress/integration/realm_settings_test.spec.ts index 33f127dca3..f62a56dc4b 100644 --- a/cypress/integration/realm_settings_test.spec.ts +++ b/cypress/integration/realm_settings_test.spec.ts @@ -33,8 +33,8 @@ describe("Realm settings", () => { const goToKeys = () => { const keysUrl = `/auth/admin/realms/${realmName}/keys`; cy.intercept(keysUrl).as("keysFetch"); - cy.getId("rs-keys-tab").click(); - cy.getId("rs-keys-list-tab").click(); + cy.findByTestId("rs-keys-tab").click(); + cy.findByTestId("rs-keys-list-tab").click(); cy.wait(["@keysFetch"]); return this; @@ -44,27 +44,33 @@ describe("Realm settings", () => { const keysUrl = `/auth/admin/realms/${realmName}/keys`; cy.intercept(keysUrl).as("keysFetch"); - cy.getId("rs-keys-tab").click(); - cy.getId("rs-providers-tab").click(); - cy.getId("provider-name-link").contains("test_aes-generated").click(); + cy.findByTestId("rs-keys-tab").click(); + cy.findByTestId("rs-providers-tab").click(); + cy.findAllByTestId("provider-name-link") + .contains("test_aes-generated") + .click(); sidebarPage.goToRealmSettings(); - cy.getId("rs-keys-tab").click(); - cy.getId("rs-providers-tab").click(); - cy.getId("provider-name-link").contains("test_hmac-generated").click(); + cy.findByTestId("rs-keys-tab").click(); + cy.findByTestId("rs-providers-tab").click(); + cy.findAllByTestId("provider-name-link") + .contains("test_hmac-generated") + .click(); sidebarPage.goToRealmSettings(); - cy.getId("rs-keys-tab").click(); - cy.getId("rs-providers-tab").click(); - cy.getId("provider-name-link").contains("test_rsa").click(); + cy.findByTestId("rs-keys-tab").click(); + cy.findByTestId("rs-providers-tab").click(); + cy.findAllByTestId("provider-name-link").contains("test_rsa").click(); sidebarPage.goToRealmSettings(); - cy.getId("rs-keys-tab").click(); - cy.getId("rs-providers-tab").click(); - cy.getId("provider-name-link").contains("test_rsa-generated").click(); + cy.findByTestId("rs-keys-tab").click(); + cy.findByTestId("rs-providers-tab").click(); + cy.findAllByTestId("provider-name-link") + .contains("test_rsa-generated") + .click(); cy.wait(["@keysFetch"]); @@ -74,14 +80,14 @@ describe("Realm settings", () => { /*const deleteProvider = (providerName: string) => { const url = `/auth/admin/realms/${realmName}/users/*`; cy.intercept(url).as("reload"); - cy.getId("provider-name") + cy.findByTestId("provider-name") .contains(providerName) .parentsUntil(".pf-c-data-list__item-row") .find(".pf-c-dropdown__toggle") .click() - .getId(realmSettingsPage.deleteAction) + .findByTestId(realmSettingsPage.deleteAction) .click(); - cy.getId(realmSettingsPage.modalConfirm).click(); + cy.findByTestId(realmSettingsPage.modalConfirm).click(); cy.wait(["@reload"]); return this; @@ -113,7 +119,7 @@ describe("Realm settings", () => { it("Go to login tab", () => { sidebarPage.goToRealmSettings(); - cy.getId("rs-login-tab").click(); + cy.findByTestId("rs-login-tab").click(); realmSettingsPage.toggleSwitch(realmSettingsPage.userRegSwitch); realmSettingsPage.toggleSwitch(realmSettingsPage.forgotPwdSwitch); realmSettingsPage.toggleSwitch(realmSettingsPage.rememberMeSwitch); @@ -121,7 +127,7 @@ describe("Realm settings", () => { it("Go to email tab", () => { sidebarPage.goToRealmSettings(); - cy.getId("rs-email-tab").click(); + cy.findByTestId("rs-email-tab").click(); cy.wait(1000); @@ -133,13 +139,13 @@ describe("Realm settings", () => { realmSettingsPage.save(realmSettingsPage.emailSaveBtn); realmSettingsPage.fillHostField("localhost"); - cy.getId(realmSettingsPage.testConnectionButton).click(); + cy.findByTestId(realmSettingsPage.testConnectionButton).click(); realmSettingsPage.fillEmailField( "example" + (Math.random() + 1).toString(36).substring(7) + "@example.com" ); - cy.getId(realmSettingsPage.modalTestConnectionButton).click(); + cy.findByTestId(realmSettingsPage.modalTestConnectionButton).click(); masthead.checkNotificationMessage("Error! Failed to send email."); }); @@ -148,7 +154,7 @@ describe("Realm settings", () => { sidebarPage.goToRealmSettings(); cy.intercept(`/auth/admin/realms/${realmName}/keys`).as("load"); - cy.getId("rs-themes-tab").click(); + cy.findByTestId("rs-themes-tab").click(); cy.wait(["@load"]); realmSettingsPage.selectLoginThemeType("keycloak"); @@ -165,7 +171,7 @@ describe("Realm settings", () => { it("Enable user events", () => { cy.intercept("GET", `/auth/admin/realms/${realmName}/keys`).as("load"); sidebarPage.goToRealmSettings(); - cy.getId("rs-realm-events-tab").click(); + cy.findByTestId("rs-realm-events-tab").click(); cy.wait(["@load"]); realmSettingsPage @@ -202,37 +208,37 @@ describe("Realm settings", () => { it("Go to keys tab", () => { sidebarPage.goToRealmSettings(); - cy.getId("rs-keys-tab").click(); + cy.findByTestId("rs-keys-tab").click(); }); it("add Providers", () => { sidebarPage.goToRealmSettings(); - cy.getId("rs-keys-tab").click(); + cy.findByTestId("rs-keys-tab").click(); - cy.getId("rs-providers-tab").click(); + cy.findByTestId("rs-providers-tab").click(); realmSettingsPage.toggleAddProviderDropdown(); - cy.getId("option-aes-generated").click(); + cy.findByTestId("option-aes-generated").click(); realmSettingsPage.enterConsoleDisplayName("test_aes-generated"); realmSettingsPage.addProvider(); realmSettingsPage.toggleAddProviderDropdown(); - cy.getId("option-ecdsa-generated").click(); + cy.findByTestId("option-ecdsa-generated").click(); realmSettingsPage.enterConsoleDisplayName("test_ecdsa-generated"); realmSettingsPage.addProvider(); realmSettingsPage.toggleAddProviderDropdown(); - cy.getId("option-hmac-generated").click(); + cy.findByTestId("option-hmac-generated").click(); realmSettingsPage.enterConsoleDisplayName("test_hmac-generated"); realmSettingsPage.addProvider(); realmSettingsPage.toggleAddProviderDropdown(); - cy.getId("option-rsa-generated").click(); + cy.findByTestId("option-rsa-generated").click(); realmSettingsPage.enterConsoleDisplayName("test_rsa-generated"); realmSettingsPage.addProvider(); }); @@ -247,8 +253,8 @@ describe("Realm settings", () => { const url = `/auth/admin/realms/${realmName}/keys`; cy.intercept(url).as("load"); - cy.getId("rs-keys-tab").click(); - cy.getId("rs-providers-tab").click(); + cy.findByTestId("rs-keys-tab").click(); + cy.findByTestId("rs-providers-tab").click(); cy.wait("@load"); @@ -267,7 +273,7 @@ describe("Realm settings", () => { it("add locale", () => { sidebarPage.goToRealmSettings(); - cy.getId("rs-localization-tab").click(); + cy.findByTestId("rs-localization-tab").click(); addBundle(); @@ -279,9 +285,9 @@ describe("Realm settings", () => { it("Realm header settings", () => { sidebarPage.goToRealmSettings(); cy.get("#pf-tab-securityDefences-securityDefences").click(); - cy.getId("headers-form-tab-save").should("be.disabled"); + cy.findByTestId("headers-form-tab-save").should("be.disabled"); cy.get("#xFrameOptions").clear().type("DENY"); - cy.getId("headers-form-tab-save").should("be.enabled").click(); + cy.findByTestId("headers-form-tab-save").should("be.enabled").click(); masthead.checkNotificationMessage("Realm successfully updated"); }); @@ -289,7 +295,7 @@ describe("Realm settings", () => { it("add session data", () => { sidebarPage.goToRealmSettings(); - cy.getId("rs-sessions-tab").click(); + cy.findByTestId("rs-sessions-tab").click(); realmSettingsPage.populateSessionsPage(); realmSettingsPage.save("sessions-tab-save"); @@ -301,30 +307,48 @@ describe("Realm settings", () => { sidebarPage.goToAuthentication(); sidebarPage.goToRealmSettings(); - cy.getId("rs-sessions-tab").click(); + cy.findByTestId("rs-sessions-tab").click(); - cy.getId(realmSettingsPage.ssoSessionIdleInput).should("have.value", 1); - cy.getId(realmSettingsPage.ssoSessionMaxInput).should("have.value", 2); - cy.getId(realmSettingsPage.ssoSessionIdleRememberMeInput).should( + cy.findByTestId(realmSettingsPage.ssoSessionIdleInput).should( + "have.value", + 1 + ); + cy.findByTestId(realmSettingsPage.ssoSessionMaxInput).should( + "have.value", + 2 + ); + cy.findByTestId(realmSettingsPage.ssoSessionIdleRememberMeInput).should( "have.value", 3 ); - cy.getId(realmSettingsPage.ssoSessionMaxRememberMeInput).should( + cy.findByTestId(realmSettingsPage.ssoSessionMaxRememberMeInput).should( "have.value", 4 ); - cy.getId(realmSettingsPage.clientSessionIdleInput).should("have.value", 5); - cy.getId(realmSettingsPage.clientSessionMaxInput).should("have.value", 6); + cy.findByTestId(realmSettingsPage.clientSessionIdleInput).should( + "have.value", + 5 + ); + cy.findByTestId(realmSettingsPage.clientSessionMaxInput).should( + "have.value", + 6 + ); - cy.getId(realmSettingsPage.offlineSessionIdleInput).should("have.value", 7); - cy.getId(realmSettingsPage.offlineSessionMaxSwitch).should( + cy.findByTestId(realmSettingsPage.offlineSessionIdleInput).should( + "have.value", + 7 + ); + cy.findByTestId(realmSettingsPage.offlineSessionMaxSwitch).should( "have.value", "on" ); - cy.getId(realmSettingsPage.loginTimeoutInput).should("have.value", 9); - cy.getId(realmSettingsPage.loginActionTimeoutInput).should( + cy.findByTestId(realmSettingsPage.loginTimeoutInput).should( + "have.value", + 9 + ); + cy.findByTestId(realmSettingsPage.loginActionTimeoutInput).should( "have.value", 10 ); @@ -333,7 +357,7 @@ describe("Realm settings", () => { it("add token data", () => { sidebarPage.goToRealmSettings(); - cy.getId("rs-tokens-tab").click(); + cy.findByTestId("rs-tokens-tab").click(); realmSettingsPage.populateTokensPage(); realmSettingsPage.save("tokens-tab-save"); @@ -344,34 +368,46 @@ describe("Realm settings", () => { it("check that token data was saved", () => { sidebarPage.goToRealmSettings(); - cy.getId("rs-tokens-tab").click(); + cy.findByTestId("rs-tokens-tab").click(); - cy.getId(realmSettingsPage.accessTokenLifespanInput).should( + cy.findByTestId(realmSettingsPage.accessTokenLifespanInput).should( "have.value", 1 ); - cy.getId(realmSettingsPage.accessTokenLifespanImplicitInput).should( + cy.findByTestId(realmSettingsPage.accessTokenLifespanImplicitInput).should( "have.value", 2 ); - cy.getId(realmSettingsPage.clientLoginTimeoutInput).should("have.value", 3); - cy.getId(realmSettingsPage.userInitiatedActionLifespanInput).should( + cy.findByTestId(realmSettingsPage.clientLoginTimeoutInput).should( + "have.value", + 3 + ); + cy.findByTestId(realmSettingsPage.userInitiatedActionLifespanInput).should( "have.value", 4 ); - cy.getId(realmSettingsPage.defaultAdminInitatedInput).should( + cy.findByTestId(realmSettingsPage.defaultAdminInitatedInput).should( "have.value", 5 ); - cy.getId(realmSettingsPage.emailVerificationInput).should("have.value", 6); + cy.findByTestId(realmSettingsPage.emailVerificationInput).should( + "have.value", + 6 + ); - cy.getId(realmSettingsPage.idpEmailVerificationInput).should( + cy.findByTestId(realmSettingsPage.idpEmailVerificationInput).should( "have.value", 7 ); - cy.getId(realmSettingsPage.forgotPasswordInput).should("have.value", 8); + cy.findByTestId(realmSettingsPage.forgotPasswordInput).should( + "have.value", + 8 + ); - cy.getId(realmSettingsPage.executeActionsInput).should("have.value", 9); + cy.findByTestId(realmSettingsPage.executeActionsInput).should( + "have.value", + 9 + ); }); }); diff --git a/cypress/integration/users_test.spec.ts b/cypress/integration/users_test.spec.ts index de9bf7cb47..817c604f78 100644 --- a/cypress/integration/users_test.spec.ts +++ b/cypress/integration/users_test.spec.ts @@ -91,7 +91,7 @@ describe("Users test", () => { console.log(groupsList); groupsListCopy.forEach((element) => { - cy.getId(`${element}-check`).click(); + cy.findByTestId(`${element}-check`).click(); }); createUserPage.joinGroups(); @@ -127,7 +127,7 @@ describe("Users test", () => { const groupsListCopy = groupsList.slice(1, 2); groupsListCopy.forEach((element) => { - cy.getId(`${element}-check`).click(); + cy.findByTestId(`${element}-check`).click(); }); userGroupsPage.joinGroups(); @@ -139,7 +139,7 @@ describe("Users test", () => { // Go to user groups userGroupsPage.goToGroupsTab(); cy.contains("Leave").click(); - cy.getId("modalConfirm").click(); + cy.findByTestId("modalConfirm").click(); }); it("Go to user consents test", () => { @@ -147,8 +147,8 @@ describe("Users test", () => { listingPage.goToItemDetails(itemId); - cy.getId("user-consents-tab").click(); - cy.getId("empty-state").contains("No consents"); + cy.findByTestId("user-consents-tab").click(); + cy.findByTestId("empty-state").contains("No consents"); }); it("Delete user test", () => { diff --git a/cypress/plugins/index.js b/cypress/plugins/index.ts similarity index 86% rename from cypress/plugins/index.js rename to cypress/plugins/index.ts index f23745509c..6da8b13b6d 100644 --- a/cypress/plugins/index.js +++ b/cypress/plugins/index.ts @@ -1,4 +1,3 @@ -/// // *********************************************************** // This example plugins/index.js can be used to load plugins // @@ -12,11 +11,10 @@ // This function is called when a project is opened or re-opened (e.g. due to // the project's config changing) -/** - * @type {Cypress.PluginConfig} - */ // eslint-disable-next-line @typescript-eslint/no-unused-vars -module.exports = (on, config) => { +const configurePlugins: Cypress.PluginConfig = (on, config) => { // `on` is used to hook into various events Cypress emits // `config` is the resolved Cypress config }; + +export default configurePlugins; diff --git a/cypress/support/commands.js b/cypress/support/commands.ts similarity index 87% rename from cypress/support/commands.js rename to cypress/support/commands.ts index 4c5099a0f0..3816c58aa2 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.ts @@ -24,6 +24,4 @@ // -- This will overwrite an existing command -- // Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) -Cypress.Commands.add("getId", (selector, ...args) => { - return cy.get(`[data-testid="${selector}"]`, ...args); -}); +import "@testing-library/cypress/add-commands"; diff --git a/cypress/support/index.js b/cypress/support/index.ts similarity index 100% rename from cypress/support/index.js rename to cypress/support/index.ts diff --git a/cypress/support/pages/ViewHeaderPage.ts b/cypress/support/pages/ViewHeaderPage.ts index 126eef657a..bcb11f6a2b 100644 --- a/cypress/support/pages/ViewHeaderPage.ts +++ b/cypress/support/pages/ViewHeaderPage.ts @@ -2,7 +2,7 @@ export default class ListingPage { private actionMenu = "action-dropdown"; clickAction(action: string) { - cy.getId(this.actionMenu).click().getId(action).click(); + cy.findByTestId(this.actionMenu).click().findByTestId(action).click(); return this; } } diff --git a/cypress/support/pages/admin_console/RealmSelector.ts b/cypress/support/pages/admin_console/RealmSelector.ts index d785823209..d331462db7 100644 --- a/cypress/support/pages/admin_console/RealmSelector.ts +++ b/cypress/support/pages/admin_console/RealmSelector.ts @@ -5,7 +5,7 @@ export default class RealmSelector { private realmContextSelector = ".keycloak__realm_selector__context_selector"; shouldContainAll(realmsList: string[]) { - cy.getId(this.realmSelector) + cy.findByTestId(this.realmSelector) .scrollIntoView() .get("ul") .should((realms) => { @@ -19,7 +19,7 @@ export default class RealmSelector { } openRealmContextSelector() { - cy.getId(this.realmSelector).scrollIntoView(); + cy.findByTestId(this.realmSelector).scrollIntoView(); cy.get(this.realmContextSelector).click(); return this; diff --git a/cypress/support/pages/admin_console/SidebarPage.ts b/cypress/support/pages/admin_console/SidebarPage.ts index 0295d69fd7..689451b6ee 100644 --- a/cypress/support/pages/admin_console/SidebarPage.ts +++ b/cypress/support/pages/admin_console/SidebarPage.ts @@ -17,20 +17,20 @@ export default class SidebarPage { private userFederationBtn = "#nav-item-user-federation"; getCurrentRealm() { - return cy.getId(this.realmsDrpDwn).scrollIntoView().invoke("text"); + return cy.findByTestId(this.realmsDrpDwn).scrollIntoView().invoke("text"); } goToRealm(realmName: string) { - cy.getId(this.realmsDrpDwn).scrollIntoView().click(); - cy.getId(this.realmsList).get("ul").contains(realmName).click(); + cy.findByTestId(this.realmsDrpDwn).scrollIntoView().click(); + cy.findByTestId(this.realmsList).get("ul").contains(realmName).click(); return this; } goToCreateRealm() { - cy.getId(this.realmsDrpDwn).scrollIntoView(); - cy.getId(this.realmsDrpDwn).click(); - cy.getId(this.createRealmBtn).click(); + cy.findByTestId(this.realmsDrpDwn).scrollIntoView(); + cy.findByTestId(this.realmsDrpDwn).click(); + cy.findByTestId(this.createRealmBtn).click(); return this; } diff --git a/cypress/support/pages/admin_console/configure/realm_settings/PartialImportModal.ts b/cypress/support/pages/admin_console/configure/realm_settings/PartialImportModal.ts index bff8097c18..17c77482a9 100644 --- a/cypress/support/pages/admin_console/configure/realm_settings/PartialImportModal.ts +++ b/cypress/support/pages/admin_console/configure/realm_settings/PartialImportModal.ts @@ -2,7 +2,7 @@ export default class GroupModal { private openPartialImport = "openPartialImportModal"; open() { - cy.getId(this.openPartialImport).click(); + cy.findByTestId(this.openPartialImport).click(); return this; } @@ -20,43 +20,43 @@ export default class GroupModal { }; importButton() { - return cy.getId("import-button"); + return cy.findByTestId("import-button"); } cancelButton() { - return cy.getId("cancel-button"); + return cy.findByTestId("cancel-button"); } groupsCheckbox() { - return cy.getId("groups-checkbox"); + return cy.findByTestId("groups-checkbox"); } usersCheckbox() { - return cy.getId("users-checkbox"); + return cy.findByTestId("users-checkbox"); } userCount() { - return cy.getId("users-count"); + return cy.findByTestId("users-count"); } clientCount() { - return cy.getId("clients-count"); + return cy.findByTestId("clients-count"); } groupCount() { - return cy.getId("groups-count"); + return cy.findByTestId("groups-count"); } idpCount() { - return cy.getId("identityProviders-count"); + return cy.findByTestId("identityProviders-count"); } realmRolesCount() { - return cy.getId("realmRoles-count"); + return cy.findByTestId("realmRoles-count"); } clientRolesCount() { - return cy.getId("clientRoles-count"); + return cy.findByTestId("clientRoles-count"); } realmSelector() { @@ -65,6 +65,6 @@ export default class GroupModal { selectRealm(realm: string) { this.realmSelector().click(); - cy.getId(realm + "-select-option").click(); + cy.findByTestId(realm + "-select-option").click(); } } diff --git a/cypress/support/pages/admin_console/configure/realm_settings/RealmSettings.ts b/cypress/support/pages/admin_console/configure/realm_settings/RealmSettings.ts index 93d5e32b24..b15fc20262 100644 --- a/cypress/support/pages/admin_console/configure/realm_settings/RealmSettings.ts +++ b/cypress/support/pages/admin_console/configure/realm_settings/RealmSettings.ts @@ -2,7 +2,7 @@ export default class RealmSettings { private actionDropdown = "action-dropdown"; clickActionMenu() { - cy.getId(this.actionDropdown).click(); + cy.findByTestId(this.actionDropdown).click(); return this; } } diff --git a/cypress/support/pages/admin_console/manage/RoleMappingTab.ts b/cypress/support/pages/admin_console/manage/RoleMappingTab.ts index 151a438ffe..a63b6cb694 100644 --- a/cypress/support/pages/admin_console/manage/RoleMappingTab.ts +++ b/cypress/support/pages/admin_console/manage/RoleMappingTab.ts @@ -16,22 +16,22 @@ export default class RoleMappingTab { } goToScopeTab() { - cy.getId(this.scopeTab).click(); + cy.findByTestId(this.scopeTab).click(); return this; } clickAssignRole(notEmpty = true) { - cy.getId(notEmpty ? this.assignEmptyRole : this.assignRole).click(); + cy.findByTestId(notEmpty ? this.assignEmptyRole : this.assignRole).click(); return this; } clickAssign() { - cy.getId(this.assign).click(); + cy.findByTestId(this.assign).click(); return this; } clickUnAssign() { - cy.getId(this.unAssign).click(); + cy.findByTestId(this.unAssign).click(); return this; } @@ -52,7 +52,7 @@ export default class RoleMappingTab { checkRoles(roleNames: string[]) { if (roleNames.length) { - cy.getId(this.assignedRolesTable) + cy.findByTestId(this.assignedRolesTable) .get(this.namesColumn) .should((roles) => { for (let index = 0; index < roleNames.length; index++) { @@ -61,7 +61,7 @@ export default class RoleMappingTab { } }); } else { - cy.getId(this.assignedRolesTable).should("not.exist"); + cy.findByTestId(this.assignedRolesTable).should("not.exist"); } return this; } diff --git a/cypress/support/pages/admin_console/manage/authentication/DuplicateFlowModal.ts b/cypress/support/pages/admin_console/manage/authentication/DuplicateFlowModal.ts index 3e2728c59a..bd71e4f0dd 100644 --- a/cypress/support/pages/admin_console/manage/authentication/DuplicateFlowModal.ts +++ b/cypress/support/pages/admin_console/manage/authentication/DuplicateFlowModal.ts @@ -5,11 +5,11 @@ export default class DuplicateFlowModal { fill(name?: string, description?: string) { if (name) { - cy.getId(this.aliasInput).type(name); + cy.findByTestId(this.aliasInput).type(name); if (description) cy.get(this.descriptionInput).type(description); } - cy.getId(this.confirmButton).click(); + cy.findByTestId(this.confirmButton).click(); return this; } } diff --git a/cypress/support/pages/admin_console/manage/authentication/FlowDetail.ts b/cypress/support/pages/admin_console/manage/authentication/FlowDetail.ts index 60cb4ff9e8..86bed52f72 100644 --- a/cypress/support/pages/admin_console/manage/authentication/FlowDetail.ts +++ b/cypress/support/pages/admin_console/manage/authentication/FlowDetail.ts @@ -7,13 +7,13 @@ export default class FlowDetails { } private getExecution(name: string) { - return cy.getId(name); + return cy.findByTestId(name); } moveRowTo(from: string, to: string) { - cy.getId(from).trigger("dragstart").trigger("dragleave"); + cy.findByTestId(from).trigger("dragstart").trigger("dragleave"); - cy.getId(to) + cy.findByTestId(to) .trigger("dragenter") .trigger("dragover") .trigger("drop") @@ -38,15 +38,18 @@ export default class FlowDetails { } private clickEditDropdownForFlow(subFlowName: string, option: string) { - cy.getId(`${subFlowName}-edit-dropdown`).click().contains(option).click(); + cy.findByTestId(`${subFlowName}-edit-dropdown`) + .click() + .contains(option) + .click(); } addExecution(subFlowName: string, executionTestId: string) { this.clickEditDropdownForFlow(subFlowName, "Add step"); cy.get(".pf-c-pagination").should("exist"); - cy.getId(executionTestId).click(); - cy.getId("modal-add").click(); + cy.findByTestId(executionTestId).click(); + cy.findByTestId("modal-add").click(); return this; } @@ -55,8 +58,8 @@ export default class FlowDetails { this.clickEditDropdownForFlow(subFlowName, "Add condition"); cy.get(".pf-c-pagination").should("not.exist"); - cy.getId(executionTestId).click(); - cy.getId("modal-add").click(); + cy.findByTestId(executionTestId).click(); + cy.findByTestId("modal-add").click(); return this; } diff --git a/cypress/support/pages/admin_console/manage/clients/AdvancedTab.ts b/cypress/support/pages/admin_console/manage/clients/AdvancedTab.ts index 8796340907..dd9a4ff80c 100644 --- a/cypress/support/pages/admin_console/manage/clients/AdvancedTab.ts +++ b/cypress/support/pages/admin_console/manage/clients/AdvancedTab.ts @@ -65,7 +65,7 @@ export default class AdvancedTab { } clickRegisterNodeManually() { - cy.getId(this.registerNodeManually).click(); + cy.findByTestId(this.registerNodeManually).click(); return this; } diff --git a/cypress/support/pages/admin_console/manage/clients/CreateClientPage.ts b/cypress/support/pages/admin_console/manage/clients/CreateClientPage.ts index 8529228732..159f068ee3 100644 --- a/cypress/support/pages/admin_console/manage/clients/CreateClientPage.ts +++ b/cypress/support/pages/admin_console/manage/clients/CreateClientPage.ts @@ -66,7 +66,7 @@ export default class CreateClientPage { changeSwitches(switches: string[]) { for (const uiSwitch of switches) { - cy.getId(uiSwitch).check({ force: true }); + cy.findByTestId(uiSwitch).check({ force: true }); } return this; } diff --git a/cypress/support/pages/admin_console/manage/clients/InitialAccessTokenTab.ts b/cypress/support/pages/admin_console/manage/clients/InitialAccessTokenTab.ts index 9479a5e23f..96ede7cadc 100644 --- a/cypress/support/pages/admin_console/manage/clients/InitialAccessTokenTab.ts +++ b/cypress/support/pages/admin_console/manage/clients/InitialAccessTokenTab.ts @@ -8,17 +8,17 @@ export default class InitialAccessTokenTab { private saveBtn = "save"; goToInitialAccessTokenTab() { - cy.getId(this.initialAccessTokenTab).click(); + cy.findByTestId(this.initialAccessTokenTab).click(); return this; } shouldBeEmpty() { - cy.getId(this.emptyAction).should("exist"); + cy.findByTestId(this.emptyAction).should("exist"); return this; } shouldNotBeEmpty() { - cy.getId(this.emptyAction).should("not.exist"); + cy.findByTestId(this.emptyAction).should("not.exist"); return this; } @@ -32,14 +32,14 @@ export default class InitialAccessTokenTab { } createNewToken(expiration: number, count: number) { - cy.getId(this.emptyAction).click(); - cy.getId(this.expirationInput).type(`${expiration}`); - cy.getId(this.countInput).type(`${count}`); + cy.findByTestId(this.emptyAction).click(); + cy.findByTestId(this.expirationInput).type(`${expiration}`); + cy.findByTestId(this.countInput).type(`${count}`); return this; } save() { - cy.getId(this.saveBtn).click(); + cy.findByTestId(this.saveBtn).click(); return this; } } diff --git a/cypress/support/pages/admin_console/manage/clients/KeysTab.ts b/cypress/support/pages/admin_console/manage/clients/KeysTab.ts index af221e64ae..e53e59a6d9 100644 --- a/cypress/support/pages/admin_console/manage/clients/KeysTab.ts +++ b/cypress/support/pages/admin_console/manage/clients/KeysTab.ts @@ -14,22 +14,24 @@ export default class KeysTab { } checkSaveDisabled(disabled = true) { - cy.getId(this.saveKeys).should((!disabled ? "not." : "") + "be.disabled"); + cy.findByTestId(this.saveKeys).should( + (!disabled ? "not." : "") + "be.disabled" + ); return this; } toggleUseJwksUrl() { - cy.getId(this.useJwksUrl).click({ force: true }); + cy.findByTestId(this.useJwksUrl).click({ force: true }); return this; } clickGenerate() { - cy.getId(this.generate).click(); + cy.findByTestId(this.generate).click(); return this; } clickConfirm() { - cy.getId(this.confirm).click(); + cy.findByTestId(this.confirm).click(); return this; } @@ -38,12 +40,9 @@ export default class KeysTab { keyPassword: string, storePassword: string ) { - cy.getId(this.keyAlias) - .type(keyAlias) - .getId(this.keyPassword) - .type(keyPassword) - .getId(this.storePassword) - .type(storePassword); + cy.findByTestId(this.keyAlias).type(keyAlias); + cy.findByTestId(this.keyPassword).type(keyPassword); + cy.findByTestId(this.storePassword).type(storePassword); return this; } } diff --git a/cypress/support/pages/admin_console/manage/events/AdminEventsTab.ts b/cypress/support/pages/admin_console/manage/events/AdminEventsTab.ts index 349c0bbd3d..b7c2e727ff 100644 --- a/cypress/support/pages/admin_console/manage/events/AdminEventsTab.ts +++ b/cypress/support/pages/admin_console/manage/events/AdminEventsTab.ts @@ -24,7 +24,7 @@ export default class AdminEventsTab { authValDataRow = 'tbody > tr > [data-label="Value"]'; shouldHaveFormFields() { - cy.getId(this.searchAdminEventDrpDwnBtn).click(); + cy.findByTestId(this.searchAdminEventDrpDwnBtn).click(); cy.get(this.searchForm).contains("Resource types"); cy.get(this.searchForm).contains("Operation types"); cy.get(this.searchForm).contains("Resource path"); @@ -37,16 +37,16 @@ export default class AdminEventsTab { } shouldHaveSearchBtnDisabled() { - cy.getId(this.searchAdminEventDrpDwnBtn).click(); - cy.getId(this.searchEventsBtn).should("have.attr", "disabled"); + cy.findByTestId(this.searchAdminEventDrpDwnBtn).click(); + cy.findByTestId(this.searchEventsBtn).should("have.attr", "disabled"); } shouldDoAdminEventsSearchAndRemoveChips() { - cy.getId(this.searchAdminEventDrpDwnBtn).click(); - cy.getId(this.resourcePathInputFld).type("events/config"); + cy.findByTestId(this.searchAdminEventDrpDwnBtn).click(); + cy.findByTestId(this.resourcePathInputFld).type("events/config"); cy.intercept("/auth/admin/realms/master/admin-events*").as("eventsFetch"); - cy.getId(this.searchEventsBtn).click(); + cy.findByTestId(this.searchEventsBtn).click(); cy.wait("@eventsFetch"); cy.get("table").contains("td", "events/config").should("be.visible"); @@ -57,15 +57,15 @@ export default class AdminEventsTab { } shouldHaveSearchBtnEnabled() { - cy.getId(this.searchAdminEventDrpDwnBtn).click(); - cy.getId(this.ipAddressInputFld).type("11111"); - cy.getId(this.searchEventsBtn).should("not.have.attr", "disabled"); + cy.findByTestId(this.searchAdminEventDrpDwnBtn).click(); + cy.findByTestId(this.ipAddressInputFld).type("11111"); + cy.findByTestId(this.searchEventsBtn).should("not.have.attr", "disabled"); } shouldDoNoResultsSearch() { - cy.getId(this.searchAdminEventDrpDwnBtn).click(); - cy.getId(this.resourcePathInputFld).type("events/test"); - cy.getId(this.searchEventsBtn).click(); + cy.findByTestId(this.searchAdminEventDrpDwnBtn).click(); + cy.findByTestId(this.resourcePathInputFld).type("events/test"); + cy.findByTestId(this.searchEventsBtn).click(); cy.get(this.adminEventsTabTitle).contains("No events logged"); } diff --git a/cypress/support/pages/admin_console/manage/events/UserEventsTab.ts b/cypress/support/pages/admin_console/manage/events/UserEventsTab.ts index d9449b3384..be81f5720a 100644 --- a/cypress/support/pages/admin_console/manage/events/UserEventsTab.ts +++ b/cypress/support/pages/admin_console/manage/events/UserEventsTab.ts @@ -19,7 +19,7 @@ export default class UserEventsTab { } shouldHaveFormFields() { - cy.getId(this.searchEventDrpDwnBtn).click(); + cy.findByTestId(this.searchEventDrpDwnBtn).click(); cy.get(this.searchForm).contains("User ID"); cy.get(this.searchForm).contains("Event type"); cy.get(this.searchForm).contains("Client"); @@ -29,22 +29,22 @@ export default class UserEventsTab { } shouldHaveEventTypeOptions() { - cy.getId(this.searchEventDrpDwnBtn).click(); + cy.findByTestId(this.searchEventDrpDwnBtn).click(); cy.get(this.eventTypeList).should("exist"); } shouldHaveSearchBtnDisabled() { - cy.getId(this.searchEventDrpDwnBtn).click(); - cy.getId(this.searchEventsBtn).should("have.attr", "disabled"); + cy.findByTestId(this.searchEventDrpDwnBtn).click(); + cy.findByTestId(this.searchEventsBtn).should("have.attr", "disabled"); } shouldDoSearchAndRemoveChips() { - cy.getId(this.searchEventDrpDwnBtn).click(); + cy.findByTestId(this.searchEventDrpDwnBtn).click(); cy.get(this.eventTypeInputFld).type("LOGIN"); cy.get(this.eventTypeOption).contains("LOGIN").click(); cy.intercept("/auth/admin/realms/master/events*").as("eventsFetch"); - cy.getId(this.searchEventsBtn).click(); + cy.findByTestId(this.searchEventsBtn).click(); cy.wait("@eventsFetch"); cy.get("table").contains("td", "LOGIN"); @@ -59,15 +59,15 @@ export default class UserEventsTab { } shouldHaveSearchBtnEnabled() { - cy.getId(this.searchEventDrpDwnBtn).click(); - cy.getId(this.userIdInputFld).type("11111"); - cy.getId(this.searchEventsBtn).should("not.have.attr", "disabled"); + cy.findByTestId(this.searchEventDrpDwnBtn).click(); + cy.findByTestId(this.userIdInputFld).type("11111"); + cy.findByTestId(this.searchEventsBtn).should("not.have.attr", "disabled"); } shouldDoNoResultsSearch() { - cy.getId(this.searchEventDrpDwnBtn).click(); - cy.getId(this.userIdInputFld).type("test"); - cy.getId(this.searchEventsBtn).click(); + cy.findByTestId(this.searchEventDrpDwnBtn).click(); + cy.findByTestId(this.userIdInputFld).type("test"); + cy.findByTestId(this.searchEventsBtn).click(); cy.get(this.userEventsTabTitle).contains("No events logged"); } } diff --git a/cypress/support/pages/admin_console/manage/groups/GroupDetailPage.ts b/cypress/support/pages/admin_console/manage/groups/GroupDetailPage.ts index 9a28802809..97e6ac68f5 100644 --- a/cypress/support/pages/admin_console/manage/groups/GroupDetailPage.ts +++ b/cypress/support/pages/admin_console/manage/groups/GroupDetailPage.ts @@ -26,7 +26,7 @@ export default class GroupDetailPage { } clickMembersTab() { - cy.getId(this.memberTab).click(); + cy.findByTestId(this.memberTab).click(); return this; } @@ -61,22 +61,22 @@ export default class GroupDetailPage { } clickAdd() { - cy.getId(this.addMember).click(); + cy.findByTestId(this.addMember).click(); return this; } clickIncludeSubGroups() { - cy.getId(this.includeSubGroupsCheck).click(); + cy.findByTestId(this.includeSubGroupsCheck).click(); return this; } clickAttributesTab() { - cy.getId(this.attributesTab).click(); + cy.findByTestId(this.attributesTab).click(); return this; } clickAddMembers() { - cy.getId(this.addMembers).click(); + cy.findByTestId(this.addMembers).click(); return this; } diff --git a/cypress/support/pages/admin_console/manage/groups/GroupModal.ts b/cypress/support/pages/admin_console/manage/groups/GroupModal.ts index 93f4440077..3f9743a7a1 100644 --- a/cypress/support/pages/admin_console/manage/groups/GroupModal.ts +++ b/cypress/support/pages/admin_console/manage/groups/GroupModal.ts @@ -5,7 +5,7 @@ export default class GroupModal { open(name?: string) { if (name) { - cy.getId(name).click(); + cy.findByTestId(name).click(); } else { cy.get("button").contains("Create").click(); } @@ -13,18 +13,18 @@ export default class GroupModal { } fillGroupForm(name = "") { - cy.getId(this.nameInput).clear().type(name); + cy.findByTestId(this.nameInput).clear().type(name); return this; } clickCreate() { - cy.getId(this.createButton).click(); + cy.findByTestId(this.createButton).click(); return this; } clickRename() { - cy.getId(this.renameButton).click(); + cy.findByTestId(this.renameButton).click(); return this; } } diff --git a/cypress/support/pages/admin_console/manage/groups/MoveGroupModal.ts b/cypress/support/pages/admin_console/manage/groups/MoveGroupModal.ts index 5ffcc36790..c2b71da7b0 100644 --- a/cypress/support/pages/admin_console/manage/groups/MoveGroupModal.ts +++ b/cypress/support/pages/admin_console/manage/groups/MoveGroupModal.ts @@ -3,7 +3,7 @@ export default class MoveGroupModal { private title = ".pf-c-modal-box__title"; clickRow(groupName: string) { - cy.getId(groupName).click(); + cy.findByTestId(groupName).click(); return this; } @@ -18,7 +18,7 @@ export default class MoveGroupModal { } clickMove() { - cy.getId(this.moveButton).click(); + cy.findByTestId(this.moveButton).click(); return this; } } diff --git a/cypress/support/pages/admin_console/manage/groups/SearchGroup.ts b/cypress/support/pages/admin_console/manage/groups/SearchGroup.ts index 23152749bf..d313d0b579 100644 --- a/cypress/support/pages/admin_console/manage/groups/SearchGroup.ts +++ b/cypress/support/pages/admin_console/manage/groups/SearchGroup.ts @@ -3,12 +3,12 @@ export class SearchGroupPage { private searchButton = "search-button"; searchGroup(search: string) { - cy.getId(this.searchField).type(search); + cy.findByTestId(this.searchField).type(search); return this; } clickSearchButton() { - cy.getId(this.searchButton).click(); + cy.findByTestId(this.searchButton).click(); return this; } diff --git a/cypress/support/pages/admin_console/manage/identity_providers/AddMapperPage.ts b/cypress/support/pages/admin_console/manage/identity_providers/AddMapperPage.ts index 227c75f3cd..8558b63aae 100644 --- a/cypress/support/pages/admin_console/manage/identity_providers/AddMapperPage.ts +++ b/cypress/support/pages/admin_console/manage/identity_providers/AddMapperPage.ts @@ -18,12 +18,12 @@ export default class AddMapperPage { private addAssociatedRolesModalButton = "add-associated-roles-button"; goToMappersTab() { - cy.getId(this.mappersTab).click(); + cy.findByTestId(this.mappersTab).click(); return this; } clickAdd() { - cy.getId(this.noMappersAddMapperButton).click(); + cy.findByTestId(this.noMappersAddMapperButton).click(); return this; } @@ -33,12 +33,12 @@ export default class AddMapperPage { } saveNewMapper() { - cy.getId(this.newMapperSaveButton).click(); + cy.findByTestId(this.newMapperSaveButton).click(); return this; } toggleSwitch(switchName: string) { - cy.getId(switchName).click({ force: true }); + cy.findByTestId(switchName).click({ force: true }); return this; } @@ -50,17 +50,19 @@ export default class AddMapperPage { cy.get(this.syncmodeSelectToggle).click(); - cy.getId("legacy").click(); + cy.findByTestId("legacy").click(); cy.get(this.idpMapperSelectToggle).click(); - cy.getId(this.idpMapperSelect).contains("Attribute Importer").click(); + cy.findByTestId(this.idpMapperSelect) + .contains("Attribute Importer") + .click(); - cy.getId(this.userSessionAttribute).clear(); - cy.getId(this.userSessionAttribute).type("user session attribute"); - cy.getId(this.userSessionAttributeValue).clear(); + cy.findByTestId(this.userSessionAttribute).clear(); + cy.findByTestId(this.userSessionAttribute).type("user session attribute"); + cy.findByTestId(this.userSessionAttributeValue).clear(); - cy.getId(this.userSessionAttributeValue).type( + cy.findByTestId(this.userSessionAttributeValue).type( "user session attribute value" ); @@ -73,9 +75,9 @@ export default class AddMapperPage { cy.get(this.radio).eq(0).check(); - cy.getId(this.addAssociatedRolesModalButton).contains("Add").click(); + cy.findByTestId(this.addAssociatedRolesModalButton).contains("Add").click(); - cy.getId(this.mapperRoleInput).should("have.value", "admin"); + cy.findByTestId(this.mapperRoleInput).should("have.value", "admin"); return this; } @@ -87,11 +89,11 @@ export default class AddMapperPage { cy.get(this.syncmodeSelectToggle).click(); - cy.getId("inherit").click(); + cy.findByTestId("inherit").click(); cy.get(this.idpMapperSelectToggle).click(); - cy.getId(this.idpMapperSelect) + cy.findByTestId(this.idpMapperSelect) .contains("Hardcoded User Session Attribute") .click(); @@ -103,7 +105,7 @@ export default class AddMapperPage { this.toggleSwitch(this.regexAttributeValuesSwitch); - cy.getId(this.selectRoleButton).click(); + cy.findByTestId(this.selectRoleButton).click(); this.addRoleToMapperForm(); 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 ffe623828c..da90100ec3 100644 --- a/cypress/support/pages/admin_console/manage/identity_providers/CreateProviderPage.ts +++ b/cypress/support/pages/admin_console/manage/identity_providers/CreateProviderPage.ts @@ -11,12 +11,12 @@ export default class CreateProviderPage { private ssoServiceUrl = "sso-service-url"; checkVisible(name: string) { - cy.getId(`${name}-card`).should("exist"); + cy.findByTestId(`${name}-card`).should("exist"); return this; } clickCard(name: string) { - cy.getId(`${name}-card`).click(); + cy.findByTestId(`${name}-card`).click(); return this; } @@ -37,12 +37,14 @@ export default class CreateProviderPage { } checkAddButtonDisabled(disabled = true) { - cy.getId(this.addButton).should(!disabled ? "not." : "" + "be.disabled"); + cy.findByTestId(this.addButton).should( + !disabled ? "not." : "" + "be.disabled" + ); return this; } clickAdd() { - cy.getId(this.addButton).click(); + cy.findByTestId(this.addButton).click(); return this; } @@ -52,48 +54,51 @@ export default class CreateProviderPage { } clickItem(item: string) { - cy.getId(item).click(); + cy.findByTestId(item).click(); return this; } fill(id: string, secret = "") { - cy.getId(this.clientIdField).clear(); + cy.findByTestId(this.clientIdField).clear(); if (id) { - cy.getId(this.clientIdField).type(id); + cy.findByTestId(this.clientIdField).type(id); } if (secret) { - cy.getId(this.clientSecretField).type(secret); + cy.findByTestId(this.clientSecretField).type(secret); } return this; } fillDiscoveryUrl(value: string) { - cy.getId(this.discoveryEndpoint).type("x"); - cy.getId(this.discoveryEndpoint).clear().type(value).blur(); + cy.findByTestId(this.discoveryEndpoint).type("x"); + cy.findByTestId(this.discoveryEndpoint).clear().type(value).blur(); return this; } fillSsoServiceUrl(value: string) { - cy.getId(this.ssoServiceUrl).type("x"); - cy.getId(this.ssoServiceUrl).clear().type(value).blur(); + cy.findByTestId(this.ssoServiceUrl).type("x"); + cy.findByTestId(this.ssoServiceUrl).clear().type(value).blur(); return this; } shouldBeSuccessful() { - cy.getId(this.discoveryEndpoint).should("have.class", "pf-m-success"); + cy.findByTestId(this.discoveryEndpoint).should( + "have.class", + "pf-m-success" + ); return this; } shouldHaveAuthorizationUrl(value: string) { - cy.getId(this.authorizationUrl).should("have.value", value); + cy.findByTestId(this.authorizationUrl).should("have.value", value); return this; } toggleEntityDescriptor() { - cy.getId(this.useEntityDescriptorSwitch).click({ force: true }); + cy.findByTestId(this.useEntityDescriptorSwitch).click({ force: true }); return this; } } diff --git a/cypress/support/pages/admin_console/manage/identity_providers/OrderDialog.ts b/cypress/support/pages/admin_console/manage/identity_providers/OrderDialog.ts index e1bd6e70bd..bacbd45d09 100644 --- a/cypress/support/pages/admin_console/manage/identity_providers/OrderDialog.ts +++ b/cypress/support/pages/admin_console/manage/identity_providers/OrderDialog.ts @@ -5,14 +5,14 @@ export default class OrderDialog { private list = "manageOrderDataList"; openDialog() { - cy.getId(this.manageDisplayOrder).click({ force: true }); + cy.findByTestId(this.manageDisplayOrder).click({ force: true }); return this; } moveRowTo(from: string, to: string) { - cy.getId(from).trigger("dragstart").trigger("dragleave"); + cy.findByTestId(from).trigger("dragstart").trigger("dragleave"); - cy.getId(to) + cy.findByTestId(to) .trigger("dragenter") .trigger("dragover") .trigger("drop") diff --git a/cypress/support/pages/admin_console/manage/providers/ProviderPage.ts b/cypress/support/pages/admin_console/manage/providers/ProviderPage.ts index f225c27a8c..2797f12ec6 100644 --- a/cypress/support/pages/admin_console/manage/providers/ProviderPage.ts +++ b/cypress/support/pages/admin_console/manage/providers/ProviderPage.ts @@ -269,7 +269,7 @@ export default class ProviderPage { .within(() => { cy.get('input[name="radioGroup"]').click(); }); - cy.getId(this.assign).click(); + cy.findByTestId(this.assign).click(); break; default: console.log("Invalid mapper type."); diff --git a/cypress/support/pages/admin_console/manage/realm_roles/AssociatedRolesPage.ts b/cypress/support/pages/admin_console/manage/realm_roles/AssociatedRolesPage.ts index c9a19f3599..360d139dde 100644 --- a/cypress/support/pages/admin_console/manage/realm_roles/AssociatedRolesPage.ts +++ b/cypress/support/pages/admin_console/manage/realm_roles/AssociatedRolesPage.ts @@ -10,21 +10,24 @@ export default class AssociatedRolesPage { private usersPage = "users-page"; addAssociatedRealmRole() { - cy.getId(this.actionDropdown).last().click(); + cy.findByTestId(this.actionDropdown).last().click(); const load = "/auth/admin/realms/master/clients"; cy.intercept(load).as("load"); - cy.getId(this.addRolesDropdownItem).click(); + cy.findByTestId(this.addRolesDropdownItem).click(); cy.wait(["@load"]); cy.get(this.checkbox).eq(2).check(); - cy.getId(this.addAssociatedRolesModalButton).contains("Add").click(); + cy.findByTestId(this.addAssociatedRolesModalButton).contains("Add").click(); cy.url().should("include", "/AssociatedRoles"); - cy.getId(this.compositeRoleBadge).should("contain.text", "Composite"); + cy.findByTestId(this.compositeRoleBadge).should( + "contain.text", + "Composite" + ); cy.wait(["@load"]); @@ -32,13 +35,13 @@ export default class AssociatedRolesPage { } addAssociatedClientRole() { - cy.getId(this.addRoleToolbarButton).click(); + cy.findByTestId(this.addRoleToolbarButton).click(); - cy.getId(this.filterTypeDropdown).click(); + cy.findByTestId(this.filterTypeDropdown).click(); - cy.getId(this.filterTypeDropdownItem).click(); + cy.findByTestId(this.filterTypeDropdownItem).click(); - cy.getId(".pf-c-spinner__tail-ball").should("not.exist"); + cy.findByTestId(".pf-c-spinner__tail-ball").should("not.exist"); cy.get('[data-testid="addAssociatedRole"] td[data-label="Role name"]') .contains("manage-account") @@ -47,8 +50,9 @@ export default class AssociatedRolesPage { cy.get("input").click(); }); - cy.getId(this.addAssociatedRolesModalButton).contains("Add").click(); + cy.findByTestId(this.addAssociatedRolesModalButton).contains("Add").click(); - cy.contains("Users in role").click().getId(this.usersPage).should("exist"); + cy.contains("Users in role").click(); + cy.findByTestId(this.usersPage).should("exist"); } } diff --git a/cypress/support/pages/admin_console/manage/realm_roles/CreateRealmRolePage.ts b/cypress/support/pages/admin_console/manage/realm_roles/CreateRealmRolePage.ts index e19bf1c88a..3cbb8a11f8 100644 --- a/cypress/support/pages/admin_console/manage/realm_roles/CreateRealmRolePage.ts +++ b/cypress/support/pages/admin_console/manage/realm_roles/CreateRealmRolePage.ts @@ -37,7 +37,7 @@ export default class CreateRealmRolePage { //#endregion save() { - cy.getId(this.saveBtn).click(); + cy.findByTestId(this.saveBtn).click(); return this; } diff --git a/cypress/support/pages/admin_console/manage/realm_settings/RealmSettingsPage.ts b/cypress/support/pages/admin_console/manage/realm_settings/RealmSettingsPage.ts index f13ea53902..3be98e7326 100644 --- a/cypress/support/pages/admin_console/manage/realm_settings/RealmSettingsPage.ts +++ b/cypress/support/pages/admin_console/manage/realm_settings/RealmSettingsPage.ts @@ -169,7 +169,7 @@ export default class RealmSettingsPage { } fillEmailField(email: string) { - cy.getId(this.emailAddressInput).type(email); + cy.findByTestId(this.emailAddressInput).type(email); return this; } @@ -185,22 +185,22 @@ export default class RealmSettingsPage { } saveGeneral() { - cy.getId(this.generalSaveBtn).click(); + cy.findByTestId(this.generalSaveBtn).click(); return this; } saveThemes() { - cy.getId(this.themesSaveBtn).click(); + cy.findByTestId(this.themesSaveBtn).click(); return this; } addSenderEmail(senderEmail: string) { - cy.getId(this.fromInput).clear(); + cy.findByTestId(this.fromInput).clear(); if (senderEmail) { - cy.getId(this.fromInput).type(senderEmail); + cy.findByTestId(this.fromInput).type(senderEmail); } return this; @@ -208,19 +208,19 @@ export default class RealmSettingsPage { testSelectFilter() { cy.get(this.filterSelectMenu).first().click(); - cy.getId(this.passiveKeysOption).click(); + cy.findByTestId(this.passiveKeysOption).click(); cy.get(this.filterSelectMenu).first().click(); - cy.getId(this.disabledKeysOption).click(); + cy.findByTestId(this.disabledKeysOption).click(); } toggleSwitch(switchName: string) { - cy.getId(switchName).click({ force: true }); + cy.findByTestId(switchName).click({ force: true }); return this; } toggleCheck(switchName: string) { - cy.getId(switchName).click(); + cy.findByTestId(switchName).click(); return this; } @@ -228,57 +228,57 @@ export default class RealmSettingsPage { toggleAddProviderDropdown() { const keysUrl = "/auth/admin/realms/master/keys"; cy.intercept(keysUrl).as("keysFetch"); - cy.getId(this.addProviderDropdown).click(); + cy.findByTestId(this.addProviderDropdown).click(); return this; } addProvider() { - cy.getId(this.addProviderButton).click(); + cy.findByTestId(this.addProviderButton).click(); return this; } addKeyValuePair(key: string, value: string) { - cy.getId(this.addBundleButton).click(); + cy.findByTestId(this.addBundleButton).click(); - cy.getId(this.keyInput).type(key); - cy.getId(this.valueInput).type(value); + cy.findByTestId(this.keyInput).type(key); + cy.findByTestId(this.valueInput).type(value); - cy.getId(this.confirmAddBundle).click(); + cy.findByTestId(this.confirmAddBundle).click(); return this; } deleteProvider(providerName: string) { - cy.getId("provider-name-link") + cy.findAllByTestId("provider-name-link") .contains(providerName) .parent() .siblings(".pf-c-data-list__item-action") .click() - .getId(this.deleteAction) + .findByTestId(this.deleteAction) .click(); - cy.wait(500).getId(this.modalConfirm).click(); + cy.wait(500).findByTestId(this.modalConfirm).click(); } enterConsoleDisplayName(name: string) { - cy.getId(this.displayName).clear().type(name); + cy.findByTestId(this.displayName).clear().type(name); } save(saveBtn: string) { - cy.getId(saveBtn).click(); + cy.findByTestId(saveBtn).click(); return this; } clearEvents(type: "admin" | "user") { - cy.getId(`clear-${type}-events`).click(); + cy.findByTestId(`clear-${type}-events`).click(); return this; } addUserEvents(events: string[]) { - cy.getId("addTypes").click(); + cy.findByTestId("addTypes").click(); for (const event of events) { cy.get(this.eventTypeColumn) .contains(event) @@ -314,54 +314,54 @@ export default class RealmSettingsPage { } populateSessionsPage() { - cy.getId(this.ssoSessionIdleInput).clear().type("1"); + cy.findByTestId(this.ssoSessionIdleInput).clear().type("1"); this.changeTimeUnit( "Minutes", this.ssoSessionIdleSelectMenu, this.ssoSessionIdleSelectMenuList ); - cy.getId(this.ssoSessionMaxInput).clear().type("2"); + cy.findByTestId(this.ssoSessionMaxInput).clear().type("2"); this.changeTimeUnit( "Hours", this.ssoSessionMaxSelectMenu, this.ssoSessionMaxSelectMenuList ); - cy.getId(this.ssoSessionIdleRememberMeInput).clear().type("3"); + cy.findByTestId(this.ssoSessionIdleRememberMeInput).clear().type("3"); this.changeTimeUnit( "Days", this.ssoSessionIdleRememberMeSelectMenu, this.ssoSessionIdleRememberMeSelectMenuList ); - cy.getId(this.ssoSessionMaxRememberMeInput).clear().type("4"); + cy.findByTestId(this.ssoSessionMaxRememberMeInput).clear().type("4"); this.changeTimeUnit( "Minutes", this.ssoSessionMaxRememberMeSelectMenu, this.ssoSessionMaxRememberMeSelectMenuList ); - cy.getId(this.clientSessionIdleInput).clear().type("5"); + cy.findByTestId(this.clientSessionIdleInput).clear().type("5"); this.changeTimeUnit( "Hours", this.clientSessionIdleSelectMenu, this.clientSessionIdleSelectMenuList ); - cy.getId(this.clientSessionMaxInput).clear().type("6"); + cy.findByTestId(this.clientSessionMaxInput).clear().type("6"); this.changeTimeUnit( "Days", this.clientSessionMaxSelectMenu, this.clientSessionMaxSelectMenuList ); - cy.getId(this.offlineSessionIdleInput).clear().type("7"); + cy.findByTestId(this.offlineSessionIdleInput).clear().type("7"); this.toggleSwitch(this.offlineSessionMaxSwitch); - cy.getId(this.loginTimeoutInput).clear().type("9"); + cy.findByTestId(this.loginTimeoutInput).clear().type("9"); this.changeTimeUnit( "Minutes", this.loginTimeoutSelectMenu, this.loginTimeoutSelectMenuList ); - cy.getId(this.loginActionTimeoutInput).clear().type("10"); + cy.findByTestId(this.loginActionTimeoutInput).clear().type("10"); this.changeTimeUnit( "Days", this.loginActionTimeoutSelectMenu, @@ -372,66 +372,64 @@ export default class RealmSettingsPage { populateTokensPage() { this.toggleSwitch(this.revokeRefreshTokenSwitch); - cy.getId(this.accessTokenLifespanInput) + cy.findByTestId(this.accessTokenLifespanInput) .focus() - .clear({ force: true }) - .getId(this.accessTokenLifespanInput) - .clear() - .type("1"); + .clear({ force: true }); + cy.findByTestId(this.accessTokenLifespanInput).clear().type("1"); this.changeTimeUnit( "Days", this.accessTokenLifespanSelectMenu, this.accessTokenLifespanSelectMenuList ); - cy.getId(this.accessTokenLifespanImplicitInput).clear().type("2"); + cy.findByTestId(this.accessTokenLifespanImplicitInput).clear().type("2"); this.changeTimeUnit( "Minutes", this.accessTokenLifespanImplicitSelectMenu, this.accessTokenLifespanImplicitSelectMenuList ); - cy.getId(this.clientLoginTimeoutInput).clear().type("3"); + cy.findByTestId(this.clientLoginTimeoutInput).clear().type("3"); this.changeTimeUnit( "Hours", this.clientLoginTimeoutSelectMenu, this.clientLoginTimeoutSelectMenuList ); - cy.getId(this.userInitiatedActionLifespanInput).clear().type("4"); + cy.findByTestId(this.userInitiatedActionLifespanInput).clear().type("4"); this.changeTimeUnit( "Minutes", this.userInitiatedActionLifespanSelectMenu, this.userInitiatedActionLifespanSelectMenuList ); - cy.getId(this.defaultAdminInitatedInput).clear().type("5"); + cy.findByTestId(this.defaultAdminInitatedInput).clear().type("5"); this.changeTimeUnit( "Days", this.defaultAdminInitatedInputSelectMenu, this.defaultAdminInitatedInputSelectMenuList ); - cy.getId(this.emailVerificationInput).clear().type("6"); + cy.findByTestId(this.emailVerificationInput).clear().type("6"); this.changeTimeUnit( "Days", this.emailVerificationSelectMenu, this.emailVerificationSelectMenuList ); - cy.getId(this.idpEmailVerificationInput).clear().type("7"); + cy.findByTestId(this.idpEmailVerificationInput).clear().type("7"); this.changeTimeUnit( "Days", this.idpEmailVerificationSelectMenu, this.idpEmailVerificationSelectMenuList ); - cy.getId(this.forgotPasswordInput).clear().type("8"); + cy.findByTestId(this.forgotPasswordInput).clear().type("8"); this.changeTimeUnit( "Days", this.forgotPasswordSelectMenu, this.forgotPasswordSelectMenuList ); - cy.getId(this.executeActionsInput).clear().type("9"); + cy.findByTestId(this.executeActionsInput).clear().type("9"); this.changeTimeUnit( "Days", this.executeActionsSelectMenu, @@ -449,7 +447,7 @@ export default class RealmSettingsPage { } clickAdd() { - cy.getId("addEventTypeConfirm").click(); + cy.findByTestId("addEventTypeConfirm").click(); return this; } } diff --git a/cypress/support/pages/admin_console/manage/sessions/SessionsPage.ts b/cypress/support/pages/admin_console/manage/sessions/SessionsPage.ts index 1dcc2b40e8..bd362b4070 100644 --- a/cypress/support/pages/admin_console/manage/sessions/SessionsPage.ts +++ b/cypress/support/pages/admin_console/manage/sessions/SessionsPage.ts @@ -28,61 +28,61 @@ export default class SessionsPage { selectAllSessionsType() { cy.get(this.sessionTypeDrpDwn).click(); - cy.getId(this.allSessionTypesOption).click(); + cy.findByTestId(this.allSessionTypesOption).click(); cy.get(this.selectedType).should("have.text", "All session types"); } selectRegularSSO() { cy.get(this.sessionTypeDrpDwn).click(); - cy.getId(this.regularSSOOption).click(); + cy.findByTestId(this.regularSSOOption).click(); cy.get(this.selectedType).should("have.text", "Regular SSO"); } selectOffline() { cy.get(this.sessionTypeDrpDwn).click(); - cy.getId(this.offlineOption).click(); + cy.findByTestId(this.offlineOption).click(); cy.get(this.selectedType).should("have.text", "Offline"); } selectDirectGrant() { cy.get(this.sessionTypeDrpDwn).click(); - cy.getId(this.directGrantOption).click(); + cy.findByTestId(this.directGrantOption).click(); cy.get(this.selectedType).should("have.text", "Direct grant"); } selectServiceAccount() { cy.get(this.sessionTypeDrpDwn).click(); - cy.getId(this.serviceAccountOption).click(); + cy.findByTestId(this.serviceAccountOption).click(); cy.get(this.selectedType).should("have.text", "Service account"); } setToNow() { - cy.getId(this.actionDropdown).click(); - cy.getId(this.revocationActionItem).click(); - cy.getId(this.setToNowButton).click(); + cy.findByTestId(this.actionDropdown).click(); + cy.findByTestId(this.revocationActionItem).click(); + cy.findByTestId(this.setToNowButton).click(); } checkNotBeforeValueExists() { - cy.getId(this.actionDropdown).click(); - cy.getId(this.revocationActionItem).click(); - cy.getId(this.notBeforeInput).should("not.have.value", "None"); + cy.findByTestId(this.actionDropdown).click(); + cy.findByTestId(this.revocationActionItem).click(); + cy.findByTestId(this.notBeforeInput).should("not.have.value", "None"); } clearNotBefore() { - cy.getId(this.actionDropdown).click(); - cy.getId(this.revocationActionItem).click(); - cy.getId(this.clearNotBeforeButton).click(); + cy.findByTestId(this.actionDropdown).click(); + cy.findByTestId(this.revocationActionItem).click(); + cy.findByTestId(this.clearNotBeforeButton).click(); } checkNotBeforeCleared() { - cy.getId(this.actionDropdown).click(); - cy.getId(this.revocationActionItem).click(); - cy.getId(this.notBeforeInput).should("have.value", "None"); + cy.findByTestId(this.actionDropdown).click(); + cy.findByTestId(this.revocationActionItem).click(); + cy.findByTestId(this.notBeforeInput).should("have.value", "None"); } logoutAllSessions() { - cy.getId(this.actionDropdown).click(); - cy.getId(this.logoutAll).click(); - cy.getId(this.logoutAllConfirm).click(); + cy.findByTestId(this.actionDropdown).click(); + cy.findByTestId(this.logoutAll).click(); + cy.findByTestId(this.logoutAllConfirm).click(); } } diff --git a/cypress/support/pages/admin_console/manage/users/CreateUserPage.ts b/cypress/support/pages/admin_console/manage/users/CreateUserPage.ts index 3f71eb945d..9a775ff404 100644 --- a/cypress/support/pages/admin_console/manage/users/CreateUserPage.ts +++ b/cypress/support/pages/admin_console/manage/users/CreateUserPage.ts @@ -37,11 +37,11 @@ export default class CreateUserPage { cy.wait(100); cy.get("body").then((body) => { if (body.find("[data-testid=empty-state]").length > 0) { - cy.getId(this.emptyStateCreateUserBtn).click(); + cy.findByTestId(this.emptyStateCreateUserBtn).click(); } else if (body.find("[data-testid=search-users-title]").length > 0) { - cy.getId(this.searchPgCreateUserBtn).click(); + cy.findByTestId(this.searchPgCreateUserBtn).click(); } else { - cy.getId(this.addUserBtn).click(); + cy.findByTestId(this.addUserBtn).click(); } }); @@ -49,25 +49,25 @@ export default class CreateUserPage { } toggleAddGroupModal() { - cy.getId(this.joinGroupsBtn).click(); + cy.findByTestId(this.joinGroupsBtn).click(); return this; } joinGroups() { - cy.getId(this.joinBtn).click(); + cy.findByTestId(this.joinBtn).click(); return this; } save() { - cy.getId(this.saveBtn).click(); + cy.findByTestId(this.saveBtn).click(); return this; } cancel() { - cy.getId(this.cancelBtn).click(); + cy.findByTestId(this.cancelBtn).click(); return this; } diff --git a/cypress/support/pages/admin_console/manage/users/UserDetailsPage.ts b/cypress/support/pages/admin_console/manage/users/UserDetailsPage.ts index 3427f90438..be7bb5aad7 100644 --- a/cypress/support/pages/admin_console/manage/users/UserDetailsPage.ts +++ b/cypress/support/pages/admin_console/manage/users/UserDetailsPage.ts @@ -32,22 +32,22 @@ export default class UserDetailsPage { } fillUserData() { - cy.getId(this.emailInput).type(this.emailValue); - cy.getId(this.firstNameInput).type(this.firstNameValue); - cy.getId(this.lastNameInput).type(this.lastNameValue); - cy.getId(this.enabledSwitch).check({ force: true }); + cy.findByTestId(this.emailInput).type(this.emailValue); + cy.findByTestId(this.firstNameInput).type(this.firstNameValue); + cy.findByTestId(this.lastNameInput).type(this.lastNameValue); + cy.findByTestId(this.enabledSwitch).check({ force: true }); return this; } save() { - cy.getId(this.saveBtn).click(); + cy.findByTestId(this.saveBtn).click(); return this; } cancel() { - cy.getId(this.cancelBtn).click(); + cy.findByTestId(this.cancelBtn).click(); return this; } diff --git a/cypress/support/pages/admin_console/manage/users/UserGroupsPage.ts b/cypress/support/pages/admin_console/manage/users/UserGroupsPage.ts index 6818e2743d..5ad099b035 100644 --- a/cypress/support/pages/admin_console/manage/users/UserGroupsPage.ts +++ b/cypress/support/pages/admin_console/manage/users/UserGroupsPage.ts @@ -10,19 +10,19 @@ export default class UserGroupsPage { } goToGroupsTab() { - cy.getId(this.userGroupsTab).click(); + cy.findByTestId(this.userGroupsTab).click(); return this; } toggleAddGroupModal() { - cy.getId(this.addGroupButton).click(); + cy.findByTestId(this.addGroupButton).click(); return this; } joinGroups() { - cy.getId(this.joinGroupButton).click(); + cy.findByTestId(this.joinGroupButton).click(); return this; } diff --git a/cypress/tsconfig.json b/cypress/tsconfig.json index 7493ba73f9..e090face86 100644 --- a/cypress/tsconfig.json +++ b/cypress/tsconfig.json @@ -1,6 +1,8 @@ { "extends": "../tsconfig.json", + "include": ["**/*"], "compilerOptions": { + "types": ["cypress", "@testing-library/cypress"], "module": "ES2015", "target": "ES2015", } diff --git a/package-lock.json b/package-lock.json index 96ae8fd05c..94efd253dc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -35,6 +35,7 @@ "@snowpack/plugin-postcss": "^1.4.3", "@snowpack/plugin-react-refresh": "^2.5.0", "@snowpack/plugin-typescript": "^1.2.1", + "@testing-library/cypress": "^8.0.1", "@testing-library/jest-dom": "^5.14.1", "@testing-library/react": "^12.1.0", "@types/dagre": "^0.7.45", @@ -3043,6 +3044,23 @@ "node": ">=10" } }, + "node_modules/@testing-library/cypress": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/@testing-library/cypress/-/cypress-8.0.1.tgz", + "integrity": "sha512-JCGy8u4ia+OQQJxVqKqjqpb0i4kmHQhu5jKFVBp+v/YSICnf52fil2MWIJqO+tH9ZQXtp3aF7uKHsVipWaI0BQ==", + "dev": true, + "dependencies": { + "@babel/runtime": "^7.14.6", + "@testing-library/dom": "^8.1.0" + }, + "engines": { + "node": ">=12", + "npm": ">=6" + }, + "peerDependencies": { + "cypress": "^2.1.0 || ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, "node_modules/@testing-library/dom": { "version": "8.1.0", "integrity": "sha512-kmW9alndr19qd6DABzQ978zKQ+J65gU2Rzkl8hriIetPnwpesRaK4//jEQyYh8fEALmGhomD/LBQqt+o+DL95Q==", @@ -19069,6 +19087,16 @@ "defer-to-connect": "^2.0.0" } }, + "@testing-library/cypress": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/@testing-library/cypress/-/cypress-8.0.1.tgz", + "integrity": "sha512-JCGy8u4ia+OQQJxVqKqjqpb0i4kmHQhu5jKFVBp+v/YSICnf52fil2MWIJqO+tH9ZQXtp3aF7uKHsVipWaI0BQ==", + "dev": true, + "requires": { + "@babel/runtime": "^7.14.6", + "@testing-library/dom": "^8.1.0" + } + }, "@testing-library/dom": { "version": "8.1.0", "integrity": "sha512-kmW9alndr19qd6DABzQ978zKQ+J65gU2Rzkl8hriIetPnwpesRaK4//jEQyYh8fEALmGhomD/LBQqt+o+DL95Q==", diff --git a/package.json b/package.json index 98ac71e501..5b04b6ed25 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,7 @@ "@snowpack/plugin-postcss": "^1.4.3", "@snowpack/plugin-react-refresh": "^2.5.0", "@snowpack/plugin-typescript": "^1.2.1", + "@testing-library/cypress": "^8.0.1", "@testing-library/jest-dom": "^5.14.1", "@testing-library/react": "^12.1.0", "@types/dagre": "^0.7.45", diff --git a/tsconfig.jest.json b/tsconfig.jest.json index acac3561a5..694fa9078d 100644 --- a/tsconfig.jest.json +++ b/tsconfig.jest.json @@ -1,6 +1,9 @@ { "extends": "./tsconfig.json", + // overwrite exclude so test files are included. + "exclude": [], "compilerOptions": { + "types": ["jest"], "jsx": "react" } } \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index bfdcedc093..7ad98c3c1e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,12 @@ { + "include": ["src"], + "exclude": [ + "**/*.test.ts", + "**/*.test.tsx" + ], "extends": "@snowpack/app-scripts-react/tsconfig.base.json", "compilerOptions": { - "types": ["jest", "cypress", "snowpack-env"], + "types": ["snowpack-env"], "esModuleInterop": true } } \ No newline at end of file diff --git a/types/import.d.ts b/types/import.d.ts deleted file mode 100644 index 39773ddab7..0000000000 --- a/types/import.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -declare namespace Cypress { - interface Chainable { - /** - * Get one or more DOM elements by `data-testid`. - * - * @example - * cy.getId('searchButton') // Gets the - */ - getId(selector: string, ...args): Chainable; - } -}