Compare commits

..

6 Commits

Author SHA1 Message Date
jaybe bd6be2fb97 CI 테스트: Gitea Actions PR/자동머지 확인
CI / test (push) Failing after 5m56s
CI / pr_and_merge (push) Has been skipped
2025-11-18 14:09:31 +09:00
jaybe cf04c6e56c CI 생성
CI / test (push) Failing after 9m0s
CI / pr_and_merge (push) Has been skipped
2025-11-18 14:08:42 +09:00
jaybe 65d613a5bb Link 오류 수정 2025-11-18 13:53:20 +09:00
jaybe a8aed0aa41 Merge branch 'feature/builder-5-ux' 2025-11-18 13:50:30 +09:00
jaybe f333e212b4 Merge pull request '프리뷰 모드: 에디터 크롬 없이 페이지 미리보기 구현' (#3) from feature/builder-4-preview into main
Reviewed-on: #3
2025-11-18 04:33:46 +00:00
jaybe b781ad1a2f 프리뷰 모드: 에디터 크롬 없이 페이지 미리보기 구현 2025-11-18 13:29:51 +09:00
5 changed files with 318 additions and 2 deletions
+105
View File
@@ -0,0 +1,105 @@
name: CI
on:
push:
branches:
- main
- feature/**
pull_request:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install dependencies
run: |
npm ci
- name: Run unit tests
run: |
npm test
- name: Install Playwright browsers
run: |
npx playwright install --with-deps
- name: Run Playwright E2E tests
run: |
npx playwright test
pr_and_merge:
needs: test
# feature/* 브랜치에 push 되었을 때만 실행한다.
if: ${{ startsWith(github.ref, 'refs/heads/feature/') }}
runs-on: ubuntu-latest
steps:
- name: Create or update PR and try auto-merge
env:
CI_BASE_URL: ${{ secrets.CI_BASE_URL }}
CI_TOKEN: ${{ secrets.CI_TOKEN }}
CI_OWNER: ${{ secrets.CI_OWNER }}
CI_REPO: ${{ secrets.CI_REPO }}
BRANCH_REF: ${{ github.ref }}
BRANCH_NAME: ${{ github.ref_name }}
run: |
set -e
if [ -z "$CI_BASE_URL" ] || [ -z "$CI_TOKEN" ] || [ -z "$CI_OWNER" ] || [ -z "$CI_REPO" ]; then
echo "CI_* 시크릿이 설정되지 않아 PR/자동 머지를 건너뜁니다." >&2
exit 0
fi
echo "현재 브랜치: $BRANCH_NAME ($BRANCH_REF)"
# 1) PR 생성 시도 (이미 존재하면 4xx를 허용)
create_pr_payload=$(jq -n \
--arg title "CI: $BRANCH_NAME" \
--arg head "$BRANCH_NAME" \
--arg base "main" \
'{title: $title, head: $head, base: $base}')
echo "PR 생성 시도..."
curl -sS -X POST \
-H "Content-Type: application/json" \
-H "Authorization: token $CI_TOKEN" \
"$CI_BASE_URL/api/v1/repos/$CI_OWNER/$CI_REPO/pulls" \
-d "$create_pr_payload" || true
# 2) 열린 PR 목록에서 해당 브랜치의 PR 번호를 찾는다.
echo "열린 PR 목록 조회..."
pr_list=$(curl -sS \
-H "Authorization: token $CI_TOKEN" \
"$CI_BASE_URL/api/v1/repos/$CI_OWNER/$CI_REPO/pulls?state=open")
pr_number=$(echo "$pr_list" | jq ".[] | select(.head.ref == \"$BRANCH_NAME\") | .number" | head -n 1)
if [ -z "$pr_number" ]; then
echo "브랜치 $BRANCH_NAME 에 대한 열린 PR을 찾지 못했습니다. 종료합니다."
exit 0
fi
echo "브랜치 $BRANCH_NAME 에 대한 PR #$pr_number 발견"
# 3) main 대상으로 자동 머지 시도
merge_payload=$(jq -n '{Do: "merge"}')
echo "PR #$pr_number 자동 머지 시도..."
curl -sS -X POST \
-H "Content-Type: application/json" \
-H "Authorization: token $CI_TOKEN" \
"$CI_BASE_URL/api/v1/repos/$CI_OWNER/$CI_REPO/pulls/$pr_number/merge" \
-d "$merge_payload" || true
# CI 테스트용 더미 주석
+9
View File
@@ -2,6 +2,7 @@
import type { CSSProperties, ReactNode } from "react"; import type { CSSProperties, ReactNode } from "react";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import Link from "next/link";
import { import {
DndContext, DndContext,
PointerSensor, PointerSensor,
@@ -283,8 +284,16 @@ export default function EditorPage() {
return ( return (
<main className="min-h-screen flex flex-col bg-slate-950 text-slate-50"> <main className="min-h-screen flex flex-col bg-slate-950 text-slate-50">
<header className="border-b border-slate-800 px-6 py-4 flex items-center justify-between"> <header className="border-b border-slate-800 px-6 py-4 flex items-center justify-between">
<div className="flex items-baseline gap-3">
<h1 className="text-xl font-semibold">Page Editor</h1> <h1 className="text-xl font-semibold">Page Editor</h1>
<p className="text-xs text-slate-400"> MVP용 </p> <p className="text-xs text-slate-400"> MVP용 </p>
</div>
<Link
href="/preview"
className="inline-flex items-center rounded border border-slate-700 bg-slate-900 px-3 py-1 text-xs text-slate-100 hover:bg-slate-800"
>
</Link>
</header> </header>
<section className="flex flex-1 overflow-hidden"> <section className="flex flex-1 overflow-hidden">
<aside className="w-60 border-r border-slate-800 p-4 text-sm space-y-3"> <aside className="w-60 border-r border-slate-800 p-4 text-sm space-y-3">
+19
View File
@@ -0,0 +1,19 @@
"use client";
import { useEditorStore } from "@/features/editor/state/editorStore";
import { PublicPageRenderer } from "@/features/editor/components/PublicPageRenderer";
export default function PreviewPage() {
const blocks = useEditorStore((state) => state.blocks);
return (
<main className="min-h-screen flex flex-col bg-slate-950 text-slate-50">
<header className="border-b border-slate-800 px-6 py-4 flex items-center justify-between">
<h1 className="text-xl font-semibold">Page Preview</h1>
<p className="text-xs text-slate-400"> </p>
</header>
{/* 에디터 크롬 없이 순수 페이지 형태로 블록들을 렌더링 */}
<PublicPageRenderer blocks={blocks} />
</main>
);
}
@@ -0,0 +1,106 @@
"use client";
import type { Block, TextBlockProps, ButtonBlockProps, ImageBlockProps, SectionBlockProps } from "@/features/editor/state/editorStore";
// 에디터 크롬 없이 실제 랜딩 페이지처럼 블록들을 렌더링하는 컴포넌트
interface PublicPageRendererProps {
blocks: Block[];
}
export function PublicPageRenderer({ blocks }: PublicPageRendererProps) {
const sectionBlocks = blocks.filter((b) => b.type === "section");
const rootBlocks = blocks.filter((b) => !b.sectionId && b.type !== "section");
const renderBlock = (block: Block) => {
if (block.type === "text") {
const props = block.props as TextBlockProps;
const alignClass =
props.align === "center" ? "text-center" : props.align === "right" ? "text-right" : "text-left";
const sizeClass = props.size === "sm" ? "text-sm" : props.size === "lg" ? "text-2xl" : "text-base";
return (
<p key={block.id} className={`${alignClass} ${sizeClass} text-slate-50 leading-relaxed`}>
{props.text}
</p>
);
}
if (block.type === "button") {
const props = block.props as ButtonBlockProps;
return (
<a
key={block.id}
href={props.href}
className="inline-flex items-center justify-center rounded-md bg-sky-600 px-4 py-2 text-sm font-medium text-white hover:bg-sky-500 transition-colors"
>
{props.label}
</a>
);
}
if (block.type === "image") {
const props = block.props as ImageBlockProps;
return (
<div key={block.id} className="w-full flex justify-center">
{/* eslint-disable-next-line @next/next/no-img-element */}
<img src={props.src || ""} alt={props.alt} className="max-w-full h-auto object-contain" />
</div>
);
}
return null;
};
const renderSection = (section: Block) => {
const props = section.props as SectionBlockProps;
const bgClass =
props.background === "muted" ? "bg-slate-900" : props.background === "primary" ? "bg-sky-900" : "bg-slate-950";
const pyClass = props.paddingY === "sm" ? "py-8" : props.paddingY === "lg" ? "py-20" : "py-12";
const columns = props.columns && props.columns.length > 0 ? props.columns : [{ id: `${section.id}_col`, span: 12 }];
return (
<section key={section.id} className={`${bgClass} ${pyClass}`}>
<div className="mx-auto max-w-5xl px-4">
<div className="flex gap-8">
{columns.map((col) => {
const basis = `${(col.span / 12) * 100}%`;
const columnBlocks = blocks.filter((b) => b.sectionId === section.id && b.columnId === col.id);
return (
<div key={col.id} className="flex flex-col gap-4" style={{ flexBasis: basis }}>
{columnBlocks.map((b) => (
<div key={b.id}>{renderBlock(b)}</div>
))}
</div>
);
})}
</div>
</div>
</section>
);
};
return (
<div className="flex-1 flex flex-col bg-slate-950 text-slate-50">
{/* 루트 텍스트/버튼/이미지 블록들이 있다면 페이지 상단에 노출 */}
{rootBlocks.length > 0 && (
<section className="bg-slate-950 py-12">
<div className="mx-auto max-w-3xl px-4 flex flex-col gap-4">
{rootBlocks.map((b) => (
<div key={b.id}>{renderBlock(b)}</div>
))}
</div>
</section>
)}
{/* 섹션 블록들 */}
{sectionBlocks.map((section) => renderSection(section))}
</div>
);
}
+77
View File
@@ -0,0 +1,77 @@
import { test, expect } from "@playwright/test";
// 프리뷰/뷰 모드 TDD: 먼저 실패하는 E2E부터 작성한다.
test("/preview 페이지는 에디터 크롬 없이 컨텐츠만 보여야 한다", async ({ page }) => {
// 프리뷰 페이지로 이동한다.
await page.goto("/preview");
// 프리뷰 전용 헤더가 있어야 한다.
await expect(page.getByRole("heading", { name: "Page Preview" })).toBeVisible();
// 에디터 좌측 패널용 버튼들은 나타나지 않아야 한다.
await expect(page.getByRole("button", { name: "텍스트 블록 추가" })).toHaveCount(0);
await expect(page.getByRole("button", { name: "Hero 템플릿 추가" })).toHaveCount(0);
});
test("에디터에서 Hero 템플릿을 추가하면 프리뷰에서 동일한 Hero 콘텐츠가 보여야 한다", async ({ page }) => {
// 에디터에서 Hero 템플릿을 추가한다.
await page.goto("/editor");
await page.getByRole("button", { name: "Hero 템플릿 추가" }).click();
// 헤드라인과 CTA 버튼이 에디터에서 생성되었는지 한 번 확인한다.
const editorCanvas = page.getByTestId("editor-canvas");
await expect(editorCanvas.getByText("Hero 제목을 여기에 입력하세요")).toBeVisible();
await expect(editorCanvas.getByRole("button", { name: "지금 시작하기" })).toBeVisible();
// 헤더의 프리뷰 열기 링크를 통해 /preview 로 이동한다 (클라이언트 내 내비게이션 유지).
await page.getByRole("link", { name: "프리뷰 열기" }).click();
// 프리뷰 헤더가 보여야 한다.
await expect(page.getByRole("heading", { name: "Page Preview" })).toBeVisible();
// 프리뷰에서도 Hero 헤드라인과 CTA 버튼이 그대로 보여야 한다.
await expect(page.getByText("Hero 제목을 여기에 입력하세요")).toBeVisible();
// 프리뷰에서는 CTA를 실제 링크(<a>)로 렌더링하므로 텍스트 기준으로만 검증한다.
await expect(page.getByText("지금 시작하기")).toBeVisible();
// 프리뷰 화면에는 에디터용 "텍스트 블록 추가" 버튼이 없어야 한다.
await expect(page.getByRole("button", { name: "텍스트 블록 추가" })).toHaveCount(0);
});
test("에디터에서 Features 템플릿을 추가하면 프리뷰에서 3개의 Feature 섹션이 보여야 한다", async ({ page }) => {
await page.goto("/editor");
await page.getByRole("button", { name: "Features 템플릿 추가" }).click();
const editorCanvas = page.getByTestId("editor-canvas");
await expect(editorCanvas.getByText("Feature 1 제목")).toBeVisible();
await expect(editorCanvas.getByText("Feature 2 제목")).toBeVisible();
await expect(editorCanvas.getByText("Feature 3 제목")).toBeVisible();
await page.getByRole("link", { name: "프리뷰 열기" }).click();
await expect(page.getByRole("heading", { name: "Page Preview" })).toBeVisible();
await expect(page.getByText("Feature 1 제목")).toBeVisible();
await expect(page.getByText("Feature 2 제목")).toBeVisible();
await expect(page.getByText("Feature 3 제목")).toBeVisible();
});
test("에디터에서 CTA 템플릿을 추가하면 프리뷰에서 CTA 텍스트와 버튼이 보여야 한다", async ({ page }) => {
await page.goto("/editor");
await page.getByRole("button", { name: "CTA 템플릿 추가" }).click();
const editorCanvas = page.getByTestId("editor-canvas");
await expect(editorCanvas.getByText("지금 바로 행동을 유도하는 CTA 텍스트를 입력하세요.")).toBeVisible();
await expect(editorCanvas.getByRole("button", { name: "CTA 버튼" })).toBeVisible();
await page.getByRole("link", { name: "프리뷰 열기" }).click();
await expect(page.getByRole("heading", { name: "Page Preview" })).toBeVisible();
await expect(page.getByText("지금 바로 행동을 유도하는 CTA 텍스트를 입력하세요.")).toBeVisible();
await expect(page.getByText("CTA 버튼")).toBeVisible();
});