Files
CODE_ASSISTANT/2_frontend/src/routes.test.tsx
T
2026-09-16 17:22:14 +09:00

39 lines
1.7 KiB
TypeScript

// 구조 회귀 방지: 챗봇(snap)·스니펫이 공통 래퍼 PaletteShell 아래 함께 있고,
// /snippet 은 SnapLayout(스냅 헤더+Ctrl+N) 밖(=Raycast 풀윈도우)인지 route 설정만 검사(렌더 없음).
import { isValidElement } from "react"
import { describe, expect, it } from "vitest"
import { routes } from "./routes"
import ProtectedRoute from "@/shared/components/ProtectedRoute"
import { SnapLayout } from "@/features/snap/components/SnapLayout"
import { PaletteShell } from "@/shared/components/PaletteShell"
import { PATHS } from "@/config/routes"
describe("routes", () => {
it("snap·snippet 은 PaletteShell(공통 래퍼) 아래 함께 있고, snippet 은 SnapLayout 밖", () => {
const protectedRoute = routes.find(
(r) => isValidElement(r.element) && r.element.type === ProtectedRoute
)
expect(protectedRoute).toBeDefined()
// 공통 래퍼가 ProtectedRoute 자식(=인증 보호됨)
const shell = (protectedRoute!.children ?? []).find(
(r) => isValidElement(r.element) && r.element.type === PaletteShell
)
expect(shell).toBeDefined()
const shellChildren = shell!.children ?? []
const snippetPath = PATHS.SNIPPET.slice(1)
// snap 그룹은 래퍼 안, 그 안에 snippet 은 없음
const snapLayoutRoute = shellChildren.find(
(r) => isValidElement(r.element) && r.element.type === SnapLayout
)
expect(snapLayoutRoute).toBeDefined()
expect(snapLayoutRoute!.children?.some((r) => r.path === snippetPath)).toBe(false)
// snippet 은 래퍼 직속(SnapLayout 밖)
const snippetRoute = shellChildren.find((r) => r.path === snippetPath)
expect(snippetRoute).toBeDefined()
})
})