feat : add language export and some image gen optimaize
This commit is contained in:
@@ -2,7 +2,10 @@ import { createElement } from "react";
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { GuideImageExport } from "@/components/public/guide-image-export";
|
||||
import {
|
||||
GuideImageExport,
|
||||
imageExportFileName,
|
||||
} from "@/components/public/guide-image-export";
|
||||
import { MaterialPoster } from "@/components/public/material-poster";
|
||||
import { ConstellationImage } from "@/components/public/constellation-image";
|
||||
import type { PublicGuide } from "@/lib/guides/queries";
|
||||
@@ -12,14 +15,16 @@ describe("image export controls", () => {
|
||||
const html = renderToStaticMarkup(<GuideImageExport fileName="guide.png">No notes</GuideImageExport>);
|
||||
expect(html).toContain("ส่งออกภาพ");
|
||||
expect(html).toContain("ส่งออกภาพโดยไม่รวมโน้ต");
|
||||
expect(html.match(/<button\b/gu)).toHaveLength(2);
|
||||
expect(html).toContain("ไทย");
|
||||
expect(html).toContain("English");
|
||||
expect(html.match(/<button\b/gu)).toHaveLength(4);
|
||||
});
|
||||
|
||||
it("shows only the Thai export button when no-note export is disabled", () => {
|
||||
it("shows only one export action when no-note export is disabled", () => {
|
||||
const html = renderToStaticMarkup(<GuideImageExport fileName="guide.png" allowWithoutNotes={false}>Content</GuideImageExport>);
|
||||
expect(html).toContain("ส่งออกภาพ");
|
||||
expect(html).not.toContain("ส่งออกภาพโดยไม่รวมโน้ต");
|
||||
expect(html.match(/<button\b/gu)).toHaveLength(1);
|
||||
expect(html.match(/<button\b/gu)).toHaveLength(3);
|
||||
});
|
||||
|
||||
it("disables both modes when an export selection is empty", () => {
|
||||
@@ -32,12 +37,25 @@ describe("image export controls", () => {
|
||||
const group = { rows: [], note } as unknown as PublicGuide["constellationGroups"][number];
|
||||
const html = renderToStaticMarkup(createElement(ConstellationImage, { guide, group }));
|
||||
expect(html).toContain("Raiden’s Constellations");
|
||||
expect(html).not.toContain("กลุ่มดาวของ Raiden");
|
||||
expect(html).toContain("Team Damage");
|
||||
expect(html).toContain("ดาเมจทั้งทีม");
|
||||
expect(html).toContain('data-export-note="true"');
|
||||
expect(html).toContain(note);
|
||||
});
|
||||
});
|
||||
|
||||
describe("image export filenames", () => {
|
||||
it("adds the selected language after the note variant", () => {
|
||||
expect(imageExportFileName("Raiden.png", "th", false)).toBe("Raiden-th.png");
|
||||
expect(imageExportFileName("Raiden.png", "en", true)).toBe("Raiden-without-notes-en.png");
|
||||
});
|
||||
|
||||
it("can preserve English-only export filenames", () => {
|
||||
expect(imageExportFileName("Raiden-materials.png", "th", false, false)).toBe("Raiden-materials.png");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe("material poster text", () => {
|
||||
const props = {
|
||||
|
||||
Reference in New Issue
Block a user