Files
tyx_AI_xhs/tests/unit/postv1-all-assets.test.ts
T
suyx 2cd85cd7cd
Dada P0-A isolated Windows CI / validate-and-package (push) Waiting to run
feat(POSTV1-ASSET-ALL-16): 在编辑器接入全部复杂素材
2026-08-06 11:55:06 +08:00

53 lines
2.5 KiB
TypeScript

import { describe, expect, it } from "vitest";
import complexAssetCatalog from "../../apps/web/src/generated/complex-assets.json";
import { P0A_DYNAMIC_STICKERS } from "../../apps/web/src/dynamic-provider.js";
import { DYNAMIC_RENDER_MODELS } from "../../apps/web/src/dynamic-render-models.js";
import { P0A_COLOR_CARDS } from "../../apps/web/src/palette-provider.js";
import { P0A_FONT_OPTIONS, P0A_TEXT_TEMPLATES } from "../../apps/web/src/text-assets.js";
import {
P0A_COLOR_CARD_IDS,
P0A_DYNAMIC_STICKER_IDS,
P0A_REQUIRED_FONT_PANEL_IDS,
P0A_TEXT_TEMPLATE_IDS,
} from "../../packages/template-registry/src/index.js";
describe("POSTV1-ASSET-ALL-16 complete asset catalog", () => {
it("publishes every normalized complex asset instead of the original alpha subset", () => {
expect(P0A_TEXT_TEMPLATE_IDS).toHaveLength(332);
expect(P0A_TEXT_TEMPLATE_IDS[0]).toBe("FLOWER001");
expect(P0A_TEXT_TEMPLATE_IDS.at(-1)).toBe("SIMPLE017");
expect(P0A_REQUIRED_FONT_PANEL_IDS).toHaveLength(86);
expect(P0A_REQUIRED_FONT_PANEL_IDS[0]).toBe("FONT001");
expect(P0A_REQUIRED_FONT_PANEL_IDS.at(-1)).toBe("FONT086");
expect(P0A_COLOR_CARD_IDS).toHaveLength(16);
expect(P0A_COLOR_CARD_IDS[0]).toBe("COLOR001");
expect(P0A_COLOR_CARD_IDS.at(-1)).toBe("COLOR016");
expect(P0A_DYNAMIC_STICKER_IDS).toHaveLength(35);
expect(P0A_DYNAMIC_STICKER_IDS[0]).toBe("DYN001");
expect(P0A_DYNAMIC_STICKER_IDS.at(-1)).toBe("DYN035");
});
it("generates a sanitized browser catalog for every text, font, and dynamic definition", () => {
expect(complexAssetCatalog.schema_version).toBe("DadaComplexBrowserCatalog/v1");
expect(complexAssetCatalog.text_templates).toHaveLength(332);
expect(complexAssetCatalog.font_panel_items).toHaveLength(86);
expect(complexAssetCatalog.dynamic_stickers).toHaveLength(35);
expect(complexAssetCatalog.text_templates.filter((item) => item.preview_asset_id)).toHaveLength(261);
expect(complexAssetCatalog.text_templates.every((item) => item.available)).toBe(true);
expect(JSON.stringify(complexAssetCatalog)).not.toMatch(/[A-Z]:[\\/]/i);
});
it("exposes every generated definition to the editor", () => {
expect(P0A_TEXT_TEMPLATES).toHaveLength(332);
expect(P0A_TEXT_TEMPLATES.every((item) => item.available && item.fontUrl)).toBe(true);
expect(P0A_FONT_OPTIONS).toHaveLength(86);
expect(P0A_COLOR_CARDS).toHaveLength(16);
expect(P0A_DYNAMIC_STICKERS).toHaveLength(35);
expect(Object.keys(DYNAMIC_RENDER_MODELS)).toHaveLength(35);
});
});