Files
sendou.ink/app/features/user-page/custom-theme-json.server.test.ts
Kalle 23875c7c67
Some checks failed
E2E Tests / e2e (push) Has been cancelled
Tests and checks on push / run-checks-and-tests (push) Has been cancelled
Updates translation progress / update-translation-progress-issue (push) Has been cancelled
Custom theme improvements (#3410)
Co-authored-by: hfcRed <hfcred@gmx.net>
2026-09-23 17:43:48 +03:00

47 lines
1.2 KiB
TypeScript

import { describe, expect, test } from "vitest";
import * as UserFactory from "~/db/seed/factories/UserFactory";
import * as ThemePalette from "~/features/theme/core/ThemePalette";
import * as UserRepository from "./UserRepository.server";
const CUSTOM_THEME = ThemePalette.build({
baseHue: 268,
baseChroma: 0.05,
accentHue: 253,
accentChroma: 0.24,
bgLightness: 0.17,
chatHue: null,
radiusBox: 3,
radiusField: 2,
radiusSelector: 2,
borderWidth: 2,
sizeField: 1,
sizeSelector: 1,
sizeSpacing: 1,
});
describe("supporter custom theme on the profile layout", () => {
test("comes back parsed", async () => {
const user = await UserFactory.create(null, {
patronTier: 2,
customTheme: CUSTOM_THEME,
});
const layoutData = await UserRepository.findLayoutDataById(user.id);
// `root.tsx` spreads the object into CSS variables, so a raw string renders as garbage
expect(layoutData?.customTheme?.["--_acc-h"]).toBe(
CUSTOM_THEME["--_acc-h"],
);
});
test("is null for a user who is not a supporter", async () => {
const user = await UserFactory.create(null, {
customTheme: CUSTOM_THEME,
});
const layoutData = await UserRepository.findLayoutDataById(user.id);
expect(layoutData?.customTheme).toBeNull();
});
});