From ea24e3b91d04be92fba790ee8df70c0619ee849b Mon Sep 17 00:00:00 2001 From: ikhomyn <89014675+ikhomyn@users.noreply.github.com> Date: Wed, 31 Aug 2022 12:16:12 +0200 Subject: [PATCH] New custom identity providers tests (#3238) --- .../e2e/identity_providers_test.spec.ts | 96 +++++++++- .../ProviderBaseAdvancedSettingsPage.ts | 167 ++++++++++++++++++ .../ProviderBaseGeneralSettingsPage.ts | 139 +++++++++++++++ .../social/ProviderFacebookGeneralSettings.ts | 34 ++++ .../social/ProviderGithubGeneralSettings.ts | 43 +++++ .../social/ProviderGoogleGeneralSettings.ts | 55 ++++++ .../ProviderOpenshiftGeneralSettings.ts | 38 ++++ .../social/ProviderPaypalGeneralSettings.ts | 27 +++ .../ProviderStackoverflowGeneralSettings.ts | 38 ++++ 9 files changed, 633 insertions(+), 4 deletions(-) create mode 100644 apps/admin-ui/cypress/support/pages/admin_console/manage/identity_providers/ProviderBaseAdvancedSettingsPage.ts create mode 100644 apps/admin-ui/cypress/support/pages/admin_console/manage/identity_providers/ProviderBaseGeneralSettingsPage.ts create mode 100644 apps/admin-ui/cypress/support/pages/admin_console/manage/identity_providers/social/ProviderFacebookGeneralSettings.ts create mode 100644 apps/admin-ui/cypress/support/pages/admin_console/manage/identity_providers/social/ProviderGithubGeneralSettings.ts create mode 100644 apps/admin-ui/cypress/support/pages/admin_console/manage/identity_providers/social/ProviderGoogleGeneralSettings.ts create mode 100644 apps/admin-ui/cypress/support/pages/admin_console/manage/identity_providers/social/ProviderOpenshiftGeneralSettings.ts create mode 100644 apps/admin-ui/cypress/support/pages/admin_console/manage/identity_providers/social/ProviderPaypalGeneralSettings.ts create mode 100644 apps/admin-ui/cypress/support/pages/admin_console/manage/identity_providers/social/ProviderStackoverflowGeneralSettings.ts diff --git a/apps/admin-ui/cypress/e2e/identity_providers_test.spec.ts b/apps/admin-ui/cypress/e2e/identity_providers_test.spec.ts index 680822abb5..2ec6d361cc 100644 --- a/apps/admin-ui/cypress/e2e/identity_providers_test.spec.ts +++ b/apps/admin-ui/cypress/e2e/identity_providers_test.spec.ts @@ -8,6 +8,14 @@ import CreateProviderPage from "../support/pages/admin_console/manage/identity_p import ModalUtils from "../support/util/ModalUtils"; import OrderDialog from "../support/pages/admin_console/manage/identity_providers/OrderDialog"; import AddMapperPage from "../support/pages/admin_console/manage/identity_providers/AddMapperPage"; +import ProviderFacebookGeneralSettings from "../support/pages/admin_console/manage/identity_providers/social/ProviderFacebookGeneralSettings"; +import ProviderBaseGeneralSettingsPage from "../support/pages/admin_console/manage/identity_providers/ProviderBaseGeneralSettingsPage"; +import ProviderGithubGeneralSettings from "../support/pages/admin_console/manage/identity_providers/social/ProviderGithubGeneralSettings"; +import ProviderGoogleGeneralSettings from "../support/pages/admin_console/manage/identity_providers/social/ProviderGoogleGeneralSettings"; +import ProviderOpenshiftGeneralSettings from "../support/pages/admin_console/manage/identity_providers/social/ProviderOpenshiftGeneralSettings"; +import ProviderPaypalGeneralSettings from "../support/pages/admin_console/manage/identity_providers/social/ProviderPaypalGeneralSettings"; +import ProviderStackoverflowGeneralSettings from "../support/pages/admin_console/manage/identity_providers/social/ProviderStackoverflowGeneralSettings"; +import adminClient from "../support/util/AdminClient"; describe("Identity provider test", () => { const loginPage = new LoginPage(); @@ -25,13 +33,93 @@ describe("Identity provider test", () => { const deletePrompt = "Delete provider?"; const deleteSuccessMsg = "Provider successfully deleted."; + beforeEach(() => { + keycloakBefore(); + loginPage.logIn(); + sidebarPage.goToIdentityProviders(); + }); + + const socialLoginIdentityProvidersWithCustomFiels = { + Facebook: new ProviderFacebookGeneralSettings(), + Github: new ProviderGithubGeneralSettings(), + Google: new ProviderGoogleGeneralSettings(), + "Openshift-v3": new ProviderOpenshiftGeneralSettings(), + "Openshift-v4": new ProviderOpenshiftGeneralSettings(), + Paypal: new ProviderPaypalGeneralSettings(), + Stackoverflow: new ProviderStackoverflowGeneralSettings(), + }; + function getSocialIdpClassInstance(idpTestName: string) { + let instance = new ProviderBaseGeneralSettingsPage(); + Object.entries(socialLoginIdentityProvidersWithCustomFiels).find( + ([key, value]) => { + if (key === idpTestName) { + instance = value; + return true; + } + return false; + } + ); + return instance; + } + describe("Identity provider creation", () => { const identityProviderName = "github"; - beforeEach(() => { - keycloakBefore(); - loginPage.logIn(); - sidebarPage.goToIdentityProviders(); + describe("Custom fields tests", () => { + const socialLoginIdentityProviders = [ + { testName: "Bitbucket", displayName: "BitBucket", alias: "bitbucket" }, + { testName: "Facebook", displayName: "Facebook", alias: "facebook" }, + { testName: "Github", displayName: "GitHub", alias: "github" }, + { testName: "Gitlab", displayName: "Gitlab", alias: "gitlab" }, + { testName: "Google", displayName: "Google", alias: "google" }, + { testName: "Instagram", displayName: "Instagram", alias: "instagram" }, + { testName: "Linkedin", displayName: "LinkedIn", alias: "linkedin" }, + { testName: "Microsoft", displayName: "Microsoft", alias: "microsoft" }, + { + testName: "Openshift-v3", + displayName: "Openshift v3", + alias: "openshift-v3", + }, + { + testName: "Openshift-v4", + displayName: "Openshift v4", + alias: "openshift-v4", + }, + { testName: "Paypal", displayName: "PayPal", alias: "paypal" }, + { + testName: "Stackoverflow", + displayName: "StackOverflow", + alias: "stackoverflow", + }, + { testName: "Twitter", displayName: "Twitter", alias: "twitter" }, + ]; + + after(async () => { + await Promise.all( + socialLoginIdentityProviders.map((idp) => + adminClient.deleteIdentityProvider(idp.alias) + ) + ); + }); + + socialLoginIdentityProviders.forEach(($idp, linkedIdpsCount) => { + it(`should create social login provider ${$idp.testName} with custom fields`, () => { + if (linkedIdpsCount == 0) { + createProviderPage.clickCard($idp.alias); + } else { + createProviderPage.clickCreateDropdown().clickItem($idp.alias); + } + const instance = getSocialIdpClassInstance($idp.testName); + instance + .typeDisplayOrder("0") + .clickAdd() + .assertRequiredFieldsErrorsExist() + .fillData($idp.testName) + .clickAdd() + .assertNotificationIdpCreated() + .assertFilledDataEqual($idp.testName); + }); + }); }); it("should create provider", () => { diff --git a/apps/admin-ui/cypress/support/pages/admin_console/manage/identity_providers/ProviderBaseAdvancedSettingsPage.ts b/apps/admin-ui/cypress/support/pages/admin_console/manage/identity_providers/ProviderBaseAdvancedSettingsPage.ts new file mode 100644 index 0000000000..2e6326e451 --- /dev/null +++ b/apps/admin-ui/cypress/support/pages/admin_console/manage/identity_providers/ProviderBaseAdvancedSettingsPage.ts @@ -0,0 +1,167 @@ +import PageObject from "../../components/PageObject"; + +export enum LoginFlowOption { + none = "None", + browser = "browser", + directGrant = "direct grant", + registration = "registration", + resetCredentials = "reset credentials", + firstBrokerLogin = "first broker login", + dockerAuth = "docker auth", + httpChallenge = "http challenge", +} + +export enum SyncModeOption { + import = "Import", + legacy = "Legacy", + force = "Force", +} + +export default class ProviderBaseGeneralSettingsPage extends PageObject { + private scopesInput = "#scopes"; + private storeTokensSwitch = "#storeTokens"; + private storedTokensReadable = "#storedTokensReadable"; + private acceptsPromptNoneForwardFromClientSwitch = "#acceptsPromptNone"; + private disableUserInfoSwitch = "#disableUserInfo"; + private trustEmailSwitch = "#trustEmail"; + private accountLinkingOnlySwitch = "#accountLinkingOnly"; + private hideOnLoginPageSwitch = "#hideOnLoginPage"; + private firstLoginFlowSelect = "#firstBrokerLoginFlowAlias"; + private postLoginFlowSelect = "#postBrokerLoginFlowAlias"; + private syncModeSelect = "#syncMode"; + private addBtn = "createProvider"; + + public typeScopesInput(text: string) { + cy.get(this.scopesInput).type(text).blur(); + return this; + } + + public clickStoreTokensSwitch() { + cy.get(this.storeTokensSwitch).click(); + return this; + } + + public clickStoredTokensReadableSwitch() { + cy.get(this.storedTokensReadable).click(); + return this; + } + + public clickAcceptsPromptNoneForwardFromClientSwitch() { + cy.get(this.acceptsPromptNoneForwardFromClientSwitch).click(); + return this; + } + + public clickDisableUserInfoSwitch() { + cy.get(this.disableUserInfoSwitch).click(); + return this; + } + + public clickTrustEmailSwitch() { + cy.get(this.trustEmailSwitch).click(); + return this; + } + + public clickAccountLinkingOnlySwitch() { + cy.get(this.accountLinkingOnlySwitch).click(); + return this; + } + + public clickHideOnLoginPageSwitch() { + cy.get(this.hideOnLoginPageSwitch).click(); + return this; + } + + public selectFirstLoginFlowOption(loginFlowOption: LoginFlowOption) { + cy.get(this.firstLoginFlowSelect).click(); + super.clickSelectMenuItem( + loginFlowOption, + cy.get(this.firstLoginFlowSelect).parent() + ); + return this; + } + + public selectPostLoginFlowOption(loginFlowOption: LoginFlowOption) { + cy.get(this.postLoginFlowSelect).click(); + super.clickSelectMenuItem( + loginFlowOption, + cy.get(this.postLoginFlowSelect).parent() + ); + return this; + } + + public selectSyncModeOption(syncModeOption: SyncModeOption) { + cy.get(this.syncModeSelect).click(); + super.clickSelectMenuItem( + syncModeOption, + cy.get(this.syncModeSelect).parent() + ); + return this; + } + + public clickAdd() { + cy.findByTestId(this.addBtn).click(); + return this; + } + + public assertScopesInputEqual(text: string) { + cy.get(this.scopesInput).should("have.text", text); + return this; + } + + public assertStoreTokensSwitchTurnedOn(isOn: boolean) { + super.assertSwitchStateOn(cy.get(this.storeTokensSwitch), isOn); + return this; + } + + public assertStoredTokensReadableTurnedOn(isOn: boolean) { + super.assertSwitchStateOn(cy.get(this.storedTokensReadable), isOn); + return this; + } + + public assertAcceptsPromptNoneForwardFromClientSwitchTurnedOn(isOn: boolean) { + super.assertSwitchStateOn( + cy.get(this.acceptsPromptNoneForwardFromClientSwitch), + isOn + ); + return this; + } + + public assertDisableUserInfoSwitchTurnedOn(isOn: boolean) { + super.assertSwitchStateOn(cy.get(this.disableUserInfoSwitch), isOn); + return this; + } + + public assertTrustEmailSwitchTurnedOn(isOn: boolean) { + super.assertSwitchStateOn(cy.get(this.trustEmailSwitch), isOn); + return this; + } + + public assertAccountLinkingOnlySwitchTurnedOn(isOn: boolean) { + super.assertSwitchStateOn(cy.get(this.accountLinkingOnlySwitch), isOn); + return this; + } + + public assertHideOnLoginPageSwitchTurnedOn(isOn: boolean) { + super.assertSwitchStateOn(cy.get(this.hideOnLoginPageSwitch), isOn); + return this; + } + + public assertFirstLoginFlowSelectOptionEqual( + loginFlowOption: LoginFlowOption + ) { + cy.get(this.firstLoginFlowSelect).should("have.text", loginFlowOption); + return this; + } + + public assertPostLoginFlowSelectOptionEqual( + loginFlowOption: LoginFlowOption + ) { + cy.get(this.postLoginFlowSelect).should("have.text", loginFlowOption); + return this; + } + + public assertSyncModeSelectOptionEqual(syncModeOption: SyncModeOption) { + cy.get(this.postLoginFlowSelect).should("have.text", syncModeOption); + return this; + } +} diff --git a/apps/admin-ui/cypress/support/pages/admin_console/manage/identity_providers/ProviderBaseGeneralSettingsPage.ts b/apps/admin-ui/cypress/support/pages/admin_console/manage/identity_providers/ProviderBaseGeneralSettingsPage.ts new file mode 100644 index 0000000000..6810cd7e74 --- /dev/null +++ b/apps/admin-ui/cypress/support/pages/admin_console/manage/identity_providers/ProviderBaseGeneralSettingsPage.ts @@ -0,0 +1,139 @@ +import PageObject from "../../components/PageObject"; +import Masthead from "../../Masthead"; + +const masthead = new Masthead(); + +export default class ProviderBaseGeneralSettingsPage extends PageObject { + private redirectUriGroup = ".pf-c-clipboard-copy__group"; + protected clientIdInput = "#kc-client-id"; + protected clientSecretInput = "#kc-client-secret"; + private displayOrderInput = "#kc-display-order"; + private addBtn = "createProvider"; + private cancelBtn = "cancel"; + private requiredFieldErrorMsg = ".pf-c-form__helper-text.pf-m-error"; + protected requiredFields: string[] = [ + this.clientIdInput, + this.clientSecretInput, + ]; + protected testData = { + ClientId: "client", + ClientSecret: "client_secret", + DisplayOrder: "0", + }; + + public typeClientId(clientId: string) { + cy.get(this.clientIdInput).type(clientId).blur(); + return this; + } + + public typeClientSecret(clientSecret: string) { + cy.get(this.clientSecretInput).type(clientSecret).blur(); + return this; + } + + public typeDisplayOrder(displayOrder: string) { + cy.get(this.displayOrderInput).type(displayOrder).blur(); + + return this; + } + + public clickShowPassword() { + cy.get(this.clientSecretInput).parent().find("button").click(); + return this; + } + + public clickCopyToClipboard() { + cy.get(this.redirectUriGroup).find("button").click(); + return this; + } + + public clickAdd() { + cy.findByTestId(this.addBtn).click(); + return this; + } + + public clickCancel() { + cy.findByTestId(this.cancelBtn).click(); + return this; + } + + public assertRedirectUriInputEqual(value: string) { + cy.get(this.redirectUriGroup).find("input").should("have.value", value); + return this; + } + + public assertClientIdInputEqual(text: string) { + cy.get(this.clientIdInput).should("have.text", text); + return this; + } + + public assertClientSecretInputEqual(text: string) { + cy.get(this.clientSecretInput).should("have.text", text); + return this; + } + + public assertDisplayOrderInputEqual(text: string) { + cy.get(this.clientSecretInput).should("have.text", text); + return this; + } + + public assertNotificationIdpCreated() { + masthead.checkNotificationMessage("Identity provider successfully created"); + return this; + } + + protected assertCommonRequiredFields(requiredFiels: string[]) { + requiredFiels.forEach((elementLocator) => { + if (elementLocator.includes("#")) { + cy.get(elementLocator) + .parent() + .parent() + .find(this.requiredFieldErrorMsg) + .should("exist"); + } else { + cy.findByTestId(elementLocator) + .parent() + .parent() + .find(this.requiredFieldErrorMsg) + .should("exist"); + } + }); + return this; + } + + public assertRequiredFieldsErrorsExist() { + return this.assertCommonRequiredFields(this.requiredFields); + } + + protected fillCommonFields(idpName: string) { + this.typeClientId(this.testData["ClientId"] + idpName); + this.typeClientSecret(this.testData["ClientSecret"] + idpName); + this.typeDisplayOrder(this.testData["DisplayOrder"]); + + return this; + } + + public fillData(idpName: string) { + this.fillCommonFields(idpName); + + return this; + } + + protected assertCommonFilledDataEqual(idpName: string) { + cy.get(this.clientIdInput).should( + "have.value", + this.testData["ClientId"] + idpName + ); + cy.get(this.clientSecretInput).should("contain.value", "****"); + cy.get(this.displayOrderInput).should( + "have.value", + this.testData["DisplayOrder"] + ); + return this; + } + + public assertFilledDataEqual(idpName: string) { + this.assertCommonFilledDataEqual(idpName); + return this; + } +} diff --git a/apps/admin-ui/cypress/support/pages/admin_console/manage/identity_providers/social/ProviderFacebookGeneralSettings.ts b/apps/admin-ui/cypress/support/pages/admin_console/manage/identity_providers/social/ProviderFacebookGeneralSettings.ts new file mode 100644 index 0000000000..5c64250e0a --- /dev/null +++ b/apps/admin-ui/cypress/support/pages/admin_console/manage/identity_providers/social/ProviderFacebookGeneralSettings.ts @@ -0,0 +1,34 @@ +import ProviderBaseGeneralSettingsPage from "../ProviderBaseGeneralSettingsPage"; + +const additionalUsersProfile_input_test_value = + "additionalUsersProfile_input_test_value"; + +export default class ProviderFacebookGeneralSettings extends ProviderBaseGeneralSettingsPage { + private additionalUsersProfileFieldsInput = "#facebookFetchedFields"; + + public typeAdditionalUsersProfileFieldsInput(value: string) { + cy.get(this.additionalUsersProfileFieldsInput).type(value).blur(); + return this; + } + + public assertAdditionalUsersProfileFieldsInputEqual(value: string) { + cy.get(this.additionalUsersProfileFieldsInput).should("have.value", value); + return this; + } + + public fillData(idpName: string) { + this.fillCommonFields(idpName); + this.typeAdditionalUsersProfileFieldsInput( + idpName + additionalUsersProfile_input_test_value + ); + return this; + } + + public assertFilledDataEqual(idpName: string) { + this.assertCommonFilledDataEqual(idpName); + this.assertAdditionalUsersProfileFieldsInputEqual( + idpName + additionalUsersProfile_input_test_value + ); + return this; + } +} diff --git a/apps/admin-ui/cypress/support/pages/admin_console/manage/identity_providers/social/ProviderGithubGeneralSettings.ts b/apps/admin-ui/cypress/support/pages/admin_console/manage/identity_providers/social/ProviderGithubGeneralSettings.ts new file mode 100644 index 0000000000..c8439a2a56 --- /dev/null +++ b/apps/admin-ui/cypress/support/pages/admin_console/manage/identity_providers/social/ProviderGithubGeneralSettings.ts @@ -0,0 +1,43 @@ +import ProviderBaseGeneralSettingsPage from "../ProviderBaseGeneralSettingsPage"; + +const base_url_input_test_value = "base_url_input_test_value"; +const api_url_input_test_value = "api_url_input_test_value"; + +export default class ProviderGithubGeneralSettings extends ProviderBaseGeneralSettingsPage { + private baseUrlInput = "#baseUrl"; + private apiUrlInput = "#apiUrl"; + + public typeBaseUrlInput(value: string) { + cy.get(this.baseUrlInput).type(value).blur(); + return this; + } + + public typeApiUrlInput(value: string) { + cy.get(this.apiUrlInput).type(value).blur(); + return this; + } + + public assertBaseUrlInputInputEqual(value: string) { + cy.get(this.baseUrlInput).should("have.value", value); + return this; + } + + public assertApiUrlInputEqual(value: string) { + cy.get(this.apiUrlInput).should("have.value", value); + return this; + } + + public fillData(idpName: string) { + this.fillCommonFields(idpName); + this.typeBaseUrlInput(idpName + base_url_input_test_value); + this.typeApiUrlInput(idpName + api_url_input_test_value); + return this; + } + + public assertFilledDataEqual(idpName: string) { + this.assertCommonFilledDataEqual(idpName); + this.assertBaseUrlInputInputEqual(idpName + base_url_input_test_value); + this.assertApiUrlInputEqual(idpName + api_url_input_test_value); + return this; + } +} diff --git a/apps/admin-ui/cypress/support/pages/admin_console/manage/identity_providers/social/ProviderGoogleGeneralSettings.ts b/apps/admin-ui/cypress/support/pages/admin_console/manage/identity_providers/social/ProviderGoogleGeneralSettings.ts new file mode 100644 index 0000000000..0c70253a68 --- /dev/null +++ b/apps/admin-ui/cypress/support/pages/admin_console/manage/identity_providers/social/ProviderGoogleGeneralSettings.ts @@ -0,0 +1,55 @@ +import ProviderBaseGeneralSettingsPage from "../ProviderBaseGeneralSettingsPage"; + +const hosted_domain_input_test_value = "hosted_domain_input_test_value"; + +export default class ProviderGoogleGeneralSettings extends ProviderBaseGeneralSettingsPage { + private hostedDomainInput = "#googleHostedDomain"; + private useUserIpParamSwitch = "#googleUserIp"; + private requestRefreshTokenSwitch = "#googleOfflineAccess"; + + public typeHostedDomainInput(value: string) { + cy.get(this.hostedDomainInput).type(value).blur(); + return this; + } + + public clickUseUserIpParamSwitch() { + cy.get(this.useUserIpParamSwitch).parent().click(); + return this; + } + + public clickRequestRefreshTokenSwitch() { + cy.get(this.requestRefreshTokenSwitch).parent().click(); + return this; + } + + public assertHostedDomainInputEqual(value: string) { + cy.get(this.hostedDomainInput).should("have.value", value); + return this; + } + + public assertUseUserIpParamSwitchTurnedOn(isOn: boolean) { + super.assertSwitchStateOn(cy.get(this.useUserIpParamSwitch), isOn); + return this; + } + + public assertRequestRefreshTokenSwitchTurnedOn(isOn: boolean) { + super.assertSwitchStateOn(cy.get(this.requestRefreshTokenSwitch), isOn); + return this; + } + + public fillData(idpName: string) { + this.fillCommonFields(idpName); + this.typeHostedDomainInput(hosted_domain_input_test_value); + this.clickUseUserIpParamSwitch(); + this.clickRequestRefreshTokenSwitch(); + return this; + } + + public assertFilledDataEqual(idpName: string) { + this.assertCommonFilledDataEqual(idpName); + this.assertHostedDomainInputEqual(hosted_domain_input_test_value); + this.assertSwitchStateOn(cy.get(this.useUserIpParamSwitch)); + this.assertSwitchStateOn(cy.get(this.requestRefreshTokenSwitch)); + return this; + } +} diff --git a/apps/admin-ui/cypress/support/pages/admin_console/manage/identity_providers/social/ProviderOpenshiftGeneralSettings.ts b/apps/admin-ui/cypress/support/pages/admin_console/manage/identity_providers/social/ProviderOpenshiftGeneralSettings.ts new file mode 100644 index 0000000000..f4dbfbebdc --- /dev/null +++ b/apps/admin-ui/cypress/support/pages/admin_console/manage/identity_providers/social/ProviderOpenshiftGeneralSettings.ts @@ -0,0 +1,38 @@ +import ProviderBaseGeneralSettingsPage from "../ProviderBaseGeneralSettingsPage"; + +const base_url_input_test_value = "base_url_input_test_value"; + +export default class ProviderOpenshiftGeneralSettings extends ProviderBaseGeneralSettingsPage { + private baseUrlInput = "#baseUrl"; + + constructor() { + super(); + this.requiredFields.push(this.baseUrlInput); + } + + public typeBaseUrlInput(value: string) { + cy.get(this.baseUrlInput).type(value).blur(); + return this; + } + + public assertbaseUrlInputEqual(value: string) { + cy.get(this.baseUrlInput).should("have.value", value); + return this; + } + + public assertRequiredFieldsErrorsExist() { + return this.assertCommonRequiredFields(this.requiredFields); + } + + public fillData(idpName: string) { + this.fillCommonFields(idpName); + cy.get(this.baseUrlInput).type(idpName + base_url_input_test_value); + return this; + } + + public assertFilledDataEqual(idpName: string) { + this.assertCommonFilledDataEqual(idpName); + this.assertbaseUrlInputEqual(idpName + base_url_input_test_value); + return this; + } +} diff --git a/apps/admin-ui/cypress/support/pages/admin_console/manage/identity_providers/social/ProviderPaypalGeneralSettings.ts b/apps/admin-ui/cypress/support/pages/admin_console/manage/identity_providers/social/ProviderPaypalGeneralSettings.ts new file mode 100644 index 0000000000..a9c53b7465 --- /dev/null +++ b/apps/admin-ui/cypress/support/pages/admin_console/manage/identity_providers/social/ProviderPaypalGeneralSettings.ts @@ -0,0 +1,27 @@ +import ProviderBaseGeneralSettingsPage from "../ProviderBaseGeneralSettingsPage"; + +export default class ProviderPaypalGeneralSettings extends ProviderBaseGeneralSettingsPage { + private targetSandboxSwitch = "#paypalSandbox"; + + public clickTargetSandboxSwitch() { + cy.get(this.targetSandboxSwitch).parent().click(); + return this; + } + + public assertTargetSandboxSwitchTurnedOn(isOn: boolean) { + super.assertSwitchStateOn(cy.get(this.targetSandboxSwitch), isOn); + return this; + } + + public fillData(idpName: string) { + this.fillCommonFields(idpName); + this.clickTargetSandboxSwitch(); + return this; + } + + public assertFilledDataEqual(idpName: string) { + this.assertCommonFilledDataEqual(idpName); + this.assertSwitchStateOn(cy.get(this.targetSandboxSwitch)); + return this; + } +} diff --git a/apps/admin-ui/cypress/support/pages/admin_console/manage/identity_providers/social/ProviderStackoverflowGeneralSettings.ts b/apps/admin-ui/cypress/support/pages/admin_console/manage/identity_providers/social/ProviderStackoverflowGeneralSettings.ts new file mode 100644 index 0000000000..11ab29ff46 --- /dev/null +++ b/apps/admin-ui/cypress/support/pages/admin_console/manage/identity_providers/social/ProviderStackoverflowGeneralSettings.ts @@ -0,0 +1,38 @@ +import ProviderBaseGeneralSettingsPage from "../ProviderBaseGeneralSettingsPage"; + +const key_input_test_value = "key_input_test_value"; + +export default class ProviderStackoverflowGeneralSettings extends ProviderBaseGeneralSettingsPage { + private keyInput = "#stackoverflowKey"; + + constructor() { + super(); + this.requiredFields.push(this.keyInput); + } + + public typeKeyInput(value: string) { + cy.get(this.keyInput).type(value).blur(); + return this; + } + + public assertKeyInputEqual(value: string) { + cy.get(this.keyInput).should("have.value", value); + return this; + } + + public assertRequiredFieldsErrorsExist() { + return this.assertCommonRequiredFields(this.requiredFields); + } + + public fillData(idpName: string) { + this.fillCommonFields(idpName); + this.typeKeyInput(idpName + key_input_test_value); + return this; + } + + public assertFilledDataEqual(idpName: string) { + this.assertCommonFilledDataEqual(idpName); + this.assertKeyInputEqual(idpName + key_input_test_value); + return this; + } +}