CI: feature/i18n-browser-locale #34

Merged
jaybe merged 3 commits from feature/i18n-browser-locale into main 2025-12-10 08:11:49 +00:00
2 changed files with 12 additions and 39 deletions
Showing only changes of commit 86f28a1299 - Show all commits
+2
View File
@@ -893,6 +893,8 @@ function EditorPageInner() {
if (!authUserId) return; if (!authUserId) return;
if (typeof window === "undefined") return; if (typeof window === "undefined") return;
return;
const slugRaw = projectConfig?.slug; const slugRaw = projectConfig?.slug;
const slug = typeof slugRaw === "string" ? slugRaw.trim() : ""; const slug = typeof slugRaw === "string" ? slugRaw.trim() : "";
if (!slug || slug === "my-landing") return; if (!slug || slug === "my-landing") return;
+10 -39
View File
@@ -107,8 +107,8 @@ vi.mock("next/navigation", () => {
}; };
}); });
describe("EditorPage - 서버 자동 저장", () => { describe("EditorPage - 서버 자동 저장 비활성화", () => {
it("로그인된 사용자가 새 페이지를 편집하면 자동 생성된 slug 로 /api/projects 에 주기적으로 저장해야 한다", async () => { it("로그인된 사용자가 새 페이지를 편집하더라도 서버(/api/projects) 자동저장을 호출하지 않아야 한다", async () => {
const fetchMock = vi.fn().mockImplementation((input: any, init?: any) => { const fetchMock = vi.fn().mockImplementation((input: any, init?: any) => {
const url = typeof input === "string" ? input : input.url; const url = typeof input === "string" ? input : input.url;
const method = init?.method ?? "GET"; const method = init?.method ?? "GET";
@@ -152,28 +152,14 @@ describe("EditorPage - 서버 자동 저장", () => {
).toBe(true); ).toBe(true);
}); });
await waitFor(() => { const projectCalls = fetchMock.mock.calls.filter(
expect(
fetchMock.mock.calls.some(
([url, options]: any[]) => url === "/api/projects" && (options?.method ?? "GET") === "POST",
),
).toBe(true);
});
const projectCall = fetchMock.mock.calls.find(
([url, options]: any[]) => url === "/api/projects" && (options?.method ?? "GET") === "POST", ([url, options]: any[]) => url === "/api/projects" && (options?.method ?? "GET") === "POST",
) as any; );
const [, options] = projectCall; expect(projectCalls.length).toBe(0);
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);
}); });
it("authUserId 가 없으면 /api/projects 자동 저장을 호출하지 않아야 한다", async () => { it("authUserId 가 없을 때는 물론, 서버 자동저장은 어떤 경우에도 /api/projects 호출하지 않아야 한다", async () => {
const fetchMock = vi.fn().mockImplementation((input: any, init?: any) => { const fetchMock = vi.fn().mockImplementation((input: any, init?: any) => {
const url = typeof input === "string" ? input : input.url; const url = typeof input === "string" ? input : input.url;
const method = init?.method ?? "GET"; const method = init?.method ?? "GET";
@@ -204,7 +190,7 @@ describe("EditorPage - 서버 자동 저장", () => {
expect(projectCalls.length).toBe(0); expect(projectCalls.length).toBe(0);
}); });
it("slug 쿼리 파라미터로 기존 프로젝트를 열었을 때는 해당 slug 로 서버 자동 저장을 야 한다", async () => { it("slug 쿼리 파라미터로 기존 프로젝트를 열었을 때 서버 자동저장을 호출하지 않아야 한다", async () => {
searchParamsSlug = "existing-slug"; searchParamsSlug = "existing-slug";
mockState.projectConfig.slug = "my-landing" as any; mockState.projectConfig.slug = "my-landing" as any;
@@ -268,25 +254,10 @@ describe("EditorPage - 서버 자동 저장", () => {
).toBe(true); ).toBe(true);
}); });
await waitFor(() => { const projectCalls = fetchMock.mock.calls.filter(
expect(
fetchMock.mock.calls.some(
([url, options]: any[]) =>
url === "/api/projects" && (options?.method ?? "GET") === "POST",
),
).toBe(true);
});
const projectCall = fetchMock.mock.calls.find(
([url, options]: any[]) => url === "/api/projects" && (options?.method ?? "GET") === "POST", ([url, options]: any[]) => url === "/api/projects" && (options?.method ?? "GET") === "POST",
) as any; );
expect(projectCall).toBeTruthy(); expect(projectCalls.length).toBe(0);
const [, options] = projectCall;
const body = JSON.parse((options.body as string) ?? "{}");
expect(body.slug).toBe("existing-slug");
expect(mockState.projectConfig.slug).toBe("existing-slug");
}); });
}); });