Files
OpenFrontIO/tests/ApiSchemas.test.ts
T
Josh Harris ff5eb78689 Login with Google — client UI (#4028) (#4279)
Resolves #4028 (client half — backend is openfrontio/infra#368, which
must be deployed first).

## Description:

Adds "Login with Google" to the client, alongside the existing Discord
login. Companion to the backend PR (openfrontio/infra#368).

- `Auth.ts` — `googleLogin()` (full-page redirect to
`/auth/login/google?redirect_uri=…`, mirrors `discordLogin()`).
- `ApiSchemas.ts` — `GoogleUserSchema` + optional `user.google` on
`UserMeResponseSchema`.
- `AccountModal.ts` — a "Login with Google" button (Google brand
guidelines: white surface, dark text, the multicolor "G" mark) in the
login options, and the logged-in view now renders a Google-authenticated
user's email (also added `google` to `isLinkedAccount()`).
- `en.json` — `main.login_google`.
- `resources/images/GoogleLogo.svg` — the Google "G" mark.

> **Draft.** Depends on infra#368 being deployed (the button hits the
live `/auth/login/google`).

## Please complete the following:

- [x] I have added screenshots for all UI updates <!-- TODO: add
screenshot of the Google button -->
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory <!-- no client
tests exist for AccountModal/Auth; verified via tsc --noEmit + eslint.
Backend behaviour is covered in infra#368 -->

## Please put your Discord username so you can be contacted if a bug or
regression is found:

jish
2026-06-19 11:47:40 +01:00

26 lines
848 B
TypeScript

import { GoogleUser, GoogleUserSchema } from "../src/core/ApiSchemas";
describe("GoogleUserSchema", () => {
it("accepts a valid email", () => {
const result = GoogleUserSchema.safeParse({ email: "user@example.com" });
expect(result.success).toBe(true);
if (result.success) {
expect(result.data.email).toBe("user@example.com");
}
});
it("rejects a missing email", () => {
expect(GoogleUserSchema.safeParse({}).success).toBe(false);
});
it("rejects a non-string email", () => {
expect(GoogleUserSchema.safeParse({ email: 123 }).success).toBe(false);
});
it("infers the GoogleUser type from the schema", () => {
// Compile-time check that GoogleUser is derived from the schema.
const user: GoogleUser = { email: "typed@example.com" };
expect(user.email).toBe("typed@example.com");
});
});