Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bd6be2fb97 |
+1
-12
@@ -27,19 +27,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
npm ci
|
npm ci
|
||||||
|
|
||||||
- name: Generate Prisma Client
|
|
||||||
env:
|
|
||||||
# CI에서는 실제 DB에 접속하지 않고 Prisma Client만 생성하면 되므로,
|
|
||||||
# 유효한 형식의 더미 DATABASE_URL 을 사용한다.
|
|
||||||
DATABASE_URL: postgresql://example:example@localhost:5432/example
|
|
||||||
run: |
|
|
||||||
npx prisma generate
|
|
||||||
|
|
||||||
- name: Run unit tests
|
- name: Run unit tests
|
||||||
env:
|
|
||||||
# API 유닛 테스트에서도 PrismaClient가 필요하므로,
|
|
||||||
# generate 단계와 동일한 더미 DATABASE_URL 을 사용한다.
|
|
||||||
DATABASE_URL: postgresql://example:example@localhost:5432/example
|
|
||||||
run: |
|
run: |
|
||||||
npm test
|
npm test
|
||||||
|
|
||||||
@@ -114,3 +102,4 @@ jobs:
|
|||||||
-H "Authorization: token $CI_TOKEN" \
|
-H "Authorization: token $CI_TOKEN" \
|
||||||
"$CI_BASE_URL/api/v1/repos/$CI_OWNER/$CI_REPO/pulls/$pr_number/merge" \
|
"$CI_BASE_URL/api/v1/repos/$CI_OWNER/$CI_REPO/pulls/$pr_number/merge" \
|
||||||
-d "$merge_payload" || true
|
-d "$merge_payload" || true
|
||||||
|
# CI 테스트용 더미 주석
|
||||||
|
|||||||
+1
-89
@@ -37,12 +37,6 @@ export default function EditorPage() {
|
|||||||
const addHeroTemplateSection = useEditorStore((state) => state.addHeroTemplateSection);
|
const addHeroTemplateSection = useEditorStore((state) => state.addHeroTemplateSection);
|
||||||
const addFeaturesTemplateSection = useEditorStore((state) => state.addFeaturesTemplateSection);
|
const addFeaturesTemplateSection = useEditorStore((state) => state.addFeaturesTemplateSection);
|
||||||
const addCtaTemplateSection = useEditorStore((state) => state.addCtaTemplateSection);
|
const addCtaTemplateSection = useEditorStore((state) => state.addCtaTemplateSection);
|
||||||
const addFaqTemplateSection = useEditorStore((state) => state.addFaqTemplateSection);
|
|
||||||
const addPricingTemplateSection = useEditorStore((state) => state.addPricingTemplateSection);
|
|
||||||
const addTestimonialsTemplateSection = useEditorStore((state) => state.addTestimonialsTemplateSection);
|
|
||||||
const addBlogTemplateSection = useEditorStore((state) => state.addBlogTemplateSection);
|
|
||||||
const addTeamTemplateSection = useEditorStore((state) => state.addTeamTemplateSection);
|
|
||||||
const addFooterTemplateSection = useEditorStore((state) => state.addFooterTemplateSection);
|
|
||||||
const updateBlock = useEditorStore((state) => state.updateBlock);
|
const updateBlock = useEditorStore((state) => state.updateBlock);
|
||||||
const selectBlock = useEditorStore((state) => state.selectBlock);
|
const selectBlock = useEditorStore((state) => state.selectBlock);
|
||||||
const replaceBlocks = useEditorStore((state) => state.replaceBlocks);
|
const replaceBlocks = useEditorStore((state) => state.replaceBlocks);
|
||||||
@@ -50,8 +44,6 @@ export default function EditorPage() {
|
|||||||
const moveBlock = useEditorStore((state) => state.moveBlock);
|
const moveBlock = useEditorStore((state) => state.moveBlock);
|
||||||
const undo = useEditorStore((state) => state.undo);
|
const undo = useEditorStore((state) => state.undo);
|
||||||
const redo = useEditorStore((state) => state.redo);
|
const redo = useEditorStore((state) => state.redo);
|
||||||
const removeBlock = useEditorStore((state) => state.removeBlock);
|
|
||||||
const duplicateBlock = useEditorStore((state) => state.duplicateBlock);
|
|
||||||
|
|
||||||
const [editingBlockId, setEditingBlockId] = useState<string | null>(null);
|
const [editingBlockId, setEditingBlockId] = useState<string | null>(null);
|
||||||
const [editingText, setEditingText] = useState("");
|
const [editingText, setEditingText] = useState("");
|
||||||
@@ -208,8 +200,7 @@ export default function EditorPage() {
|
|||||||
|
|
||||||
const rootBlocks = blocks.filter((block) => !block.sectionId);
|
const rootBlocks = blocks.filter((block) => !block.sectionId);
|
||||||
|
|
||||||
// 에디터 전역에서 Undo/Redo 단축키(Cmd/Ctrl+Z, Cmd/Ctrl+Shift+Z),
|
// 에디터 전역에서 Undo/Redo 단축키(Cmd/Ctrl+Z, Cmd/Ctrl+Shift+Z)와
|
||||||
// Delete/Backspace 기반 삭제, Cmd/Ctrl+D 기반 복제,
|
|
||||||
// ArrowUp/ArrowDown을 이용한 선택 블록 이동을 처리한다.
|
// ArrowUp/ArrowDown을 이용한 선택 블록 이동을 처리한다.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleKeyDown = (event: KeyboardEvent) => {
|
const handleKeyDown = (event: KeyboardEvent) => {
|
||||||
@@ -246,29 +237,8 @@ export default function EditorPage() {
|
|||||||
const isMac = navigator.platform.toLowerCase().includes("mac");
|
const isMac = navigator.platform.toLowerCase().includes("mac");
|
||||||
const metaKey = isMac ? event.metaKey : event.ctrlKey;
|
const metaKey = isMac ? event.metaKey : event.ctrlKey;
|
||||||
|
|
||||||
// Delete / Backspace 로 선택된 블록 삭제
|
|
||||||
if (event.key === "Delete" || event.key === "Backspace") {
|
|
||||||
const { selectedBlockId: currentSelectedId } = (useEditorStore as any).getState();
|
|
||||||
if (currentSelectedId) {
|
|
||||||
event.preventDefault();
|
|
||||||
removeBlock(currentSelectedId);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cmd/Ctrl 없는 경우에는 여기서 종료한다.
|
|
||||||
if (!metaKey) return;
|
if (!metaKey) return;
|
||||||
|
|
||||||
// Cmd/Ctrl + D → 현재 선택된 블록 복제
|
|
||||||
if (event.key.toLowerCase() === "d") {
|
|
||||||
const { selectedBlockId: currentSelectedId } = (useEditorStore as any).getState();
|
|
||||||
if (currentSelectedId) {
|
|
||||||
event.preventDefault();
|
|
||||||
duplicateBlock(currentSelectedId);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cmd/Ctrl + Shift + Z → Redo
|
// Cmd/Ctrl + Shift + Z → Redo
|
||||||
if (event.key.toLowerCase() === "z" && event.shiftKey) {
|
if (event.key.toLowerCase() === "z" && event.shiftKey) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -379,48 +349,6 @@ export default function EditorPage() {
|
|||||||
>
|
>
|
||||||
CTA 템플릿 추가
|
CTA 템플릿 추가
|
||||||
</button>
|
</button>
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="w-full rounded border border-slate-700 bg-slate-900 px-3 py-2 text-left text-xs hover:bg-slate-800"
|
|
||||||
onClick={addFaqTemplateSection}
|
|
||||||
>
|
|
||||||
FAQ 템플릿 추가
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="w-full rounded border border-slate-700 bg-slate-900 px-3 py-2 text-left text-xs hover:bg-slate-800"
|
|
||||||
onClick={addPricingTemplateSection}
|
|
||||||
>
|
|
||||||
Pricing 템플릿 추가
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="w-full rounded border border-slate-700 bg-slate-900 px-3 py-2 text-left text-xs hover:bg-slate-800"
|
|
||||||
onClick={addTestimonialsTemplateSection}
|
|
||||||
>
|
|
||||||
Testimonials 템플릿 추가
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="w-full rounded border border-slate-700 bg-slate-900 px-3 py-2 text-left text-xs hover:bg-slate-800"
|
|
||||||
onClick={addBlogTemplateSection}
|
|
||||||
>
|
|
||||||
Blog 템플릿 추가
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="w-full rounded border border-slate-700 bg-slate-900 px-3 py-2 text-left text-xs hover:bg-slate-800"
|
|
||||||
onClick={addTeamTemplateSection}
|
|
||||||
>
|
|
||||||
Team 템플릿 추가
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="w-full rounded border border-slate-700 bg-slate-900 px-3 py-2 text-left text-xs hover:bg-slate-800"
|
|
||||||
onClick={addFooterTemplateSection}
|
|
||||||
>
|
|
||||||
Footer 템플릿 추가
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
<p className="text-xs text-slate-500">
|
<p className="text-xs text-slate-500">
|
||||||
Text / Image / Button / Section 블록을 이 영역에서 추가할 수 있습니다.
|
Text / Image / Button / Section 블록을 이 영역에서 추가할 수 있습니다.
|
||||||
@@ -453,22 +381,6 @@ export default function EditorPage() {
|
|||||||
<h2 className="font-medium mb-2">속성 패널</h2>
|
<h2 className="font-medium mb-2">속성 패널</h2>
|
||||||
{selectedBlockId ? (
|
{selectedBlockId ? (
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
<div className="flex gap-2 text-[11px]">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="flex-1 rounded border border-slate-700 bg-slate-900 px-2 py-1 text-slate-100 hover:bg-red-900/60 hover:border-red-700"
|
|
||||||
onClick={() => removeBlock(selectedBlockId)}
|
|
||||||
>
|
|
||||||
블록 삭제
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="flex-1 rounded border border-slate-700 bg-slate-900 px-2 py-1 text-slate-100 hover:bg-slate-800"
|
|
||||||
onClick={() => duplicateBlock(selectedBlockId)}
|
|
||||||
>
|
|
||||||
블록 복제
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
{(() => {
|
{(() => {
|
||||||
const selectedBlock = blocks.find((b) => b.id === selectedBlockId);
|
const selectedBlock = blocks.find((b) => b.id === selectedBlockId);
|
||||||
if (!selectedBlock) return null;
|
if (!selectedBlock) return null;
|
||||||
|
|||||||
@@ -60,12 +60,6 @@ export interface EditorState {
|
|||||||
addHeroTemplateSection: () => void;
|
addHeroTemplateSection: () => void;
|
||||||
addFeaturesTemplateSection: () => void;
|
addFeaturesTemplateSection: () => void;
|
||||||
addCtaTemplateSection: () => void;
|
addCtaTemplateSection: () => void;
|
||||||
addFaqTemplateSection: () => void;
|
|
||||||
addPricingTemplateSection: () => void;
|
|
||||||
addTestimonialsTemplateSection: () => void;
|
|
||||||
addBlogTemplateSection: () => void;
|
|
||||||
addTeamTemplateSection: () => void;
|
|
||||||
addFooterTemplateSection: () => void;
|
|
||||||
updateBlock: (id: string, partial: Partial<TextBlockProps & ButtonBlockProps>) => void;
|
updateBlock: (id: string, partial: Partial<TextBlockProps & ButtonBlockProps>) => void;
|
||||||
selectBlock: (id: string | null) => void;
|
selectBlock: (id: string | null) => void;
|
||||||
replaceBlocks: (blocks: Block[]) => void;
|
replaceBlocks: (blocks: Block[]) => void;
|
||||||
@@ -73,8 +67,6 @@ export interface EditorState {
|
|||||||
moveBlock: (id: string, sectionId: string | null, columnId: string | null) => void;
|
moveBlock: (id: string, sectionId: string | null, columnId: string | null) => void;
|
||||||
undo: () => void;
|
undo: () => void;
|
||||||
redo: () => void;
|
redo: () => void;
|
||||||
removeBlock: (id: string) => void;
|
|
||||||
duplicateBlock: (id: string) => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 간단한 ID 생성기 (추후 uuid 라이브러리로 교체 가능)
|
// 간단한 ID 생성기 (추후 uuid 라이브러리로 교체 가능)
|
||||||
@@ -271,225 +263,6 @@ const createEditorState = (set: any, get: any): EditorState => ({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// Blog 템플릿 섹션 추가: 3컬럼 포스트 카드(제목/요약)를 생성한다
|
|
||||||
addBlogTemplateSection: () => {
|
|
||||||
const sectionId = createId();
|
|
||||||
|
|
||||||
const columns = [
|
|
||||||
{ id: `${sectionId}_col_1`, span: 4 },
|
|
||||||
{ id: `${sectionId}_col_2`, span: 4 },
|
|
||||||
{ id: `${sectionId}_col_3`, span: 4 },
|
|
||||||
];
|
|
||||||
|
|
||||||
const sectionBlock: Block = {
|
|
||||||
id: sectionId,
|
|
||||||
type: "section",
|
|
||||||
props: {
|
|
||||||
background: "default",
|
|
||||||
paddingY: "lg",
|
|
||||||
columns,
|
|
||||||
},
|
|
||||||
sectionId: null,
|
|
||||||
columnId: null,
|
|
||||||
};
|
|
||||||
|
|
||||||
const postDefinitions = [
|
|
||||||
{ title: "블로그 포스트 1", summary: "첫 번째 포스트 요약을 여기에 입력하세요." },
|
|
||||||
{ title: "블로그 포스트 2", summary: "두 번째 포스트 요약을 여기에 입력하세요." },
|
|
||||||
{ title: "블로그 포스트 3", summary: "세 번째 포스트 요약을 여기에 입력하세요." },
|
|
||||||
];
|
|
||||||
|
|
||||||
const blogBlocks: Block[] = columns.flatMap((col, index) => {
|
|
||||||
const post = postDefinitions[index] ?? postDefinitions[0];
|
|
||||||
|
|
||||||
const titleId = createId();
|
|
||||||
const summaryId = createId();
|
|
||||||
|
|
||||||
const titleBlock: Block = {
|
|
||||||
id: titleId,
|
|
||||||
type: "text",
|
|
||||||
props: {
|
|
||||||
text: post.title,
|
|
||||||
align: "left",
|
|
||||||
size: "lg",
|
|
||||||
},
|
|
||||||
sectionId,
|
|
||||||
columnId: col.id,
|
|
||||||
};
|
|
||||||
|
|
||||||
const summaryBlock: Block = {
|
|
||||||
id: summaryId,
|
|
||||||
type: "text",
|
|
||||||
props: {
|
|
||||||
text: post.summary,
|
|
||||||
align: "left",
|
|
||||||
size: "sm",
|
|
||||||
},
|
|
||||||
sectionId,
|
|
||||||
columnId: col.id,
|
|
||||||
};
|
|
||||||
|
|
||||||
return [titleBlock, summaryBlock];
|
|
||||||
});
|
|
||||||
|
|
||||||
const lastBlockId = blogBlocks[blogBlocks.length - 1].id;
|
|
||||||
|
|
||||||
set((state: EditorState) => {
|
|
||||||
const newBlocks = [...state.blocks, sectionBlock, ...blogBlocks];
|
|
||||||
|
|
||||||
return {
|
|
||||||
blocks: newBlocks,
|
|
||||||
selectedBlockId: lastBlockId,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
// Team 템플릿 섹션 추가: 3컬럼 팀 카드(이름/역할/소개)를 생성한다
|
|
||||||
addTeamTemplateSection: () => {
|
|
||||||
const sectionId = createId();
|
|
||||||
|
|
||||||
const columns = [
|
|
||||||
{ id: `${sectionId}_col_1`, span: 4 },
|
|
||||||
{ id: `${sectionId}_col_2`, span: 4 },
|
|
||||||
{ id: `${sectionId}_col_3`, span: 4 },
|
|
||||||
];
|
|
||||||
|
|
||||||
const sectionBlock: Block = {
|
|
||||||
id: sectionId,
|
|
||||||
type: "section",
|
|
||||||
props: {
|
|
||||||
background: "muted",
|
|
||||||
paddingY: "lg",
|
|
||||||
columns,
|
|
||||||
},
|
|
||||||
sectionId: null,
|
|
||||||
columnId: null,
|
|
||||||
};
|
|
||||||
|
|
||||||
const memberDefinitions = [
|
|
||||||
{ name: "홍길동", role: "Product Designer", bio: "사용자 경험을 설계합니다." },
|
|
||||||
{ name: "김영희", role: "Frontend Engineer", bio: "깔끔한 UI를 구현합니다." },
|
|
||||||
{ name: "이철수", role: "Backend Engineer", bio: "안정적인 인프라를 책임집니다." },
|
|
||||||
];
|
|
||||||
|
|
||||||
const teamBlocks: Block[] = columns.flatMap((col, index) => {
|
|
||||||
const m = memberDefinitions[index] ?? memberDefinitions[0];
|
|
||||||
|
|
||||||
const nameId = createId();
|
|
||||||
const roleId = createId();
|
|
||||||
const bioId = createId();
|
|
||||||
|
|
||||||
const nameBlock: Block = {
|
|
||||||
id: nameId,
|
|
||||||
type: "text",
|
|
||||||
props: {
|
|
||||||
text: m.name,
|
|
||||||
align: "center",
|
|
||||||
size: "lg",
|
|
||||||
},
|
|
||||||
sectionId,
|
|
||||||
columnId: col.id,
|
|
||||||
};
|
|
||||||
|
|
||||||
const roleBlock: Block = {
|
|
||||||
id: roleId,
|
|
||||||
type: "text",
|
|
||||||
props: {
|
|
||||||
text: m.role,
|
|
||||||
align: "center",
|
|
||||||
size: "base",
|
|
||||||
},
|
|
||||||
sectionId,
|
|
||||||
columnId: col.id,
|
|
||||||
};
|
|
||||||
|
|
||||||
const bioBlock: Block = {
|
|
||||||
id: bioId,
|
|
||||||
type: "text",
|
|
||||||
props: {
|
|
||||||
text: m.bio,
|
|
||||||
align: "center",
|
|
||||||
size: "sm",
|
|
||||||
},
|
|
||||||
sectionId,
|
|
||||||
columnId: col.id,
|
|
||||||
};
|
|
||||||
|
|
||||||
return [nameBlock, roleBlock, bioBlock];
|
|
||||||
});
|
|
||||||
|
|
||||||
const lastBlockId = teamBlocks[teamBlocks.length - 1].id;
|
|
||||||
|
|
||||||
set((state: EditorState) => {
|
|
||||||
const newBlocks = [...state.blocks, sectionBlock, ...teamBlocks];
|
|
||||||
|
|
||||||
return {
|
|
||||||
blocks: newBlocks,
|
|
||||||
selectedBlockId: lastBlockId,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
// Footer 템플릿 섹션 추가: 링크/카피라이트 텍스트가 포함된 1컬럼 섹션을 생성한다
|
|
||||||
addFooterTemplateSection: () => {
|
|
||||||
const sectionId = createId();
|
|
||||||
|
|
||||||
const sectionBlock: Block = {
|
|
||||||
id: sectionId,
|
|
||||||
type: "section",
|
|
||||||
props: {
|
|
||||||
background: "muted",
|
|
||||||
paddingY: "md",
|
|
||||||
columns: [
|
|
||||||
{
|
|
||||||
id: `${sectionId}_col_1`,
|
|
||||||
span: 12,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
sectionId: null,
|
|
||||||
columnId: null,
|
|
||||||
};
|
|
||||||
|
|
||||||
const firstColumnId = `${sectionId}_col_1`;
|
|
||||||
|
|
||||||
const linksId = createId();
|
|
||||||
const copyrightId = createId();
|
|
||||||
|
|
||||||
const linksBlock: Block = {
|
|
||||||
id: linksId,
|
|
||||||
type: "text",
|
|
||||||
props: {
|
|
||||||
text: "이용약관 · 개인정보처리방침",
|
|
||||||
align: "center",
|
|
||||||
size: "sm",
|
|
||||||
},
|
|
||||||
sectionId,
|
|
||||||
columnId: firstColumnId,
|
|
||||||
};
|
|
||||||
|
|
||||||
const copyrightBlock: Block = {
|
|
||||||
id: copyrightId,
|
|
||||||
type: "text",
|
|
||||||
props: {
|
|
||||||
text: "© 2025 MyLanding. All rights reserved.",
|
|
||||||
align: "center",
|
|
||||||
size: "sm",
|
|
||||||
},
|
|
||||||
sectionId,
|
|
||||||
columnId: firstColumnId,
|
|
||||||
};
|
|
||||||
|
|
||||||
set((state: EditorState) => {
|
|
||||||
const newBlocks = [...state.blocks, sectionBlock, linksBlock, copyrightBlock];
|
|
||||||
|
|
||||||
return {
|
|
||||||
blocks: newBlocks,
|
|
||||||
selectedBlockId: copyrightId,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
// CTA 템플릿 섹션 추가: 텍스트와 버튼이 포함된 1컬럼 섹션을 생성한다
|
// CTA 템플릿 섹션 추가: 텍스트와 버튼이 포함된 1컬럼 섹션을 생성한다
|
||||||
addCtaTemplateSection: () => {
|
addCtaTemplateSection: () => {
|
||||||
const sectionId = createId();
|
const sectionId = createId();
|
||||||
@@ -548,233 +321,6 @@ const createEditorState = (set: any, get: any): EditorState => ({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// FAQ 템플릿 섹션 추가: 질문/답변 쌍이 수직으로 나열된 섹션을 생성한다
|
|
||||||
addFaqTemplateSection: () => {
|
|
||||||
const sectionId = createId();
|
|
||||||
|
|
||||||
const sectionBlock: Block = {
|
|
||||||
id: sectionId,
|
|
||||||
type: "section",
|
|
||||||
props: {
|
|
||||||
background: "default",
|
|
||||||
paddingY: "md",
|
|
||||||
columns: [
|
|
||||||
{
|
|
||||||
id: `${sectionId}_col_1`,
|
|
||||||
span: 12,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
sectionId: null,
|
|
||||||
columnId: null,
|
|
||||||
};
|
|
||||||
|
|
||||||
const firstColumnId = `${sectionId}_col_1`;
|
|
||||||
|
|
||||||
const faqPairs = [
|
|
||||||
{
|
|
||||||
question: "자주 묻는 질문 1",
|
|
||||||
answer: "첫 번째 질문에 대한 답변을 여기에 입력하세요.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
question: "자주 묻는 질문 2",
|
|
||||||
answer: "두 번째 질문에 대한 답변을 여기에 입력하세요.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
question: "자주 묻는 질문 3",
|
|
||||||
answer: "세 번째 질문에 대한 답변을 여기에 입력하세요.",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const faqBlocks: Block[] = faqPairs.flatMap((pair) => {
|
|
||||||
const qId = createId();
|
|
||||||
const aId = createId();
|
|
||||||
|
|
||||||
const questionBlock: Block = {
|
|
||||||
id: qId,
|
|
||||||
type: "text",
|
|
||||||
props: {
|
|
||||||
text: pair.question,
|
|
||||||
align: "left",
|
|
||||||
size: "lg",
|
|
||||||
},
|
|
||||||
sectionId,
|
|
||||||
columnId: firstColumnId,
|
|
||||||
};
|
|
||||||
|
|
||||||
const answerBlock: Block = {
|
|
||||||
id: aId,
|
|
||||||
type: "text",
|
|
||||||
props: {
|
|
||||||
text: pair.answer,
|
|
||||||
align: "left",
|
|
||||||
size: "sm",
|
|
||||||
},
|
|
||||||
sectionId,
|
|
||||||
columnId: firstColumnId,
|
|
||||||
};
|
|
||||||
|
|
||||||
return [questionBlock, answerBlock];
|
|
||||||
});
|
|
||||||
|
|
||||||
const lastBlockId = faqBlocks[faqBlocks.length - 1].id;
|
|
||||||
|
|
||||||
set((state: EditorState) => {
|
|
||||||
const newBlocks = [...state.blocks, sectionBlock, ...faqBlocks];
|
|
||||||
|
|
||||||
return {
|
|
||||||
blocks: newBlocks,
|
|
||||||
selectedBlockId: lastBlockId,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
// Pricing 템플릿 섹션 추가: 3컬럼 요금제 카드(플랜 이름/가격/설명)를 생성한다
|
|
||||||
addPricingTemplateSection: () => {
|
|
||||||
const sectionId = createId();
|
|
||||||
|
|
||||||
const columns = [
|
|
||||||
{ id: `${sectionId}_col_1`, span: 4 },
|
|
||||||
{ id: `${sectionId}_col_2`, span: 4 },
|
|
||||||
{ id: `${sectionId}_col_3`, span: 4 },
|
|
||||||
];
|
|
||||||
|
|
||||||
const sectionBlock: Block = {
|
|
||||||
id: sectionId,
|
|
||||||
type: "section",
|
|
||||||
props: {
|
|
||||||
background: "muted",
|
|
||||||
paddingY: "lg",
|
|
||||||
columns,
|
|
||||||
},
|
|
||||||
sectionId: null,
|
|
||||||
columnId: null,
|
|
||||||
};
|
|
||||||
|
|
||||||
const planDefinitions = [
|
|
||||||
{ name: "Basic", price: "₩9,900/월" },
|
|
||||||
{ name: "Pro", price: "₩29,900/월" },
|
|
||||||
{ name: "Enterprise", price: "문의" },
|
|
||||||
];
|
|
||||||
|
|
||||||
const pricingBlocks: Block[] = columns.flatMap((col, index) => {
|
|
||||||
const plan = planDefinitions[index] ?? planDefinitions[0];
|
|
||||||
|
|
||||||
const nameId = createId();
|
|
||||||
const priceId = createId();
|
|
||||||
|
|
||||||
const nameBlock: Block = {
|
|
||||||
id: nameId,
|
|
||||||
type: "text",
|
|
||||||
props: {
|
|
||||||
text: plan.name,
|
|
||||||
align: "center",
|
|
||||||
size: "lg",
|
|
||||||
},
|
|
||||||
sectionId,
|
|
||||||
columnId: col.id,
|
|
||||||
};
|
|
||||||
|
|
||||||
const priceBlock: Block = {
|
|
||||||
id: priceId,
|
|
||||||
type: "text",
|
|
||||||
props: {
|
|
||||||
text: plan.price,
|
|
||||||
align: "center",
|
|
||||||
size: "base",
|
|
||||||
},
|
|
||||||
sectionId,
|
|
||||||
columnId: col.id,
|
|
||||||
};
|
|
||||||
|
|
||||||
return [nameBlock, priceBlock];
|
|
||||||
});
|
|
||||||
|
|
||||||
const lastBlockId = pricingBlocks[pricingBlocks.length - 1].id;
|
|
||||||
|
|
||||||
set((state: EditorState) => {
|
|
||||||
const newBlocks = [...state.blocks, sectionBlock, ...pricingBlocks];
|
|
||||||
|
|
||||||
return {
|
|
||||||
blocks: newBlocks,
|
|
||||||
selectedBlockId: lastBlockId,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
// Testimonials 템플릿 섹션 추가: 3컬럼 후기 카드(본문/작성자)를 생성한다
|
|
||||||
addTestimonialsTemplateSection: () => {
|
|
||||||
const sectionId = createId();
|
|
||||||
|
|
||||||
const columns = [
|
|
||||||
{ id: `${sectionId}_col_1`, span: 4 },
|
|
||||||
{ id: `${sectionId}_col_2`, span: 4 },
|
|
||||||
{ id: `${sectionId}_col_3`, span: 4 },
|
|
||||||
];
|
|
||||||
|
|
||||||
const sectionBlock: Block = {
|
|
||||||
id: sectionId,
|
|
||||||
type: "section",
|
|
||||||
props: {
|
|
||||||
background: "default",
|
|
||||||
paddingY: "lg",
|
|
||||||
columns,
|
|
||||||
},
|
|
||||||
sectionId: null,
|
|
||||||
columnId: null,
|
|
||||||
};
|
|
||||||
|
|
||||||
const testimonialDefinitions = [
|
|
||||||
{ body: "이 서비스 덕분에 랜딩 페이지 제작 시간이 크게 줄었습니다.", author: "홍길동" },
|
|
||||||
{ body: "디자인을 잘 못해도 깔끔한 페이지를 만들 수 있어요.", author: "김영희" },
|
|
||||||
{ body: "팀 전체가 만족하는 빌더입니다.", author: "이철수" },
|
|
||||||
];
|
|
||||||
|
|
||||||
const testimonialBlocks: Block[] = columns.flatMap((col, index) => {
|
|
||||||
const t = testimonialDefinitions[index] ?? testimonialDefinitions[0];
|
|
||||||
|
|
||||||
const bodyId = createId();
|
|
||||||
const authorId = createId();
|
|
||||||
|
|
||||||
const bodyBlock: Block = {
|
|
||||||
id: bodyId,
|
|
||||||
type: "text",
|
|
||||||
props: {
|
|
||||||
text: t.body,
|
|
||||||
align: "left",
|
|
||||||
size: "base",
|
|
||||||
},
|
|
||||||
sectionId,
|
|
||||||
columnId: col.id,
|
|
||||||
};
|
|
||||||
|
|
||||||
const authorBlock: Block = {
|
|
||||||
id: authorId,
|
|
||||||
type: "text",
|
|
||||||
props: {
|
|
||||||
text: `- ${t.author}`,
|
|
||||||
align: "left",
|
|
||||||
size: "sm",
|
|
||||||
},
|
|
||||||
sectionId,
|
|
||||||
columnId: col.id,
|
|
||||||
};
|
|
||||||
|
|
||||||
return [bodyBlock, authorBlock];
|
|
||||||
});
|
|
||||||
|
|
||||||
const lastBlockId = testimonialBlocks[testimonialBlocks.length - 1].id;
|
|
||||||
|
|
||||||
set((state: EditorState) => {
|
|
||||||
const newBlocks = [...state.blocks, sectionBlock, ...testimonialBlocks];
|
|
||||||
|
|
||||||
return {
|
|
||||||
blocks: newBlocks,
|
|
||||||
selectedBlockId: lastBlockId,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
// 이미지 블록 추가: 기본 플레이스홀더와 함께 생성 후 선택 상태로 만든다
|
// 이미지 블록 추가: 기본 플레이스홀더와 함께 생성 후 선택 상태로 만든다
|
||||||
addImageBlock: () => {
|
addImageBlock: () => {
|
||||||
const id = createId();
|
const id = createId();
|
||||||
@@ -940,63 +486,6 @@ const createEditorState = (set: any, get: any): EditorState => ({
|
|||||||
),
|
),
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
removeBlock: (id) => {
|
|
||||||
set((state: EditorState) => {
|
|
||||||
const current = state.blocks;
|
|
||||||
const index = current.findIndex((b) => b.id === id);
|
|
||||||
if (index === -1) {
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
const nextBlocks = current.filter((b) => b.id !== id);
|
|
||||||
|
|
||||||
// 선택 상태는 삭제된 블록의 이전 블록 또는 다음 블록으로 이동한다.
|
|
||||||
let nextSelected: string | null = null;
|
|
||||||
if (nextBlocks.length > 0) {
|
|
||||||
const prevIndex = index - 1;
|
|
||||||
if (prevIndex >= 0) {
|
|
||||||
nextSelected = nextBlocks[prevIndex].id;
|
|
||||||
} else {
|
|
||||||
// 첫 블록이 삭제된 경우, 새 첫 블록을 선택한다.
|
|
||||||
nextSelected = nextBlocks[0].id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
blocks: nextBlocks,
|
|
||||||
selectedBlockId: nextSelected,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
},
|
|
||||||
duplicateBlock: (id) => {
|
|
||||||
set((state: EditorState) => {
|
|
||||||
const current = state.blocks;
|
|
||||||
const index = current.findIndex((b) => b.id === id);
|
|
||||||
if (index === -1) {
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
const original = current[index];
|
|
||||||
const newId = createId();
|
|
||||||
|
|
||||||
const cloned: Block = {
|
|
||||||
...original,
|
|
||||||
id: newId,
|
|
||||||
// props 는 얕은 복사로 충분 (현재 props 는 모두 평면 구조)
|
|
||||||
props: { ...(original.props as any) },
|
|
||||||
};
|
|
||||||
|
|
||||||
const nextBlocks = [...current];
|
|
||||||
nextBlocks.splice(index + 1, 0, cloned);
|
|
||||||
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
blocks: nextBlocks,
|
|
||||||
selectedBlockId: newId,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
},
|
|
||||||
undo: () => {
|
undo: () => {
|
||||||
const { history, blocks } = get();
|
const { history, blocks } = get();
|
||||||
if (history.length === 0) return;
|
if (history.length === 0) return;
|
||||||
|
|||||||
@@ -1,26 +1,7 @@
|
|||||||
import "dotenv/config";
|
import "dotenv/config";
|
||||||
import { describe, it, expect, vi } from "vitest";
|
import { describe, it, expect } from "vitest";
|
||||||
|
import { POST as createProject } from "@/app/api/projects/route";
|
||||||
// PrismaClient를 실제 DB 대신 메모리 기반 저장소를 사용하는 목으로 대체한다.
|
import { GET as getProjectBySlug } from "@/app/api/projects/[slug]/route";
|
||||||
// 이렇게 하면 CI/로컬 어디에서도 DATABASE_URL 이나 실제 DB 없이 API 테스트를 실행할 수 있다.
|
|
||||||
const inMemoryProjects: any[] = [];
|
|
||||||
|
|
||||||
vi.mock("@/generated/prisma/client", () => {
|
|
||||||
class PrismaClientMock {
|
|
||||||
project = {
|
|
||||||
create: async ({ data }: any) => {
|
|
||||||
const project = { id: inMemoryProjects.length + 1, ...data };
|
|
||||||
inMemoryProjects.push(project);
|
|
||||||
return project;
|
|
||||||
},
|
|
||||||
findUnique: async ({ where: { slug } }: any) => {
|
|
||||||
return inMemoryProjects.find((p) => p.slug === slug) ?? null;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return { PrismaClient: PrismaClientMock };
|
|
||||||
});
|
|
||||||
|
|
||||||
const BASE_URL = "http://localhost";
|
const BASE_URL = "http://localhost";
|
||||||
|
|
||||||
@@ -38,8 +19,6 @@ describe("/api/projects", () => {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
const { POST: createProject } = await import("@/app/api/projects/route");
|
|
||||||
|
|
||||||
const createResponse = await createProject(
|
const createResponse = await createProject(
|
||||||
new Request(`${BASE_URL}/api/projects`, {
|
new Request(`${BASE_URL}/api/projects`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -58,8 +37,6 @@ describe("/api/projects", () => {
|
|||||||
expect(created.title).toBe(payload.title);
|
expect(created.title).toBe(payload.title);
|
||||||
expect(created.slug).toBe(payload.slug);
|
expect(created.slug).toBe(payload.slug);
|
||||||
|
|
||||||
const { GET: getProjectBySlug } = await import("@/app/api/projects/[slug]/route");
|
|
||||||
|
|
||||||
const getResponse = await getProjectBySlug(
|
const getResponse = await getProjectBySlug(
|
||||||
new Request(`${BASE_URL}/api/projects/${payload.slug}`),
|
new Request(`${BASE_URL}/api/projects/${payload.slug}`),
|
||||||
{ params: { slug: payload.slug } } as any,
|
{ params: { slug: payload.slug } } as any,
|
||||||
|
|||||||
+10
-140
@@ -25,8 +25,8 @@ test("텍스트 블록을 더블클릭해서 내용을 수정할 수 있어야
|
|||||||
|
|
||||||
// 기존 텍스트 블록을 더블클릭해서 편집 모드로 전환한다.
|
// 기존 텍스트 블록을 더블클릭해서 편집 모드로 전환한다.
|
||||||
const canvas = page.getByTestId("editor-canvas");
|
const canvas = page.getByTestId("editor-canvas");
|
||||||
const block = canvas.getByTestId("editor-block").nth(0);
|
const block = canvas.getByText("새 텍스트");
|
||||||
await block.dblclick({ force: true });
|
await block.dblclick();
|
||||||
|
|
||||||
// 편집 모드에서 텍스트를 변경한다.
|
// 편집 모드에서 텍스트를 변경한다.
|
||||||
const editor = page.getByRole("textbox", { name: "텍스트 블록 내용 편집" });
|
const editor = page.getByRole("textbox", { name: "텍스트 블록 내용 편집" });
|
||||||
@@ -46,8 +46,7 @@ test("속성 패널에서 선택된 텍스트 블록 내용을 수정하면 캔
|
|||||||
|
|
||||||
// 캔버스 블록을 클릭해서 선택한다.
|
// 캔버스 블록을 클릭해서 선택한다.
|
||||||
const canvas = page.getByTestId("editor-canvas");
|
const canvas = page.getByTestId("editor-canvas");
|
||||||
const firstBlock = canvas.getByTestId("editor-block").nth(0);
|
await canvas.getByText("새 텍스트").click();
|
||||||
await firstBlock.click({ force: true });
|
|
||||||
|
|
||||||
// 우측 속성 패널에서 텍스트를 수정한다.
|
// 우측 속성 패널에서 텍스트를 수정한다.
|
||||||
const sidebarEditor = page.getByRole("textbox", { name: "선택한 텍스트 블록 내용" });
|
const sidebarEditor = page.getByRole("textbox", { name: "선택한 텍스트 블록 내용" });
|
||||||
@@ -71,15 +70,16 @@ test("여러 텍스트 블록 중 선택을 전환하면 속성 패널 내용과
|
|||||||
const secondBlock = blocks.nth(1);
|
const secondBlock = blocks.nth(1);
|
||||||
|
|
||||||
// 첫 번째 블록을 선택하고, 속성 패널에서 텍스트를 변경한다.
|
// 첫 번째 블록을 선택하고, 속성 패널에서 텍스트를 변경한다.
|
||||||
await firstBlock.click({ force: true });
|
await firstBlock.click();
|
||||||
const sidebarEditor = page.getByRole("textbox", { name: "선택한 텍스트 블록 내용" });
|
const sidebarEditor = page.getByRole("textbox", { name: "선택한 텍스트 블록 내용" });
|
||||||
await sidebarEditor.fill("첫 번째 블록");
|
await sidebarEditor.fill("첫 번째 블록");
|
||||||
|
|
||||||
// 두 번째 블록을 선택하고, 다시 속성 패널에서 텍스트를 변경한다.
|
// 두 번째 블록을 선택하고, 다시 속성 패널에서 텍스트를 변경한다.
|
||||||
await secondBlock.click({ force: true });
|
await secondBlock.click();
|
||||||
await sidebarEditor.fill("두 번째 블록");
|
await sidebarEditor.fill("두 번째 블록");
|
||||||
|
|
||||||
// 캔버스에는 두 번째 블록의 텍스트가 보여야 한다.
|
// 캔버스에는 두 블록의 텍스트가 모두 보여야 한다.
|
||||||
|
await expect(canvas.getByText("첫 번째 블록")).toBeVisible();
|
||||||
await expect(canvas.getByText("두 번째 블록")).toBeVisible();
|
await expect(canvas.getByText("두 번째 블록")).toBeVisible();
|
||||||
|
|
||||||
// 현재 선택된 블록은 두 번째 블록이어야 한다.
|
// 현재 선택된 블록은 두 번째 블록이어야 한다.
|
||||||
@@ -97,7 +97,7 @@ test("텍스트 블록의 정렬과 글자 크기를 속성 패널에서 변경
|
|||||||
await page.getByRole("button", { name: "텍스트 블록 추가" }).click();
|
await page.getByRole("button", { name: "텍스트 블록 추가" }).click();
|
||||||
const canvas = page.getByTestId("editor-canvas");
|
const canvas = page.getByTestId("editor-canvas");
|
||||||
const block = canvas.getByTestId("editor-block").nth(0);
|
const block = canvas.getByTestId("editor-block").nth(0);
|
||||||
await block.click({ force: true });
|
await block.click();
|
||||||
|
|
||||||
// 속성 패널에서 정렬을 가운데로 변경한다.
|
// 속성 패널에서 정렬을 가운데로 변경한다.
|
||||||
const alignSelect = page.getByRole("combobox", { name: "정렬" });
|
const alignSelect = page.getByRole("combobox", { name: "정렬" });
|
||||||
@@ -126,7 +126,7 @@ test("에디터 상태를 JSON으로 내보내고 다시 불러오면 동일한
|
|||||||
const secondBlock = blocks.nth(1);
|
const secondBlock = blocks.nth(1);
|
||||||
|
|
||||||
// 첫 번째 블록: 텍스트/정렬/크기 설정
|
// 첫 번째 블록: 텍스트/정렬/크기 설정
|
||||||
await firstBlock.click({ force: true });
|
await firstBlock.click();
|
||||||
const sidebarEditor = page.getByRole("textbox", { name: "선택한 텍스트 블록 내용" });
|
const sidebarEditor = page.getByRole("textbox", { name: "선택한 텍스트 블록 내용" });
|
||||||
await sidebarEditor.fill("첫 번째 JSON 블록");
|
await sidebarEditor.fill("첫 번째 JSON 블록");
|
||||||
const alignSelect = page.getByRole("combobox", { name: "정렬" });
|
const alignSelect = page.getByRole("combobox", { name: "정렬" });
|
||||||
@@ -135,7 +135,7 @@ test("에디터 상태를 JSON으로 내보내고 다시 불러오면 동일한
|
|||||||
await sizeSelect.selectOption("sm");
|
await sizeSelect.selectOption("sm");
|
||||||
|
|
||||||
// 두 번째 블록: 텍스트/정렬/크기 설정
|
// 두 번째 블록: 텍스트/정렬/크기 설정
|
||||||
await secondBlock.click({ force: true });
|
await secondBlock.click();
|
||||||
await sidebarEditor.fill("두 번째 JSON 블록");
|
await sidebarEditor.fill("두 번째 JSON 블록");
|
||||||
await alignSelect.selectOption("right");
|
await alignSelect.selectOption("right");
|
||||||
await sizeSelect.selectOption("lg");
|
await sizeSelect.selectOption("lg");
|
||||||
@@ -337,86 +337,6 @@ test("CTA 템플릿 버튼을 클릭하면 CTA 텍스트와 버튼이 포함된
|
|||||||
await expect(ctaButton).toBeVisible();
|
await expect(ctaButton).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("FAQ 템플릿 버튼을 클릭하면 질문/답변 텍스트가 세 쌍 이상 생성되어야 한다", async ({ page }) => {
|
|
||||||
await page.goto("/editor");
|
|
||||||
|
|
||||||
const canvas = page.getByTestId("editor-canvas");
|
|
||||||
|
|
||||||
await page.getByRole("button", { name: "FAQ 템플릿 추가" }).click();
|
|
||||||
|
|
||||||
// 기본 FAQ 질문/답변 텍스트들이 렌더되어야 한다.
|
|
||||||
await expect(canvas.getByText("자주 묻는 질문 1")).toBeVisible();
|
|
||||||
await expect(canvas.getByText("첫 번째 질문에 대한 답변을 여기에 입력하세요.")).toBeVisible();
|
|
||||||
await expect(canvas.getByText("자주 묻는 질문 2")).toBeVisible();
|
|
||||||
await expect(canvas.getByText("자주 묻는 질문 3")).toBeVisible();
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Pricing 템플릿 버튼을 클릭하면 3개의 요금제 카드가 생성되어야 한다", async ({ page }) => {
|
|
||||||
await page.goto("/editor");
|
|
||||||
|
|
||||||
const canvas = page.getByTestId("editor-canvas");
|
|
||||||
|
|
||||||
await page.getByRole("button", { name: "Pricing 템플릿 추가" }).click();
|
|
||||||
|
|
||||||
await expect(canvas.getByText("Basic")).toBeVisible();
|
|
||||||
await expect(canvas.getByText("₩9,900/월")).toBeVisible();
|
|
||||||
await expect(canvas.getByText("Pro")).toBeVisible();
|
|
||||||
await expect(canvas.getByText("₩29,900/월")).toBeVisible();
|
|
||||||
await expect(canvas.getByText("Enterprise")).toBeVisible();
|
|
||||||
await expect(canvas.getByText("문의")).toBeVisible();
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Testimonials 템플릿 버튼을 클릭하면 3개의 후기 카드가 생성되어야 한다", async ({ page }) => {
|
|
||||||
await page.goto("/editor");
|
|
||||||
|
|
||||||
const canvas = page.getByTestId("editor-canvas");
|
|
||||||
|
|
||||||
await page.getByRole("button", { name: "Testimonials 템플릿 추가" }).click();
|
|
||||||
|
|
||||||
await expect(canvas.getByText("이 서비스 덕분에 랜딩 페이지 제작 시간이 크게 줄었습니다.")).toBeVisible();
|
|
||||||
await expect(canvas.getByText("디자인을 잘 못해도 깔끔한 페이지를 만들 수 있어요.")).toBeVisible();
|
|
||||||
await expect(canvas.getByText("팀 전체가 만족하는 빌더입니다.")).toBeVisible();
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Blog 템플릿 버튼을 클릭하면 3개의 포스트 카드(제목/요약)가 생성되어야 한다", async ({ page }) => {
|
|
||||||
await page.goto("/editor");
|
|
||||||
|
|
||||||
const canvas = page.getByTestId("editor-canvas");
|
|
||||||
|
|
||||||
await page.getByRole("button", { name: "Blog 템플릿 추가" }).click();
|
|
||||||
|
|
||||||
await expect(canvas.getByText("블로그 포스트 1")).toBeVisible();
|
|
||||||
await expect(canvas.getByText("첫 번째 포스트 요약을 여기에 입력하세요.")).toBeVisible();
|
|
||||||
await expect(canvas.getByText("블로그 포스트 2")).toBeVisible();
|
|
||||||
await expect(canvas.getByText("블로그 포스트 3")).toBeVisible();
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Team 템플릿 버튼을 클릭하면 3명의 팀 카드가 생성되어야 한다", async ({ page }) => {
|
|
||||||
await page.goto("/editor");
|
|
||||||
|
|
||||||
const canvas = page.getByTestId("editor-canvas");
|
|
||||||
|
|
||||||
await page.getByRole("button", { name: "Team 템플릿 추가" }).click();
|
|
||||||
|
|
||||||
await expect(canvas.getByText("홍길동")).toBeVisible();
|
|
||||||
await expect(canvas.getByText("Product Designer")).toBeVisible();
|
|
||||||
await expect(canvas.getByText("김영희")).toBeVisible();
|
|
||||||
await expect(canvas.getByText("Frontend Engineer")).toBeVisible();
|
|
||||||
await expect(canvas.getByText("이철수")).toBeVisible();
|
|
||||||
await expect(canvas.getByText("Backend Engineer")).toBeVisible();
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Footer 템플릿 버튼을 클릭하면 링크/카피라이트 텍스트가 포함된 섹션이 생성되어야 한다", async ({ page }) => {
|
|
||||||
await page.goto("/editor");
|
|
||||||
|
|
||||||
const canvas = page.getByTestId("editor-canvas");
|
|
||||||
|
|
||||||
await page.getByRole("button", { name: "Footer 템플릿 추가" }).click();
|
|
||||||
|
|
||||||
await expect(canvas.getByText("이용약관 · 개인정보처리방침")).toBeVisible();
|
|
||||||
await expect(canvas.getByText("© 2025 MyLanding. All rights reserved.")).toBeVisible();
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Cmd/Ctrl+Z로 블록 추가를 Undo 하고 Cmd/Ctrl+Shift+Z로 Redo 할 수 있어야 한다", async ({ page }) => {
|
test("Cmd/Ctrl+Z로 블록 추가를 Undo 하고 Cmd/Ctrl+Shift+Z로 Redo 할 수 있어야 한다", async ({ page }) => {
|
||||||
await page.goto("/editor");
|
await page.goto("/editor");
|
||||||
|
|
||||||
@@ -472,53 +392,3 @@ test("ArrowUp/ArrowDown 키로 선택된 블록을 위/아래로 이동하며
|
|||||||
await page.keyboard.press("ArrowUp");
|
await page.keyboard.press("ArrowUp");
|
||||||
await expect(blocks.nth(1)).toHaveAttribute("data-selected", "true");
|
await expect(blocks.nth(1)).toHaveAttribute("data-selected", "true");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("속성 패널의 블록 삭제 버튼으로 선택된 블록을 삭제할 수 있어야 한다", async ({ page }) => {
|
|
||||||
await page.goto("/editor");
|
|
||||||
|
|
||||||
const canvas = page.getByTestId("editor-canvas");
|
|
||||||
|
|
||||||
// 텍스트 블록 두 개를 추가한다.
|
|
||||||
await page.getByRole("button", { name: "텍스트 블록 추가" }).click();
|
|
||||||
await page.getByRole("button", { name: "텍스트 블록 추가" }).click();
|
|
||||||
|
|
||||||
const blocks = canvas.getByTestId("editor-block");
|
|
||||||
await expect(blocks).toHaveCount(2);
|
|
||||||
|
|
||||||
// 두 번째 블록을 선택한 다음, 속성 패널에서 "블록 삭제" 버튼을 클릭한다.
|
|
||||||
await blocks.nth(1).click();
|
|
||||||
await page.getByRole("button", { name: "블록 삭제" }).click();
|
|
||||||
|
|
||||||
// 하나의 블록만 남아야 하며, 첫 번째 블록이 남아 있어야 한다.
|
|
||||||
const remainingBlocks = canvas.getByTestId("editor-block");
|
|
||||||
await expect(remainingBlocks).toHaveCount(1);
|
|
||||||
await expect(remainingBlocks.nth(0)).toHaveAttribute("data-selected", "true");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Cmd/Ctrl+D 단축키로 선택된 블록을 복제할 수 있어야 한다", async ({ page }) => {
|
|
||||||
await page.goto("/editor");
|
|
||||||
|
|
||||||
const canvas = page.getByTestId("editor-canvas");
|
|
||||||
|
|
||||||
// 텍스트 블록을 하나 추가한다.
|
|
||||||
await page.getByRole("button", { name: "텍스트 블록 추가" }).click();
|
|
||||||
|
|
||||||
let blocks = canvas.getByTestId("editor-block");
|
|
||||||
await expect(blocks).toHaveCount(1);
|
|
||||||
|
|
||||||
// 블록의 텍스트를 식별 가능한 값으로 바꾼다.
|
|
||||||
await blocks.nth(0).click();
|
|
||||||
const sidebarEditor = page.getByRole("textbox", { name: "선택한 텍스트 블록 내용" });
|
|
||||||
await sidebarEditor.fill("복제 대상 블록");
|
|
||||||
|
|
||||||
// Cmd/Ctrl + D 로 복제한다.
|
|
||||||
await page.keyboard.press("Meta+D");
|
|
||||||
|
|
||||||
// 블록이 두 개가 되어야 한다.
|
|
||||||
blocks = canvas.getByTestId("editor-block");
|
|
||||||
await expect(blocks).toHaveCount(2);
|
|
||||||
|
|
||||||
// 두 블록 모두 동일한 텍스트를 가지고 있어야 한다.
|
|
||||||
await expect(blocks.nth(0)).toContainText("복제 대상 블록");
|
|
||||||
await expect(blocks.nth(1)).toContainText("복제 대상 블록");
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -75,35 +75,3 @@ test("에디터에서 CTA 템플릿을 추가하면 프리뷰에서 CTA 텍스
|
|||||||
await expect(page.getByText("지금 바로 행동을 유도하는 CTA 텍스트를 입력하세요.")).toBeVisible();
|
await expect(page.getByText("지금 바로 행동을 유도하는 CTA 텍스트를 입력하세요.")).toBeVisible();
|
||||||
await expect(page.getByText("CTA 버튼")).toBeVisible();
|
await expect(page.getByText("CTA 버튼")).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("모바일 뷰에서도 프리뷰 페이지가 깨지지 않고 주요 템플릿 컨텐츠를 보여줘야 한다", async ({ page }) => {
|
|
||||||
// 에디터에서 여러 템플릿을 추가한다.
|
|
||||||
await page.goto("/editor");
|
|
||||||
|
|
||||||
await page.getByRole("button", { name: "Hero 템플릿 추가" }).click();
|
|
||||||
await page.getByRole("button", { name: "Features 템플릿 추가" }).click();
|
|
||||||
await page.getByRole("button", { name: "Pricing 템플릿 추가" }).click();
|
|
||||||
await page.getByRole("button", { name: "Testimonials 템플릿 추가" }).click();
|
|
||||||
|
|
||||||
// 모바일 뷰포트로 전환한다.
|
|
||||||
await page.setViewportSize({ width: 390, height: 844 });
|
|
||||||
|
|
||||||
// 프리뷰로 이동한다.
|
|
||||||
await page.getByRole("link", { name: "프리뷰 열기" }).click();
|
|
||||||
|
|
||||||
// 프리뷰 헤더와 주요 템플릿 텍스트들이 모두 보여야 한다.
|
|
||||||
await expect(page.getByRole("heading", { name: "Page Preview" })).toBeVisible();
|
|
||||||
|
|
||||||
// Hero 헤드라인
|
|
||||||
await expect(page.getByText("Hero 제목을 여기에 입력하세요")).toBeVisible();
|
|
||||||
|
|
||||||
// Features 제목 일부
|
|
||||||
await expect(page.getByText("Feature 1 제목")).toBeVisible();
|
|
||||||
|
|
||||||
// Pricing 플랜 이름/가격 일부
|
|
||||||
await expect(page.getByText("Basic")).toBeVisible();
|
|
||||||
await expect(page.getByText("₩9,900/월")).toBeVisible();
|
|
||||||
|
|
||||||
// Testimonials 본문 일부
|
|
||||||
await expect(page.getByText("이 서비스 덕분에 랜딩 페이지 제작 시간이 크게 줄었습니다.")).toBeVisible();
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -217,90 +217,6 @@ describe("editorStore", () => {
|
|||||||
expect(selectedBlockId).toBe(blocks[blocks.length - 1].id);
|
expect(selectedBlockId).toBe(blocks[blocks.length - 1].id);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Blog 템플릿 섹션을 추가하면 3개의 포스트 카드(제목/요약)가 생성되어야 한다", () => {
|
|
||||||
const store = createEditorStore();
|
|
||||||
|
|
||||||
store.getState().addBlogTemplateSection();
|
|
||||||
|
|
||||||
const { blocks, selectedBlockId } = store.getState();
|
|
||||||
|
|
||||||
const sectionBlocks = blocks.filter((b) => b.type === "section");
|
|
||||||
expect(sectionBlocks).toHaveLength(1);
|
|
||||||
|
|
||||||
const section = sectionBlocks[0] as any;
|
|
||||||
const columns = (section.props as any).columns;
|
|
||||||
expect(Array.isArray(columns)).toBe(true);
|
|
||||||
expect(columns.length).toBe(3);
|
|
||||||
|
|
||||||
const textBlocks = blocks.filter((b) => b.type === "text") as any[];
|
|
||||||
|
|
||||||
// 3개의 포스트 카드에 대해 각 컬럼에 최소 2개 텍스트(제목 + 요약)를 가정한다.
|
|
||||||
expect(textBlocks.length).toBeGreaterThanOrEqual(6);
|
|
||||||
|
|
||||||
textBlocks.forEach((tb) => {
|
|
||||||
expect(tb.sectionId).toBe(section.id);
|
|
||||||
expect(columns.some((col: any) => col.id === tb.columnId)).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(selectedBlockId).toBe(blocks[blocks.length - 1].id);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Team 템플릿 섹션을 추가하면 3명의 팀 카드(이름/역할/소개)가 생성되어야 한다", () => {
|
|
||||||
const store = createEditorStore();
|
|
||||||
|
|
||||||
store.getState().addTeamTemplateSection();
|
|
||||||
|
|
||||||
const { blocks, selectedBlockId } = store.getState();
|
|
||||||
|
|
||||||
const sectionBlocks = blocks.filter((b) => b.type === "section");
|
|
||||||
expect(sectionBlocks).toHaveLength(1);
|
|
||||||
|
|
||||||
const section = sectionBlocks[0] as any;
|
|
||||||
const columns = (section.props as any).columns;
|
|
||||||
expect(Array.isArray(columns)).toBe(true);
|
|
||||||
expect(columns.length).toBe(3);
|
|
||||||
|
|
||||||
const textBlocks = blocks.filter((b) => b.type === "text") as any[];
|
|
||||||
|
|
||||||
// 3명의 팀원 카드에 대해 각 컬럼에 최소 3개 텍스트(이름/역할/소개)를 가정한다.
|
|
||||||
expect(textBlocks.length).toBeGreaterThanOrEqual(9);
|
|
||||||
|
|
||||||
textBlocks.forEach((tb) => {
|
|
||||||
expect(tb.sectionId).toBe(section.id);
|
|
||||||
expect(columns.some((col: any) => col.id === tb.columnId)).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(selectedBlockId).toBe(blocks[blocks.length - 1].id);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Footer 템플릿 섹션을 추가하면 링크/카피라이트 텍스트가 포함된 섹션이 생성되어야 한다", () => {
|
|
||||||
const store = createEditorStore();
|
|
||||||
|
|
||||||
store.getState().addFooterTemplateSection();
|
|
||||||
|
|
||||||
const { blocks, selectedBlockId } = store.getState();
|
|
||||||
|
|
||||||
const sectionBlocks = blocks.filter((b) => b.type === "section");
|
|
||||||
expect(sectionBlocks).toHaveLength(1);
|
|
||||||
|
|
||||||
const section = sectionBlocks[0] as any;
|
|
||||||
const columns = (section.props as any).columns;
|
|
||||||
expect(Array.isArray(columns)).toBe(true);
|
|
||||||
expect(columns.length).toBeGreaterThanOrEqual(1);
|
|
||||||
|
|
||||||
const firstColumnId = columns[0].id;
|
|
||||||
|
|
||||||
const textBlocks = blocks.filter((b) => b.type === "text") as any[];
|
|
||||||
expect(textBlocks.length).toBeGreaterThanOrEqual(2);
|
|
||||||
|
|
||||||
textBlocks.forEach((tb) => {
|
|
||||||
expect(tb.sectionId).toBe(section.id);
|
|
||||||
expect(tb.columnId).toBe(firstColumnId);
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(selectedBlockId).toBe(blocks[blocks.length - 1].id);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Features 템플릿 섹션을 추가하면 3컬럼 섹션과 각 컬럼의 제목/설명 텍스트가 생성되어야 한다", () => {
|
it("Features 템플릿 섹션을 추가하면 3컬럼 섹션과 각 컬럼의 제목/설명 텍스트가 생성되어야 한다", () => {
|
||||||
const store = createEditorStore();
|
const store = createEditorStore();
|
||||||
|
|
||||||
@@ -367,92 +283,6 @@ describe("editorStore", () => {
|
|||||||
expect(selectedBlockId).toBe(blocks[blocks.length - 1].id);
|
expect(selectedBlockId).toBe(blocks[blocks.length - 1].id);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("FAQ 템플릿 섹션을 추가하면 질문/답변 쌍이 포함된 섹션이 생성되어야 한다", () => {
|
|
||||||
const store = createEditorStore();
|
|
||||||
|
|
||||||
store.getState().addFaqTemplateSection();
|
|
||||||
|
|
||||||
const { blocks, selectedBlockId } = store.getState();
|
|
||||||
|
|
||||||
const sectionBlocks = blocks.filter((b) => b.type === "section");
|
|
||||||
expect(sectionBlocks).toHaveLength(1);
|
|
||||||
|
|
||||||
const section = sectionBlocks[0] as any;
|
|
||||||
const columns = (section.props as any).columns;
|
|
||||||
expect(Array.isArray(columns)).toBe(true);
|
|
||||||
expect(columns.length).toBeGreaterThanOrEqual(1);
|
|
||||||
|
|
||||||
const firstColumnId = columns[0].id;
|
|
||||||
|
|
||||||
const textBlocks = blocks.filter((b) => b.type === "text") as any[];
|
|
||||||
|
|
||||||
// 최소 3개의 FAQ 항목(질문+답변 쌍)을 가정한다.
|
|
||||||
expect(textBlocks.length).toBeGreaterThanOrEqual(6);
|
|
||||||
|
|
||||||
textBlocks.forEach((tb) => {
|
|
||||||
expect(tb.sectionId).toBe(section.id);
|
|
||||||
expect(tb.columnId).toBe(firstColumnId);
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(selectedBlockId).toBe(blocks[blocks.length - 1].id);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Pricing 템플릿 섹션을 추가하면 요금제 카드(플랜 이름/가격/설명)가 3개 생성되어야 한다", () => {
|
|
||||||
const store = createEditorStore();
|
|
||||||
|
|
||||||
store.getState().addPricingTemplateSection();
|
|
||||||
|
|
||||||
const { blocks, selectedBlockId } = store.getState();
|
|
||||||
|
|
||||||
const sectionBlocks = blocks.filter((b) => b.type === "section");
|
|
||||||
expect(sectionBlocks).toHaveLength(1);
|
|
||||||
|
|
||||||
const section = sectionBlocks[0] as any;
|
|
||||||
const columns = (section.props as any).columns;
|
|
||||||
expect(Array.isArray(columns)).toBe(true);
|
|
||||||
expect(columns.length).toBe(3);
|
|
||||||
|
|
||||||
const textBlocks = blocks.filter((b) => b.type === "text") as any[];
|
|
||||||
|
|
||||||
// 3개의 요금제에 대해 각 컬럼에 최소 2개 텍스트(플랜 이름 + 가격/설명)를 가정한다.
|
|
||||||
expect(textBlocks.length).toBeGreaterThanOrEqual(6);
|
|
||||||
|
|
||||||
textBlocks.forEach((tb) => {
|
|
||||||
expect(tb.sectionId).toBe(section.id);
|
|
||||||
expect(columns.some((col: any) => col.id === tb.columnId)).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(selectedBlockId).toBe(blocks[blocks.length - 1].id);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Testimonials 템플릿 섹션을 추가하면 후기(본문/작성자)가 3개 생성되어야 한다", () => {
|
|
||||||
const store = createEditorStore();
|
|
||||||
|
|
||||||
store.getState().addTestimonialsTemplateSection();
|
|
||||||
|
|
||||||
const { blocks, selectedBlockId } = store.getState();
|
|
||||||
|
|
||||||
const sectionBlocks = blocks.filter((b) => b.type === "section");
|
|
||||||
expect(sectionBlocks).toHaveLength(1);
|
|
||||||
|
|
||||||
const section = sectionBlocks[0] as any;
|
|
||||||
const columns = (section.props as any).columns;
|
|
||||||
expect(Array.isArray(columns)).toBe(true);
|
|
||||||
expect(columns.length).toBe(3);
|
|
||||||
|
|
||||||
const textBlocks = blocks.filter((b) => b.type === "text") as any[];
|
|
||||||
|
|
||||||
// 3개의 후기 카드에 대해 각 컬럼에 최소 2개 텍스트(본문 + 작성자)를 가정한다.
|
|
||||||
expect(textBlocks.length).toBeGreaterThanOrEqual(6);
|
|
||||||
|
|
||||||
textBlocks.forEach((tb) => {
|
|
||||||
expect(tb.sectionId).toBe(section.id);
|
|
||||||
expect(columns.some((col: any) => col.id === tb.columnId)).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(selectedBlockId).toBe(blocks[blocks.length - 1].id);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("undo 호출 시 마지막 변경 이전의 블록 상태로 되돌려야 한다", () => {
|
it("undo 호출 시 마지막 변경 이전의 블록 상태로 되돌려야 한다", () => {
|
||||||
const store = createEditorStore();
|
const store = createEditorStore();
|
||||||
|
|
||||||
@@ -494,61 +324,4 @@ describe("editorStore", () => {
|
|||||||
({ blocks } = store.getState());
|
({ blocks } = store.getState());
|
||||||
expect(blocks).toHaveLength(2);
|
expect(blocks).toHaveLength(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("removeBlock 호출 시 해당 블록이 삭제되고 선택 상태가 적절히 변경되어야 한다", () => {
|
|
||||||
const store = createEditorStore();
|
|
||||||
|
|
||||||
// 텍스트 블록 두 개를 추가한다.
|
|
||||||
store.getState().addTextBlock();
|
|
||||||
store.getState().addTextBlock();
|
|
||||||
|
|
||||||
let { blocks, selectedBlockId } = store.getState();
|
|
||||||
expect(blocks).toHaveLength(2);
|
|
||||||
|
|
||||||
const firstId = blocks[0].id;
|
|
||||||
const secondId = blocks[1].id;
|
|
||||||
|
|
||||||
// 두 번째 블록을 선택한 상태에서 삭제한다.
|
|
||||||
store.getState().selectBlock(secondId);
|
|
||||||
store.getState().removeBlock(secondId);
|
|
||||||
|
|
||||||
({ blocks, selectedBlockId } = store.getState());
|
|
||||||
|
|
||||||
// 두 번째 블록만 삭제되고 첫 번째 블록은 남아 있어야 한다.
|
|
||||||
expect(blocks).toHaveLength(1);
|
|
||||||
expect(blocks[0].id).toBe(firstId);
|
|
||||||
expect(selectedBlockId).toBe(firstId);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("duplicateBlock 호출 시 같은 내용의 블록이 같은 위치 정보로 복제되어야 한다", () => {
|
|
||||||
const store = createEditorStore();
|
|
||||||
|
|
||||||
// 섹션 + 텍스트 블록을 하나 만든다.
|
|
||||||
store.getState().addSectionBlock();
|
|
||||||
const { blocks: afterSection } = store.getState();
|
|
||||||
const sectionBlock = afterSection[0] as any;
|
|
||||||
|
|
||||||
store.getState().selectBlock(sectionBlock.id);
|
|
||||||
store.getState().addTextBlock();
|
|
||||||
|
|
||||||
let { blocks } = store.getState();
|
|
||||||
const original = blocks.find((b) => b.type === "text") as any;
|
|
||||||
|
|
||||||
expect(original).toBeTruthy();
|
|
||||||
|
|
||||||
// duplicateBlock 으로 복제한다.
|
|
||||||
store.getState().duplicateBlock(original.id);
|
|
||||||
|
|
||||||
({ blocks } = store.getState());
|
|
||||||
const textBlocks = blocks.filter((b) => b.type === "text") as any[];
|
|
||||||
|
|
||||||
// 텍스트 블록이 두 개가 되어야 한다.
|
|
||||||
expect(textBlocks).toHaveLength(2);
|
|
||||||
|
|
||||||
const [t1, t2] = textBlocks;
|
|
||||||
expect(t1.id).not.toBe(t2.id);
|
|
||||||
expect(t1.props).toEqual(t2.props);
|
|
||||||
expect(t2.sectionId).toBe(t1.sectionId);
|
|
||||||
expect(t2.columnId).toBe(t1.columnId);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user