- 등록부 home 줄 = mountHome · 썸네일 선 · 단계 점 · 「다음: 지금 단계」 · [이어서 하기] = 그 단계 화면 · [자세히] = 상세 - 4~8 = 팀원별 · 단계 분포 · 14 일 넘게 그대로 표시 · 9 넘음 = 요약 숫자 · 회사별 막대 · 종류 원(인라인 SVG) - 오른쪽 = 처리할 일 · 임시 보관함 · 회사(회사 관리자) · 예정노선(산림청) · 처음 = 세 걸음 · 꼴 고정(자동 · 작게 · 크게) 기억 - 홈 역할 차례 = 셸 roleOf 와 같게(회사 관리자가 산림청 앞) - test_546 등록부 시험 — import 한 mount 이름을 빈 함수로 저절로(페이지 줄 갈아 끼워도 그대로) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
110 lines
4.7 KiB
Python
110 lines
4.7 KiB
Python
"""546 대시보드 셸 · 세부 페이지 등록부 시험 — 화면 조작은 ORCA.
|
|
|
|
· 역할 넷(일반 · 회사 관리자 · 산림청 · 시스템 관리자)별 메뉴 묶음 · 항목 — 등록부를 Node 로 바로 돌림
|
|
· 없는 열쇠 · 권한 없는 열쇠 = 홈 · 주소 열쇠 하나에 한 페이지
|
|
· 셸 = 라우터 MountedPage(같은 주소 안 이동 = 페이지만 갈아 끼움) · 옛 ☰ 서랍 · 구역 접기 없음
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import re
|
|
import shutil
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
B01 = ROOT / "B01_Dashboard"
|
|
|
|
|
|
def _text(path: Path) -> str:
|
|
return path.read_text(encoding="utf-8")
|
|
|
|
|
|
def _run_views(body: str) -> object:
|
|
text = _text(B01 / "B01_Dashboard_UI_Views.ts")
|
|
# import 한 값(type 아닌 이름) = 빈 함수 — 페이지 줄이 새 mount 를 끌어와도 그대로 돎
|
|
stubs = [
|
|
name.split(" as ")[-1].strip()
|
|
for group in re.findall(r"^import \{([^}]*)\}", text, flags=re.M)
|
|
for name in group.split(",")
|
|
if name.strip() and not name.strip().startswith("type ")
|
|
]
|
|
src = re.sub(r"^import[\s\S]*?;\n", "", text, flags=re.M)
|
|
script = "".join(f"const {n} = () => {{}};\n" for n in stubs) + src + "\n" + body
|
|
result = subprocess.run(
|
|
["node", "--experimental-strip-types", "--no-warnings",
|
|
"--input-type=module-typescript", "-e", script],
|
|
capture_output=True, text=True, encoding="utf-8", timeout=60,
|
|
) # fmt: skip
|
|
assert result.returncode == 0, result.stderr
|
|
return json.loads(result.stdout)
|
|
|
|
|
|
MENU = (
|
|
"const menu = (r: ViewRole) => VIEWS.filter((v) => v.roles.includes(r) && v.group !== 'hidden')"
|
|
".map((v) => v.group + ':' + v.key);\n"
|
|
)
|
|
|
|
|
|
@pytest.mark.skipif(shutil.which("node") is None, reason="node 가 없음")
|
|
def test_역할별_메뉴():
|
|
out = _run_views(
|
|
MENU + "console.log(JSON.stringify(['USER','ADMIN','FOREST','SYSTEM_ADMIN'].map(menu)));"
|
|
)
|
|
work = ["work:home", "work:projects", "work:assigned", "work:temp"]
|
|
help_ = ["help:guide", "help:chat"]
|
|
user, admin, forest, system = out
|
|
assert user == [*work, "company:company", "company:company-defaults", *help_]
|
|
assert admin == [*work, "company:people", "company:company", "company:company-defaults", *help_]
|
|
# 산림청 = 받은 예정노선 없음(보내는 쪽)
|
|
assert forest == [
|
|
"work:home", "work:projects", "work:temp",
|
|
"company:company", "company:company-defaults", *help_,
|
|
] # fmt: skip
|
|
assert system == [
|
|
*work, "company:people", "company:company",
|
|
"system:sys-overview", "system:sys-companies", "system:sys-users",
|
|
"system:sys-defaults", "system:sys-logs", *help_,
|
|
] # fmt: skip
|
|
|
|
|
|
@pytest.mark.skipif(shutil.which("node") is None, reason="node 가 없음")
|
|
def test_주소_열쇠_권한_없으면_홈():
|
|
out = _run_views(
|
|
"console.log(JSON.stringify(["
|
|
"viewFor(null, 'USER').key, viewFor('없음', 'USER').key,"
|
|
"viewFor('people', 'USER').key, viewFor('people', 'ADMIN').key,"
|
|
"viewFor('sys-logs', 'ADMIN').key, viewFor('sys-logs', 'SYSTEM_ADMIN').key,"
|
|
"viewFor('project', 'USER').key, viewFor('me', 'FOREST').key,"
|
|
"roleOf({ role: 'USER' }, true), roleOf({ role: 'ADMIN' }, true),"
|
|
"roleOf({ role: 'SYSTEM_ADMIN' }, true), roleOf({ role: 'USER' }, false),"
|
|
"new Set(VIEWS.map((v) => v.key)).size === VIEWS.length,"
|
|
"]));"
|
|
)
|
|
assert out == [
|
|
"home", "home", "home", "people", "home", "sys-logs", "project", "me",
|
|
"FOREST", "ADMIN", "SYSTEM_ADMIN", "USER", True,
|
|
] # fmt: skip
|
|
|
|
|
|
def test_셸_한_벌():
|
|
shell = _text(B01 / "B01_Dashboard_UI_Shell.ts")
|
|
assert "covers: (route) => route === ROUTES.B01_ACCOUNT" in shell # 같은 주소 안 = show
|
|
assert 'currentQuery().get("view")' in shell
|
|
assert "buildKnowledgeChat()" in shell # 챗봇 둥근 단추 그대로
|
|
page = _text(B01 / "B01_Dashboard_UI_Page.ts")
|
|
assert "mountDashboardShell(root, user, Boolean(session?.is_forest_service))" in page
|
|
for name in ("Page", "Shell", "Nav", "Views", "Legacy"):
|
|
src = _text(B01 / f"B01_Dashboard_UI_{name}.ts")
|
|
assert "setDrawerSteps" not in src and "attachCollapsible" not in src, name
|
|
assert len(src.splitlines()) <= 700, name
|
|
css = _text(B01 / "B01_Dashboard_UI_Style_Shell.css")
|
|
# 색 변수는 셸 안에서만 — :root 에 안 둠
|
|
assert "--b01-accent: #1f7a4d;" in css and not re.search(r"^:root\s*\{", css, re.M)
|
|
assert ':root[data-theme="dark"] .b01-shell {' in css
|
|
icons = _text(ROOT / "ui_template" / "ui_template_icons.ts")
|
|
assert "MIT License" in icons and "Paweł Kuna" in icons
|