From f0a79b3ae220e8e8c9c709da5f09bc9a24678a27 Mon Sep 17 00:00:00 2001 From: Tim Roes Date: Wed, 8 Feb 2023 11:27:34 +0100 Subject: [PATCH] Remove experimentation flags for OAuth --- .../hooks/services/Experiment/experiments.ts | 4 -- .../views/auth/OAuthLogin/OAuthLogin.test.tsx | 44 ------------------- .../views/auth/OAuthLogin/OAuthLogin.tsx | 25 ++--------- .../views/auth/SignupPage/SignupPage.tsx | 4 +- 4 files changed, 5 insertions(+), 72 deletions(-) diff --git a/airbyte-webapp/src/hooks/services/Experiment/experiments.ts b/airbyte-webapp/src/hooks/services/Experiment/experiments.ts index 79021d1bcbdc..f5cf670c8611 100644 --- a/airbyte-webapp/src/hooks/services/Experiment/experiments.ts +++ b/airbyte-webapp/src/hooks/services/Experiment/experiments.ts @@ -17,10 +17,6 @@ export interface Experiments { "authPage.hideSelfHostedCTA": boolean; "authPage.signup.hideName": boolean; "authPage.signup.hideCompanyName": boolean; - "authPage.oauth.google": boolean; - "authPage.oauth.github": boolean; - "authPage.oauth.google.signUpPage": boolean; - "authPage.oauth.github.signUpPage": boolean; "onboarding.speedyConnection": boolean; "authPage.oauth.position": "top" | "bottom"; "connection.onboarding.sources": string; diff --git a/airbyte-webapp/src/packages/cloud/views/auth/OAuthLogin/OAuthLogin.test.tsx b/airbyte-webapp/src/packages/cloud/views/auth/OAuthLogin/OAuthLogin.test.tsx index c27ce81cce37..766d02d09d71 100644 --- a/airbyte-webapp/src/packages/cloud/views/auth/OAuthLogin/OAuthLogin.test.tsx +++ b/airbyte-webapp/src/packages/cloud/views/auth/OAuthLogin/OAuthLogin.test.tsx @@ -4,7 +4,6 @@ import { EMPTY } from "rxjs"; import { TestWrapper } from "test-utils/testutils"; import type { useExperiment } from "hooks/services/Experiment"; -import type { Experiments } from "hooks/services/Experiment/experiments"; const mockUseExperiment = jest.fn, Parameters>(); jest.doMock("hooks/services/Experiment", () => ({ @@ -22,28 +21,6 @@ jest.doMock("packages/cloud/services/auth/AuthService", () => ({ // eslint-disable-next-line @typescript-eslint/no-var-requires const { OAuthLogin } = require("./OAuthLogin"); -const createUseExperimentMock = (options: { - google?: boolean; - github?: boolean; - googleSignUp?: boolean; - githubSignUp?: boolean; -}) => { - return (key: keyof Experiments) => { - switch (key) { - case "authPage.oauth.github": - return options.github ?? false; - case "authPage.oauth.google": - return options.google ?? false; - case "authPage.oauth.github.signUpPage": - return options.githubSignUp ?? true; - case "authPage.oauth.google.signUpPage": - return options.googleSignUp ?? true; - default: - throw new Error(`${key} is not mocked`); - } - }; -}; - describe("OAuthLogin", () => { beforeEach(() => { mockUseExperiment.mockReset(); @@ -52,27 +29,6 @@ describe("OAuthLogin", () => { mockLoginWithOAuth.mockReturnValue(EMPTY); }); - it("should render all enabled logins", () => { - mockUseExperiment.mockImplementation(createUseExperimentMock({ google: true, github: true })); - const { getByTestId } = render(, { wrapper: TestWrapper }); - expect(getByTestId("googleOauthLogin")).toBeInTheDocument(); - expect(getByTestId("githubOauthLogin")).toBeInTheDocument(); - }); - - it("should not render buttons that are disabled", () => { - mockUseExperiment.mockImplementation(createUseExperimentMock({ google: false, github: true })); - const { getByTestId, queryByTestId } = render(, { wrapper: TestWrapper }); - expect(queryByTestId("googleOauthLogin")).not.toBeInTheDocument(); - expect(getByTestId("githubOauthLogin")).toBeInTheDocument(); - }); - - it("should not render disabled buttons for sign-up page", () => { - mockUseExperiment.mockImplementation(createUseExperimentMock({ google: true, github: true, googleSignUp: false })); - const { getByTestId, queryByTestId } = render(, { wrapper: TestWrapper }); - expect(queryByTestId("googleOauthLogin")).not.toBeInTheDocument(); - expect(getByTestId("githubOauthLogin")).toBeInTheDocument(); - }); - it("should call auth service for Google", () => { const { getByTestId } = render(, { wrapper: TestWrapper }); userEvents.click(getByTestId("googleOauthLogin")); diff --git a/airbyte-webapp/src/packages/cloud/views/auth/OAuthLogin/OAuthLogin.tsx b/airbyte-webapp/src/packages/cloud/views/auth/OAuthLogin/OAuthLogin.tsx index 869cdfc40608..545844d3c6d3 100644 --- a/airbyte-webapp/src/packages/cloud/views/auth/OAuthLogin/OAuthLogin.tsx +++ b/airbyte-webapp/src/packages/cloud/views/auth/OAuthLogin/OAuthLogin.tsx @@ -5,7 +5,6 @@ import { Subscription } from "rxjs"; import { Spinner } from "components/ui/Spinner"; -import { useExperiment } from "hooks/services/Experiment"; import { OAuthProviders } from "packages/cloud/lib/auth/AuthProviders"; import { useAuthService } from "packages/cloud/services/auth/AuthService"; @@ -31,35 +30,17 @@ const GoogleButton: React.FC<{ onClick: () => void }> = ({ onClick }) => { ); }; -interface OAuthLoginProps { - isSignUpPage?: boolean; -} - -export const OAuthLogin: React.FC = ({ isSignUpPage }) => { +export const OAuthLogin: React.FC = () => { const { formatMessage } = useIntl(); const { loginWithOAuth } = useAuthService(); const stateSubscription = useRef(); const [errorCode, setErrorCode] = useState(); const [isLoading, setLoading] = useState(false); - const isGitHubLoginEnabled = useExperiment("authPage.oauth.github", true); - const isGoogleLoginEnabled = useExperiment("authPage.oauth.google", true); - const isGitHubEnabledOnSignUp = useExperiment("authPage.oauth.github.signUpPage", true); - const isGoogleEnabledOnSignUp = useExperiment("authPage.oauth.google.signUpPage", true); - - const showGoogleLogin = isGoogleLoginEnabled && (!isSignUpPage || isGoogleEnabledOnSignUp); - const showGitHubLogin = isGitHubLoginEnabled && (!isSignUpPage || isGitHubEnabledOnSignUp); - - const isAnyOauthEnabled = showGoogleLogin || showGitHubLogin; - useUnmount(() => { stateSubscription.current?.unsubscribe(); }); - if (!isAnyOauthEnabled) { - return null; - } - const getErrorMessage = (error: string): string | undefined => { switch (error) { // The following error codes are not really errors, thus we'll ignore them. @@ -107,8 +88,8 @@ export const OAuthLogin: React.FC = ({ isSignUpPage }) => { )} {!isLoading && (
- {showGoogleLogin && login("google")} />} - {showGitHubLogin && login("github")} />} + login("google")} /> + login("github")} />
)} {errorMessage &&
{errorMessage}
} diff --git a/airbyte-webapp/src/packages/cloud/views/auth/SignupPage/SignupPage.tsx b/airbyte-webapp/src/packages/cloud/views/auth/SignupPage/SignupPage.tsx index a010cbea363b..b498ed90b149 100644 --- a/airbyte-webapp/src/packages/cloud/views/auth/SignupPage/SignupPage.tsx +++ b/airbyte-webapp/src/packages/cloud/views/auth/SignupPage/SignupPage.tsx @@ -39,7 +39,7 @@ const SignupPage: React.FC = ({ highlightStyle }) => { {oAuthPosition === "top" && ( <> - + )} @@ -47,7 +47,7 @@ const SignupPage: React.FC = ({ highlightStyle }) => { {oAuthPosition === "bottom" && ( <> - + )}