96 lines
5.0 KiB
TypeScript
96 lines
5.0 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";
|
|
|
|
function containsAbsolutePath(value: unknown): boolean {
|
|
if (typeof value === "string") return /^[A-Z]:[\\/]/i.test(value);
|
|
if (Array.isArray(value)) return value.some(containsAbsolutePath);
|
|
return value !== null && typeof value === "object" && Object.values(value).some(containsAbsolutePath);
|
|
}
|
|
|
|
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/v2");
|
|
expect(complexAssetCatalog.text_resource_revision).toMatch(/^[a-f0-9]{16}$/);
|
|
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(complexAssetCatalog.text_templates.every((item) => item.render_model.text_layers.length > 0)).toBe(true);
|
|
expect(complexAssetCatalog.text_templates.filter((item) => item.resource_class === "zip_template")).toHaveLength(330);
|
|
expect(complexAssetCatalog.text_templates.reduce((count, item) => count + item.render_model.image_layers.length, 0)).toBe(316);
|
|
expect(complexAssetCatalog.text_templates.reduce((count, item) => count + item.render_model.particle_layers.length, 0)).toBe(9);
|
|
expect(complexAssetCatalog.text_templates.reduce((count, item) => count + item.render_model.text_layers.length, 0)).toBe(490);
|
|
expect(complexAssetCatalog.text_templates.filter((item) => item.render_model.text_layers.some((layer) => "fill_pattern_asset_id" in layer))).toHaveLength(14);
|
|
expect(containsAbsolutePath(complexAssetCatalog)).toBe(false);
|
|
});
|
|
|
|
it("keeps the captured template font, default text, style, and decoration layers", () => {
|
|
const byId = new Map(complexAssetCatalog.text_templates.map((item) => [item.template_id, item]));
|
|
const flower001 = byId.get("FLOWER001")!;
|
|
expect(flower001.default_font_id).toMatch(/^TEXT-FONT-FLOWER001-/);
|
|
expect(flower001.font_match_status).toBe("template_package");
|
|
expect(flower001.render_model.image_layers).toHaveLength(1);
|
|
expect(flower001.render_model.text_layers[0]).toMatchObject({
|
|
fill_color: "#FFC5D4",
|
|
stroke_color: "#FF69A6",
|
|
stroke_width: 5,
|
|
});
|
|
|
|
const flower008 = byId.get("FLOWER008")!;
|
|
expect(flower008.default_text).toBe("Vlog.");
|
|
expect(flower008.default_font_id).toMatch(/^TEXT-FONT-FLOWER008-/);
|
|
|
|
const heading001 = byId.get("H001")!;
|
|
expect(heading001.render_model.image_layers).toHaveLength(5);
|
|
expect(heading001.default_font_id).toMatch(/^TEXT-FONT-H001-/);
|
|
|
|
const materialText = byId.get("FLOWER048")!;
|
|
expect(materialText.render_model.text_layers[0]).toHaveProperty("fill_pattern_asset_id");
|
|
|
|
const underlinedText = byId.get("FLOWER121")!;
|
|
expect(underlinedText.render_model.image_layers).toHaveLength(1);
|
|
|
|
const particleText = byId.get("H013")!;
|
|
expect(particleText.render_model.particle_layers).toHaveLength(3);
|
|
});
|
|
|
|
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);
|
|
});
|
|
});
|