# -*- coding: utf-8 -*- """요구 280-2 · PLAN 481-1 — 좌측 아래 [?] [<] [>] 페이지 이동. ① 줄 차례 = [?] [<] [>] + 그 페이지 단추 · 다섯 주소만(b03 · b04 · b09-print · m01 · m02 = [?] 만) · B05 [<] · B09 [>] 흐림 ② [<] [>] = 이웃 단계 단추 누름(`onStepClick` 한 길) · 막힌 단계(NOT_STARTED 만) = 누르지 않고 그 단추 title 알림 ③ B05 ↔ B06 = 같은 페이지 주소만(다시 안 실음) · 주소 바뀌면 [<] 다시 맞춤 · 도크 = [저장] [초기화] 둘(496-1) """ import json import os import subprocess from pathlib import Path import pytest HERE = os.path.dirname(os.path.abspath(__file__)) ROOT = Path(HERE).parents[1] FIVE = ("b05-profile", "b06-section", "b07-design-detail", "b08-quantity", "b09-estimation") OTHERS = ("b03-file-input", "b04-preprocess", "b09-print", "m01-master-data", "m02-master-template") @pytest.fixture(scope="module") def results(): proc = subprocess.run( ["node", os.path.join(HERE, "helper_280_2_step_nav.cjs")], capture_output=True, text=True, encoding="utf-8", timeout=60, ) assert proc.returncode == 0, proc.stderr return json.loads(proc.stdout) @pytest.mark.parametrize("shape", ["helpRow", "plain"]) def test_다섯_주소만_물음_앞뒤_차례(results, shape): for route in FIVE: assert results["rows"][route][shape]["labels"] == ["?", "<", ">", "저장"], route for route in OTHERS: assert results["rows"][route][shape]["labels"] == ["?", "저장"], route def test_B05_앞_B09_다음만_흐림(results): for route in FIVE: expected = [False, route == "b05-profile", route == "b09-estimation", False] assert results["rows"][route]["helpRow"]["disabled"] == expected, route def test_앞뒤는_이웃_단계_누름(results): nav = results["nav"] assert nav["b05Prev"] == {"calls": [], "toasts": []} # 흐림 — 누름 안 감(496-1) assert nav["b05Next"] == {"calls": ["3:b06-section"], "toasts": []} # B05 → B06 은 같은 페이지 — setActiveStep 으로 켜진 칸이 바뀐 뒤 이웃 assert nav["b06Prev"] == {"calls": ["2:b05-profile"], "toasts": []} assert nav["b06Next"] == {"calls": ["4:b07-design-detail"], "toasts": []} assert nav["b09Prev"] == {"calls": ["5:b08-quantity"], "toasts": []} assert nav["b09Next"] == {"calls": [], "toasts": []} def test_B05_앞_흐림은_주소_따라_다시_맞춤(results): assert results["nav"]["prevDisabled"] == {"b05": True, "b06": False, "back": True} def test_막힌_단계는_알림만(results): nav = results["nav"] assert nav["blockedNext"] == {"calls": [], "toasts": ["WF_State_NotStarted"]} assert nav["userPrev"] == {"calls": ["2:b05-profile"], "toasts": []} lock = {"disabled": True, "title": "시스템 관리자 전용 단계입니다."} assert nav["userB04"] == lock and nav["userB04Repaint"] == lock def test_STALE_은_색만_막지_않음(results): nav = results["nav"] assert nav["staleNext"] == {"calls": ["4:b07-design-detail"], "toasts": []} assert "state-stale" in nav["staleClass"].split() def test_다시_칠하기와_켤_칸_목록(results): nav = results["nav"] assert nav["repaintNext"] == {"calls": ["4:b07-design-detail"], "toasts": []} assert "state-in_progress" in nav["repaintClass"].split() assert "state-not_started" not in nav["repaintClass"].split() # B05 · B06 화면 = 2 · 3 · 4 늘 켬 — 운영 · 체인 직후 B07 NOT_STARTED 라도 [>] 가 감 · B08 은 막힘 assert nav["listNext"] == {"calls": ["4:b07-design-detail"], "toasts": []} assert nav["listB08"] is True def test_B05_B06_사이는_주소만_다시_안_실음(): page = (ROOT / "A00_Common" / "design" / "design_page.ts").read_text(encoding="utf-8") assert "if (designViewOf(route)) navigateTo(route);" in page dock = (ROOT / "A00_Common" / "design" / "design_dock.ts").read_text(encoding="utf-8") shared = (ROOT / "A00_Common" / "design" / "design_shared.ts").read_text(encoding="utf-8") for text in (dock, shared): assert "switchView" not in text assert "row.append(saveButton, resetButton);" in dock assert "confirmButton" not in dock and 'variant: "danger-ghost"' in dock assert "currentStage: [2, 3, 4]" in page assert "else if (stepIndex >= 4) confirmAndGo(shared, route);" in page locale = (ROOT / "ui_template" / "ui_template_locale_b2.ts").read_text(encoding="utf-8") assert "Design_Btn_ToCross" not in locale and "Design_Btn_ToProfile" not in locale assert "B06_Profile_Btn_Confirm" not in locale