refactor(#416): delete old LoginButton, replaced by OAuthButton
All checks were successful
ci/woodpecker/push/web Pipeline was successful
All checks were successful
ci/woodpecker/push/web Pipeline was successful
LoginButton.tsx and LoginButton.test.tsx removed. The login page now uses OAuthButton, LoginForm, and AuthDivider from the auth redesign. Refs #416 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,45 +0,0 @@
|
||||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { LoginButton } from "./LoginButton";
|
||||
|
||||
const { mockOAuth2 } = vi.hoisted(() => ({
|
||||
mockOAuth2: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("@/lib/auth-client", () => ({
|
||||
signIn: {
|
||||
oauth2: mockOAuth2,
|
||||
},
|
||||
}));
|
||||
|
||||
describe("LoginButton", (): void => {
|
||||
beforeEach((): void => {
|
||||
mockOAuth2.mockClear();
|
||||
});
|
||||
|
||||
it("should render sign in button", (): void => {
|
||||
render(<LoginButton />);
|
||||
const button = screen.getByRole("button", { name: /sign in/i });
|
||||
expect(button).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("should initiate OAuth2 sign-in on click", async (): Promise<void> => {
|
||||
const user = userEvent.setup();
|
||||
render(<LoginButton />);
|
||||
|
||||
const button = screen.getByRole("button", { name: /sign in/i });
|
||||
await user.click(button);
|
||||
|
||||
expect(mockOAuth2).toHaveBeenCalledWith({
|
||||
providerId: "authentik",
|
||||
callbackURL: "/",
|
||||
});
|
||||
});
|
||||
|
||||
it("should have proper styling", (): void => {
|
||||
render(<LoginButton />);
|
||||
const button = screen.getByRole("button", { name: /sign in/i });
|
||||
expect(button).toHaveClass("w-full");
|
||||
});
|
||||
});
|
||||
@@ -1,18 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { Button } from "@mosaic/ui";
|
||||
import { signIn } from "@/lib/auth-client";
|
||||
|
||||
export function LoginButton(): React.JSX.Element {
|
||||
const handleLogin = (): void => {
|
||||
// Use BetterAuth's genericOAuth client to initiate the OIDC flow.
|
||||
// This POSTs to /auth/sign-in/oauth2 and follows the returned redirect URL.
|
||||
void signIn.oauth2({ providerId: "authentik", callbackURL: "/" });
|
||||
};
|
||||
|
||||
return (
|
||||
<Button variant="primary" onClick={handleLogin} className="w-full">
|
||||
Sign In with Authentik
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user