Skip to content

Commit 9834ca1

Browse files
author
Tim Roes
authored
Remove experimentation flags for OAuth (#22554)
1 parent 3694eb9 commit 9834ca1

File tree

4 files changed

+5
-72
lines changed

4 files changed

+5
-72
lines changed

airbyte-webapp/src/hooks/services/Experiment/experiments.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ export interface Experiments {
1717
"authPage.hideSelfHostedCTA": boolean;
1818
"authPage.signup.hideName": boolean;
1919
"authPage.signup.hideCompanyName": boolean;
20-
"authPage.oauth.google": boolean;
21-
"authPage.oauth.github": boolean;
22-
"authPage.oauth.google.signUpPage": boolean;
23-
"authPage.oauth.github.signUpPage": boolean;
2420
"onboarding.speedyConnection": boolean;
2521
"authPage.oauth.position": "top" | "bottom";
2622
"connection.onboarding.sources": string;

airbyte-webapp/src/packages/cloud/views/auth/OAuthLogin/OAuthLogin.test.tsx

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { EMPTY } from "rxjs";
44
import { TestWrapper } from "test-utils/testutils";
55

66
import type { useExperiment } from "hooks/services/Experiment";
7-
import type { Experiments } from "hooks/services/Experiment/experiments";
87

98
const mockUseExperiment = jest.fn<ReturnType<typeof useExperiment>, Parameters<typeof useExperiment>>();
109
jest.doMock("hooks/services/Experiment", () => ({
@@ -22,28 +21,6 @@ jest.doMock("packages/cloud/services/auth/AuthService", () => ({
2221
// eslint-disable-next-line @typescript-eslint/no-var-requires
2322
const { OAuthLogin } = require("./OAuthLogin");
2423

25-
const createUseExperimentMock = (options: {
26-
google?: boolean;
27-
github?: boolean;
28-
googleSignUp?: boolean;
29-
githubSignUp?: boolean;
30-
}) => {
31-
return (key: keyof Experiments) => {
32-
switch (key) {
33-
case "authPage.oauth.github":
34-
return options.github ?? false;
35-
case "authPage.oauth.google":
36-
return options.google ?? false;
37-
case "authPage.oauth.github.signUpPage":
38-
return options.githubSignUp ?? true;
39-
case "authPage.oauth.google.signUpPage":
40-
return options.googleSignUp ?? true;
41-
default:
42-
throw new Error(`${key} is not mocked`);
43-
}
44-
};
45-
};
46-
4724
describe("OAuthLogin", () => {
4825
beforeEach(() => {
4926
mockUseExperiment.mockReset();
@@ -52,27 +29,6 @@ describe("OAuthLogin", () => {
5229
mockLoginWithOAuth.mockReturnValue(EMPTY);
5330
});
5431

55-
it("should render all enabled logins", () => {
56-
mockUseExperiment.mockImplementation(createUseExperimentMock({ google: true, github: true }));
57-
const { getByTestId } = render(<OAuthLogin />, { wrapper: TestWrapper });
58-
expect(getByTestId("googleOauthLogin")).toBeInTheDocument();
59-
expect(getByTestId("githubOauthLogin")).toBeInTheDocument();
60-
});
61-
62-
it("should not render buttons that are disabled", () => {
63-
mockUseExperiment.mockImplementation(createUseExperimentMock({ google: false, github: true }));
64-
const { getByTestId, queryByTestId } = render(<OAuthLogin />, { wrapper: TestWrapper });
65-
expect(queryByTestId("googleOauthLogin")).not.toBeInTheDocument();
66-
expect(getByTestId("githubOauthLogin")).toBeInTheDocument();
67-
});
68-
69-
it("should not render disabled buttons for sign-up page", () => {
70-
mockUseExperiment.mockImplementation(createUseExperimentMock({ google: true, github: true, googleSignUp: false }));
71-
const { getByTestId, queryByTestId } = render(<OAuthLogin isSignUpPage />, { wrapper: TestWrapper });
72-
expect(queryByTestId("googleOauthLogin")).not.toBeInTheDocument();
73-
expect(getByTestId("githubOauthLogin")).toBeInTheDocument();
74-
});
75-
7632
it("should call auth service for Google", () => {
7733
const { getByTestId } = render(<OAuthLogin />, { wrapper: TestWrapper });
7834
userEvents.click(getByTestId("googleOauthLogin"));

airbyte-webapp/src/packages/cloud/views/auth/OAuthLogin/OAuthLogin.tsx

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { Subscription } from "rxjs";
55

66
import { Spinner } from "components/ui/Spinner";
77

8-
import { useExperiment } from "hooks/services/Experiment";
98
import { OAuthProviders } from "packages/cloud/lib/auth/AuthProviders";
109
import { useAuthService } from "packages/cloud/services/auth/AuthService";
1110

@@ -31,35 +30,17 @@ const GoogleButton: React.FC<{ onClick: () => void }> = ({ onClick }) => {
3130
);
3231
};
3332

34-
interface OAuthLoginProps {
35-
isSignUpPage?: boolean;
36-
}
37-
38-
export const OAuthLogin: React.FC<OAuthLoginProps> = ({ isSignUpPage }) => {
33+
export const OAuthLogin: React.FC = () => {
3934
const { formatMessage } = useIntl();
4035
const { loginWithOAuth } = useAuthService();
4136
const stateSubscription = useRef<Subscription>();
4237
const [errorCode, setErrorCode] = useState<string>();
4338
const [isLoading, setLoading] = useState(false);
4439

45-
const isGitHubLoginEnabled = useExperiment("authPage.oauth.github", true);
46-
const isGoogleLoginEnabled = useExperiment("authPage.oauth.google", true);
47-
const isGitHubEnabledOnSignUp = useExperiment("authPage.oauth.github.signUpPage", true);
48-
const isGoogleEnabledOnSignUp = useExperiment("authPage.oauth.google.signUpPage", true);
49-
50-
const showGoogleLogin = isGoogleLoginEnabled && (!isSignUpPage || isGoogleEnabledOnSignUp);
51-
const showGitHubLogin = isGitHubLoginEnabled && (!isSignUpPage || isGitHubEnabledOnSignUp);
52-
53-
const isAnyOauthEnabled = showGoogleLogin || showGitHubLogin;
54-
5540
useUnmount(() => {
5641
stateSubscription.current?.unsubscribe();
5742
});
5843

59-
if (!isAnyOauthEnabled) {
60-
return null;
61-
}
62-
6344
const getErrorMessage = (error: string): string | undefined => {
6445
switch (error) {
6546
// The following error codes are not really errors, thus we'll ignore them.
@@ -107,8 +88,8 @@ export const OAuthLogin: React.FC<OAuthLoginProps> = ({ isSignUpPage }) => {
10788
)}
10889
{!isLoading && (
10990
<div className={styles.buttons}>
110-
{showGoogleLogin && <GoogleButton onClick={() => login("google")} />}
111-
{showGitHubLogin && <GitHubButton onClick={() => login("github")} />}
91+
<GoogleButton onClick={() => login("google")} />
92+
<GitHubButton onClick={() => login("github")} />
11293
</div>
11394
)}
11495
{errorMessage && <div className={styles.error}>{errorMessage}</div>}

airbyte-webapp/src/packages/cloud/views/auth/SignupPage/SignupPage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ const SignupPage: React.FC<SignupPageProps> = ({ highlightStyle }) => {
3939
<SpecialBlock />
4040
{oAuthPosition === "top" && (
4141
<>
42-
<OAuthLogin isSignUpPage />
42+
<OAuthLogin />
4343
<Separator />
4444
</>
4545
)}
4646
<SignupForm />
4747
{oAuthPosition === "bottom" && (
4848
<>
4949
<Separator />
50-
<OAuthLogin isSignUpPage />
50+
<OAuthLogin />
5151
</>
5252
)}
5353
<Disclaimer />

0 commit comments

Comments
 (0)