에디터 MVP 골격 및 프로젝트 저장/로드 기능 구현

This commit is contained in:
2025-11-18 06:04:39 +09:00
commit 4b00e9a3f9
26 changed files with 11179 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
import { describe, it, expect } from "vitest";
import { createEditorStore } from "@/features/editor/state/editorStore";
// 에디터 상태 스토어에 대한 첫 TDD: 텍스트 블록 추가
describe("editorStore", () => {
it("addTextBlock 호출 시 텍스트 블록이 추가되고 선택되어야 한다", () => {
const store = createEditorStore();
store.getState().addTextBlock();
const { blocks, selectedBlockId } = store.getState();
expect(blocks).toHaveLength(1);
expect(blocks[0].type).toBe("text");
expect(blocks[0].props.text).toBe("새 텍스트");
expect(selectedBlockId).toBe(blocks[0].id);
});
it("reorderBlocks 호출 시 블록 배열 순서가 변경되어야 한다", () => {
const store = createEditorStore();
// 블록 세 개를 추가하고 각기 다른 텍스트로 수정한다.
store.getState().addTextBlock();
store.getState().addTextBlock();
store.getState().addTextBlock();
let { blocks } = store.getState();
store.getState().updateBlock(blocks[0].id, { text: "블록 A" });
store.getState().updateBlock(blocks[1].id, { text: "블록 B" });
store.getState().updateBlock(blocks[2].id, { text: "블록 C" });
const [aId, bId, cId] = blocks.map((b) => b.id);
// B를 맨 앞으로 이동시키는 순서 변경을 수행한다.
store.getState().reorderBlocks(bId, aId);
blocks = store.getState().blocks;
expect(blocks.map((b) => b.id)).toEqual([bId, aId, cId]);
expect(blocks.map((b) => b.props.text)).toEqual(["블록 B", "블록 A", "블록 C"]);
});
});