feat : overhual [no ci]
This commit is contained in:
@@ -51,14 +51,21 @@ describe("export translations", () => {
|
||||
|
||||
describe("image export controls", () => {
|
||||
it("always offers both export modes even without notes", () => {
|
||||
const html = renderToStaticMarkup(<LocaleBoundary locale="en"><GuideImageExport fileName="guide.png">No notes</GuideImageExport></LocaleBoundary>);
|
||||
const html = renderToStaticMarkup(<LocaleBoundary locale="en"><GuideImageExport allowWithoutNote fileName="guide.png">No notes</GuideImageExport></LocaleBoundary>);
|
||||
expect(html).toContain("Export image");
|
||||
expect(html).toContain("Export without note");
|
||||
expect(html.match(/<button\b/gu)).toHaveLength(2);
|
||||
});
|
||||
|
||||
it("only offers normal export unless note omission is enabled", () => {
|
||||
const html = renderToStaticMarkup(<LocaleBoundary locale="en"><GuideImageExport fileName="overview.png">Overview</GuideImageExport></LocaleBoundary>);
|
||||
expect(html.match(/<button\b/gu)).toHaveLength(1);
|
||||
expect(html).toContain("Export image");
|
||||
expect(html).not.toContain("Export without note");
|
||||
});
|
||||
|
||||
it("disables both modes when an export selection is empty", () => {
|
||||
const html = renderToStaticMarkup(<GuideImageExport fileName="guide.png" disabled>No sections</GuideImageExport>);
|
||||
const html = renderToStaticMarkup(<GuideImageExport allowWithoutNote fileName="guide.png" disabled>No sections</GuideImageExport>);
|
||||
expect(html.match(/\sdisabled=""/gu)).toHaveLength(2);
|
||||
});
|
||||
|
||||
|
||||
+17
-1
@@ -1,4 +1,5 @@
|
||||
import Link from "next/link";
|
||||
import type { ReactElement } from "react";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
@@ -81,6 +82,21 @@ describe("interface translations", () => {
|
||||
expect(html).toContain("Talent Priority");
|
||||
});
|
||||
|
||||
it("localises a lazy child streamed from a server component", () => {
|
||||
const streamedChild = {
|
||||
$$typeof: Symbol.for("react.lazy"),
|
||||
_payload: <Link href="/">Home</Link>,
|
||||
_init: (element: ReactElement) => element,
|
||||
} as unknown as ReactElement;
|
||||
const html = renderToStaticMarkup(
|
||||
<LocaleBoundary locale="en">
|
||||
<Localized attributes={{ "aria-label": "กลับหน้ารวม" }}>{streamedChild}</Localized>
|
||||
</LocaleBoundary>,
|
||||
);
|
||||
expect(html).toContain('aria-label="Back to all guides"');
|
||||
expect(html).toContain("Home");
|
||||
});
|
||||
|
||||
it("preserves custom content while translating only generated headings and conditions", () => {
|
||||
const html = renderToStaticMarkup(<LocaleBoundary locale="en"><input defaultValue="ชื่อภาษาไทย" /><ConditionLabel name="เงื่อนไขของฉัน" index={1} /><ConditionLabel name={null} index={2} /><SectionTitle slug="custom" fallback="หัวข้อของฉัน" /></LocaleBoundary>);
|
||||
expect(html).toContain('value="ชื่อภาษาไทย"');
|
||||
@@ -99,7 +115,7 @@ describe("interface translations", () => {
|
||||
});
|
||||
|
||||
it.each(["th", "en"] as const)("offers both export modes in %s even with no notes", (locale) => {
|
||||
const html = renderToStaticMarkup(<LocaleBoundary locale={locale}><GuideImageExport fileName="test.png">No notes</GuideImageExport></LocaleBoundary>);
|
||||
const html = renderToStaticMarkup(<LocaleBoundary locale={locale}><GuideImageExport allowWithoutNote fileName="test.png">No notes</GuideImageExport></LocaleBoundary>);
|
||||
expect(html).toContain(locale === "en" ? "Export without note" : "ส่งออกภาพโดยไม่รวมโน้ต");
|
||||
expect(html.match(/<button\b/gu)).toHaveLength(2);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user