refactor(data): replace schema classes with readonly models

This commit is contained in:
2026-07-17 13:21:40 +08:00
parent 3437312167
commit ae97366a4a
103 changed files with 1220 additions and 2117 deletions
@@ -1,16 +1,18 @@
import { renderToStaticMarkup } from "react-dom/server";
import { describe, expect, it } from "vitest";
import { PrivateAlbum } from "@/data/schemas/private-room";
import {
PrivateAlbumSchema,
type PrivateAlbum,
type PrivateAlbumInput,
} from "@/data/schemas/private-room";
import { PrivateAlbumCard } from "../private-album-card";
const COVER_URL = "/images/private-room/banner.png";
function makeAlbum(
overrides: Partial<Parameters<typeof PrivateAlbum.from>[0]> = {},
): PrivateAlbum {
return PrivateAlbum.from({
function makeAlbum(overrides: Partial<PrivateAlbumInput> = {}): PrivateAlbum {
return PrivateAlbumSchema.parse({
albumId: "album-1",
title: "Private morning",
content: "A quiet morning by the water.",
@@ -61,9 +63,7 @@ describe("PrivateAlbumCard", () => {
expect(html).toContain("8 photos");
expect(html).toContain("A quiet morning by the water.");
expect(html).toContain('aria-label="Open 8 private album photos"');
expect(html).toContain(
'data-analytics-key="private_album.open_gallery"',
);
expect(html).toContain('data-analytics-key="private_album.open_gallery"');
});
it("uses the backend first image as the locked cover", () => {