From 86f28a12994cdf73833a038eb042e857f5af8946 Mon Sep 17 00:00:00 2001 From: Jaybe Date: Wed, 10 Dec 2025 16:19:30 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9E=90=EB=8F=99=EC=A0=80=EC=9E=A5=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/editor/page.tsx | 2 + tests/unit/EditorServerAutosave.spec.tsx | 49 +++++------------------- 2 files changed, 12 insertions(+), 39 deletions(-) diff --git a/src/app/editor/page.tsx b/src/app/editor/page.tsx index bce70b4..9b05dca 100644 --- a/src/app/editor/page.tsx +++ b/src/app/editor/page.tsx @@ -893,6 +893,8 @@ function EditorPageInner() { if (!authUserId) return; if (typeof window === "undefined") return; + return; + const slugRaw = projectConfig?.slug; const slug = typeof slugRaw === "string" ? slugRaw.trim() : ""; if (!slug || slug === "my-landing") return; diff --git a/tests/unit/EditorServerAutosave.spec.tsx b/tests/unit/EditorServerAutosave.spec.tsx index 90747de..4ccd70a 100644 --- a/tests/unit/EditorServerAutosave.spec.tsx +++ b/tests/unit/EditorServerAutosave.spec.tsx @@ -107,8 +107,8 @@ vi.mock("next/navigation", () => { }; }); -describe("EditorPage - 서버 자동 저장", () => { - it("로그인된 사용자가 새 페이지를 편집하면 자동 생성된 slug 로 /api/projects 에 주기적으로 저장해야 한다", async () => { +describe("EditorPage - 서버 자동 저장 비활성화", () => { + it("로그인된 사용자가 새 페이지를 편집하더라도 서버(/api/projects) 자동저장을 호출하지 않아야 한다", async () => { const fetchMock = vi.fn().mockImplementation((input: any, init?: any) => { const url = typeof input === "string" ? input : input.url; const method = init?.method ?? "GET"; @@ -152,28 +152,14 @@ describe("EditorPage - 서버 자동 저장", () => { ).toBe(true); }); - await waitFor(() => { - expect( - fetchMock.mock.calls.some( - ([url, options]: any[]) => url === "/api/projects" && (options?.method ?? "GET") === "POST", - ), - ).toBe(true); - }); - - const projectCall = fetchMock.mock.calls.find( + const projectCalls = fetchMock.mock.calls.filter( ([url, options]: any[]) => url === "/api/projects" && (options?.method ?? "GET") === "POST", - ) as any; + ); - const [, options] = projectCall; - const body = JSON.parse((options.body as string) ?? "{}"); - - expect(typeof body.slug).toBe("string"); - expect(body.slug).not.toBe("my-landing"); - expect(body.slug.startsWith("page-")).toBe(false); - expect(mockState.projectConfig.slug).toBe(body.slug); + expect(projectCalls.length).toBe(0); }); - it("authUserId 가 없으면 /api/projects 자동 저장을 호출하지 않아야 한다", async () => { + it("authUserId 가 없을 때는 물론, 서버 자동저장은 어떤 경우에도 /api/projects 를 호출하지 않아야 한다", async () => { const fetchMock = vi.fn().mockImplementation((input: any, init?: any) => { const url = typeof input === "string" ? input : input.url; const method = init?.method ?? "GET"; @@ -204,7 +190,7 @@ describe("EditorPage - 서버 자동 저장", () => { expect(projectCalls.length).toBe(0); }); - it("slug 쿼리 파라미터로 기존 프로젝트를 열었을 때는 해당 slug 로 서버 자동 저장을 해야 한다", async () => { + it("slug 쿼리 파라미터로 기존 프로젝트를 열었을 때도 서버 자동저장을 호출하지 않아야 한다", async () => { searchParamsSlug = "existing-slug"; mockState.projectConfig.slug = "my-landing" as any; @@ -268,25 +254,10 @@ describe("EditorPage - 서버 자동 저장", () => { ).toBe(true); }); - await waitFor(() => { - expect( - fetchMock.mock.calls.some( - ([url, options]: any[]) => - url === "/api/projects" && (options?.method ?? "GET") === "POST", - ), - ).toBe(true); - }); - - const projectCall = fetchMock.mock.calls.find( + const projectCalls = fetchMock.mock.calls.filter( ([url, options]: any[]) => url === "/api/projects" && (options?.method ?? "GET") === "POST", - ) as any; + ); - expect(projectCall).toBeTruthy(); - - const [, options] = projectCall; - const body = JSON.parse((options.body as string) ?? "{}"); - - expect(body.slug).toBe("existing-slug"); - expect(mockState.projectConfig.slug).toBe("existing-slug"); + expect(projectCalls.length).toBe(0); }); });