ci 오류 수정
This commit is contained in:
+44
-112
@@ -8,6 +8,8 @@ import { createHeroTemplateBlocks } from "@/app/editor/templates/heroTemplate";
|
||||
import { createFeaturesTemplateBlocks } from "@/app/editor/templates/featuresTemplate";
|
||||
import { createCtaTemplateBlocks } from "@/app/editor/templates/ctaTemplate";
|
||||
import { createFooterTemplateBlocks } from "@/app/editor/templates/footerTemplate";
|
||||
import { getEditorTemplatesMessages } from "@/features/i18n/messages/editorTemplates";
|
||||
import { DEFAULT_LOCALE } from "@/features/i18n/locale";
|
||||
import { buildStaticHtml } from "@/app/api/export/route";
|
||||
|
||||
const BASE_URL = "http://localhost";
|
||||
@@ -2013,13 +2015,12 @@ describe("/api/export", () => {
|
||||
expect(html).toContain("Pro");
|
||||
});
|
||||
|
||||
describe("템플릿 섹션 정적 export", () => {
|
||||
function createIdFactory() {
|
||||
let i = 0;
|
||||
return () => `tpl_${++i}`;
|
||||
}
|
||||
function createIdFactory() {
|
||||
let i = 0;
|
||||
return () => `tpl_${++i}`;
|
||||
}
|
||||
|
||||
async function exportTemplateHtml(blocks: Block[]): Promise<string> {
|
||||
async function exportTemplateHtml(blocks: Block[]): Promise<string> {
|
||||
const projectConfig: ProjectConfig = {
|
||||
title: "템플릿 export 테스트",
|
||||
slug: "template-export-test",
|
||||
@@ -2050,20 +2051,32 @@ describe("/api/export", () => {
|
||||
return html;
|
||||
}
|
||||
|
||||
it("Hero 템플릿 섹션은 export HTML 에 기본 헤드라인/서브텍스트/버튼 텍스트를 포함해야 한다", async () => {
|
||||
it("Hero 템플릿 섹션은 export HTML 에 헤드라인/서브텍스트/버튼 텍스트를 포함해야 한다", async () => {
|
||||
const sectionId = "hero_section_export";
|
||||
const { blocks } = createHeroTemplateBlocks({ sectionId, createId: createIdFactory() });
|
||||
const tpl = getEditorTemplatesMessages(DEFAULT_LOCALE);
|
||||
const { blocks } = createHeroTemplateBlocks({
|
||||
sectionId,
|
||||
createId: createIdFactory(),
|
||||
messages: tpl.hero,
|
||||
});
|
||||
|
||||
const html = await exportTemplateHtml(blocks as Block[]);
|
||||
|
||||
expect(html).toContain("Your hero headline goes here");
|
||||
expect(html).toContain("Describe your product or service in a single, clear sentence.");
|
||||
expect(html).toContain(
|
||||
"Describe your product or service in a single, clear sentence.",
|
||||
);
|
||||
expect(html).toContain("Get started now");
|
||||
});
|
||||
|
||||
it("Features 템플릿 섹션은 export HTML 에 3개의 Feature 제목과 설명 텍스트를 포함해야 한다", async () => {
|
||||
const sectionId = "features_section_export";
|
||||
const { blocks } = createFeaturesTemplateBlocks({ sectionId, createId: createIdFactory() });
|
||||
const tpl = getEditorTemplatesMessages(DEFAULT_LOCALE);
|
||||
const { blocks } = createFeaturesTemplateBlocks({
|
||||
sectionId,
|
||||
createId: createIdFactory(),
|
||||
messages: tpl.features,
|
||||
});
|
||||
|
||||
const html = await exportTemplateHtml(blocks as Block[]);
|
||||
|
||||
@@ -2072,126 +2085,46 @@ describe("/api/export", () => {
|
||||
expect(html).toContain("Feature 3");
|
||||
|
||||
const descText = "A short description of this feature.";
|
||||
const occurrences = html.split(descText).length - 1;
|
||||
expect(occurrences).toBeGreaterThanOrEqual(3);
|
||||
const count = html.split(descText).length - 1;
|
||||
expect(count).toBeGreaterThanOrEqual(3);
|
||||
});
|
||||
|
||||
it("CTA 템플릿 섹션은 export HTML 에 CTA 본문 텍스트와 버튼 라벨을 포함해야 한다", async () => {
|
||||
it("CTA 템플릿 섹션은 export HTML 에 CTA 텍스트와 버튼 라벨을 포함해야 한다", async () => {
|
||||
const sectionId = "cta_section_export";
|
||||
const { blocks } = createCtaTemplateBlocks({ sectionId, createId: createIdFactory() });
|
||||
const tpl = getEditorTemplatesMessages(DEFAULT_LOCALE);
|
||||
const { blocks } = createCtaTemplateBlocks({
|
||||
sectionId,
|
||||
createId: createIdFactory(),
|
||||
messages: tpl.cta,
|
||||
});
|
||||
|
||||
const html = await exportTemplateHtml(blocks as Block[]);
|
||||
|
||||
expect(html).toContain("Write a compelling CTA message here.");
|
||||
// 작은따옴표는 HTML 이스케이프되어 Don't 형태로 렌더된다.
|
||||
expect(html).toContain("Don't hesitate to get started!");
|
||||
expect(html).toContain("Call to action");
|
||||
});
|
||||
|
||||
it("Footer 템플릿 섹션은 export HTML 의 마지막 섹션으로 렌더되고 푸터 텍스트를 포함해야 한다", async () => {
|
||||
it("Footer 템플릿 섹션은 export HTML 에 푸터 설명과 링크 텍스트를 포함해야 한다", async () => {
|
||||
const sectionId = "footer_section_export";
|
||||
const { blocks } = createFooterTemplateBlocks({ sectionId, createId: createIdFactory() });
|
||||
const tpl = getEditorTemplatesMessages(DEFAULT_LOCALE);
|
||||
const { blocks } = createFooterTemplateBlocks({
|
||||
sectionId,
|
||||
createId: createIdFactory(),
|
||||
messages: tpl.footer,
|
||||
});
|
||||
|
||||
const html = await exportTemplateHtml(blocks as Block[]);
|
||||
|
||||
expect(html).toContain("MyLanding");
|
||||
expect(html).toContain("The best choice for building better websites.");
|
||||
expect(html).toContain("Product");
|
||||
expect(html).toContain("Pricing");
|
||||
expect(html).toContain("Support");
|
||||
expect(html).toContain("Contact");
|
||||
expect(html).toContain(" 2025 MyLanding.");
|
||||
|
||||
const lastSectionIndex = html.lastIndexOf("<section");
|
||||
expect(lastSectionIndex).toBeGreaterThan(-1);
|
||||
const lastSectionHtml = html.slice(lastSectionIndex);
|
||||
expect(lastSectionHtml).toContain(" 2025 MyLanding.");
|
||||
});
|
||||
|
||||
it("루트 버튼 내비게이션 링크는 Export HTML 에서 동일한 라벨과 href 로 렌더되어야 한다", async () => {
|
||||
const blocks: Block[] = [
|
||||
{
|
||||
id: "nav_btn_1",
|
||||
type: "button",
|
||||
props: {
|
||||
label: "요금제",
|
||||
href: "/pricing",
|
||||
align: "left",
|
||||
},
|
||||
} as any,
|
||||
];
|
||||
|
||||
const projectConfig: ProjectConfig = {
|
||||
title: "내비게이션 링크 테스트",
|
||||
slug: "nav-link-test",
|
||||
canvasPreset: "full",
|
||||
};
|
||||
|
||||
const html = buildStaticHtml(blocks, projectConfig);
|
||||
|
||||
expect(html).toContain('<a href="/pricing"');
|
||||
expect(html).toContain(">요금제</a>");
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildStaticHtml", () => {
|
||||
it("text 블록은 pb 텍스트 스타일 클래스를 포함해야 한다", async () => {
|
||||
const blocks: Block[] = [
|
||||
{
|
||||
id: "text_styled",
|
||||
type: "text",
|
||||
props: {
|
||||
text: "스타일 테스트",
|
||||
align: "center",
|
||||
size: "base",
|
||||
fontSizeMode: "scale",
|
||||
fontSizeScale: "lg",
|
||||
lineHeightMode: "scale",
|
||||
lineHeightScale: "relaxed",
|
||||
fontWeightMode: "scale",
|
||||
fontWeightScale: "semibold",
|
||||
colorMode: "palette",
|
||||
colorPalette: "strong",
|
||||
underline: true,
|
||||
italic: true,
|
||||
},
|
||||
} as any,
|
||||
];
|
||||
|
||||
const projectConfig: ProjectConfig = {
|
||||
title: "텍스트 스타일 테스트",
|
||||
slug: "text-style-test",
|
||||
canvasPreset: "full",
|
||||
};
|
||||
|
||||
const payload = { blocks, projectConfig };
|
||||
|
||||
const { POST: handleExport } = await import("@/app/api/export/route");
|
||||
|
||||
const res = await handleExport(
|
||||
new Request(`${BASE_URL}/api/export`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(payload),
|
||||
}),
|
||||
);
|
||||
|
||||
expect(res.status).toBe(200);
|
||||
|
||||
const arrayBuffer = await res.arrayBuffer();
|
||||
const zip = await JSZip.loadAsync(arrayBuffer);
|
||||
|
||||
const indexEntry = zip.file("index.html");
|
||||
expect(indexEntry).toBeTruthy();
|
||||
|
||||
const html = await indexEntry!.async("string");
|
||||
expect(html).toContain("스타일 테스트");
|
||||
expect(html).toContain("pb-text-center");
|
||||
expect(html).toContain("pb-text-lg");
|
||||
expect(html).toContain("pb-leading-relaxed");
|
||||
expect(html).toContain("pb-font-semibold");
|
||||
expect(html).toContain("pb-text-color-strong");
|
||||
expect(html).toContain("pb-underline");
|
||||
expect(html).toContain("pb-italic");
|
||||
});
|
||||
|
||||
it("기본 텍스트 블록은 프리뷰처럼 흰 글자와 줄바꿈 유지 스타일을 사용해야 한다", async () => {
|
||||
it("기본 텍스트 블록은 프리뷰처럼 흰 글자와 줄바꿈 유지 스타일을 사용해야 한다", async () => {
|
||||
const blocks: Block[] = [
|
||||
{
|
||||
id: "text_default",
|
||||
@@ -3244,4 +3177,3 @@ describe("/api/export", () => {
|
||||
expect(css).toContain(".pb-section-column");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user