- B08 줄 [?][<][>][저장][초기화] · POST quantity/reset · 초안 넷 비움 · 이정 저장본 다시 읽음 - B08 B09 쪽 이동 = 저장 뒤 POST quantity/complete · 실패면 머묾 - B09 줄 [?][<][>][초기화] · [내역 초기화] → [초기화] 하나(POST estimation/reset) - B09 [>] = 고친 값 저장 → POST estimation/complete → DRAFT.next(인쇄 미리보기) · 초안 없으면 흐림 - 시험: 새 test_298_2_b08_b09_buttons · test_184_3 · test_304 · test_481_2 고쳐 씀 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
109 lines
3.4 KiB
Python
109 lines
3.4 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""298-2 B08 · B09 좌측 아래 단추 줄 — [초기화] · [>] (PLAN 497-2 · 요구 300 C1 · C3 · C4 · C5 · 301).
|
|
|
|
`helper_298_2_b08_b09_buttons.cjs` 가 진짜 `B08_Quantity_UI_Options.ts` · `B08_Quantity_UI_Page.ts` ·
|
|
`B09_Estimation_UI_Shell.ts` 를 가짜 DOM · 가짜 의존 위에서 돌림.
|
|
"""
|
|
|
|
import json
|
|
import os
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
DRAFTS = ["b08-options", "b08-materials", "b08-hydro", "b08-milestone"]
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
def r():
|
|
proc = subprocess.run(
|
|
["node", os.path.join(HERE, "helper_298_2_b08_b09_buttons.cjs")],
|
|
capture_output=True,
|
|
text=True,
|
|
encoding="utf-8",
|
|
timeout=60,
|
|
)
|
|
assert proc.returncode == 0, proc.stderr
|
|
return json.loads(proc.stdout)
|
|
|
|
|
|
def test_B08_단추_줄_저장_다음_초기화(r):
|
|
assert r["options"]["order"] == ["filled", "danger-ghost"] # [?][<][>] 은 공용이 앞에
|
|
|
|
|
|
def test_B08_초기화_취소면_그대로(r):
|
|
assert r["options"]["cancel"] == [["confirm"], DRAFTS]
|
|
|
|
|
|
def test_B08_초기화_확인_잠금_요청_초안_비움_다시_그림(r):
|
|
calls, left = r["options"]["ok"]
|
|
assert calls == [
|
|
"confirm",
|
|
"lock",
|
|
"req:POST:/projects/P1/quantity/reset",
|
|
"milestone:true", # 이정 저장본 다시 읽음
|
|
"redraw",
|
|
"unlock",
|
|
]
|
|
assert left == []
|
|
|
|
|
|
def test_B08_초기화_실패면_초안_남음(r):
|
|
calls, left = r["options"]["fail"]
|
|
assert "toast:error" in calls and "redraw" not in calls and left == DRAFTS
|
|
|
|
|
|
def test_B08_다음_단계_완료_뒤_이동_실패면_머묾(r):
|
|
p = r["page"]
|
|
assert p["next"] == ["req:POST:/projects/P1/quantity/complete", "go:b09"]
|
|
assert p["back"] == ["go:b07"] # 앞 단계 = 완료 없음
|
|
assert p["fail"] == ["req:POST:/projects/P1/quantity/complete", "toast:error"]
|
|
|
|
|
|
def test_B09_단추_줄_초기화_하나_저장_없음(r):
|
|
assert r["b09"]["dock"] == ["danger-ghost"]
|
|
assert r["b09"]["nextEnabled"] is True
|
|
|
|
|
|
def test_B09_다음_저장_완료_인쇄(r):
|
|
b = r["b09"]
|
|
assert b["clean"] == [True, ["fetch:POST:/api/projects/P1/estimation/complete", "next"]]
|
|
assert b["changed"] == [
|
|
True,
|
|
[
|
|
"lock",
|
|
"fetch:PUT:/api/projects/P1/estimation",
|
|
"unlock",
|
|
"fetch:POST:/api/projects/P1/estimation/complete",
|
|
"next",
|
|
],
|
|
]
|
|
assert b["cleared"] is True
|
|
assert "next" not in b["saveFail"][1] and "toast:error" in b["saveFail"][1]
|
|
assert b["completeFail"][1] == [
|
|
"fetch:POST:/api/projects/P1/estimation/complete",
|
|
"toast:error",
|
|
]
|
|
assert b["prev"] == [False, []] # [<] = 공용 틀 몫
|
|
|
|
|
|
def test_B09_초기화(r):
|
|
b = r["b09"]
|
|
assert b["resetCancel"] == [["confirm"], True]
|
|
assert b["resetOk"] == [
|
|
["confirm", "lock", "fetch:POST:/api/projects/P1/estimation/reset", "unlock"],
|
|
False,
|
|
]
|
|
|
|
|
|
def test_B09_초안_없으면_다음_흐림(r):
|
|
assert r["b09NoDraft"] == {"dock": ["danger-ghost"], "nextEnabled": False, "nav": [False, []]}
|
|
|
|
|
|
def test_초안_다음_길_등록():
|
|
src = (ROOT / "B09_Estimation/draft/B09_Draft_Print_UI.ts").read_text("utf-8")
|
|
assert "DRAFT.next = () => navigateTo(ROUTE.path as RoutePath);" in src
|