@davoodmehraban89 / Aram / commits / aa71ed2
Fork 0

test(desktop): exercise frozen Tk success route with valid synthetic five-statement inputs

davoodmehraban89 committed Oct 31, 2026 at 19:03 UTC aa71ed21efb28343dcff36d2875764a1e4b7578c
1 file changed +64 -1
backend/src/aram_backend/desktop_five_statement.py
+64 -1
@@ -6,6 +6,7 @@ Tk is a presentation layer over the existing bounded local preview pipeline.
6 from __future__ import annotations
7
8 from queue import Empty, Queue
9 +import json
10 import sys
11 import tempfile
12 from threading import Thread
@@ -17,6 +18,9 @@ from typing import Callable
18 from aram_backend.desktop_five_statement_core import (
19 DesktopFiveInputError, DesktopFiveStatementController,
20 )
21 +from aram_backend.synthetic_five_statement_demo import (
22 + pipeline_manifest, source_workbook,
23 +)
24
25 TITLE = "آرام | پنج صورت مالی — پیش‌نمایش آزمایشی و غیررسمی"
26 ACTIONS = {
@@ -455,14 +459,73 @@ def ui_smoke_test() -> int:
459 pass
460
461
462 +def ui_valid_smoke_test() -> int:
463 + """Exercise frozen Tk with a truly valid synthetic five-statement input.
464 +
465 + This is an automated widget check, not human review or official approval.
466 + """
467 + import time
468 + with tempfile.TemporaryDirectory() as directory:
469 + folder = Path(directory)
470 + workbook = folder / "ARAM-SYNTHETIC-ONLY.xlsx"
471 + manifest = folder / "ARAM-SYNTHETIC-ONLY.json"
472 + workbook.write_bytes(source_workbook())
473 + manifest.write_text(
474 + json.dumps(pipeline_manifest(), ensure_ascii=True), encoding="utf-8",
475 + )
476 + selected = {"workbook": str(workbook), "manifest": str(manifest)}
477 + window = FiveStatementWindow(picker=lambda kind: selected[kind])
478 + try:
479 + window.withdraw()
480 + window.update_idletasks()
481 + if str(window.run_button.cget("state")) != "disabled":
482 + return 20
483 + window.workbook_button.invoke()
484 + window.manifest_button.invoke()
485 + if not window.controller.can_run:
486 + return 21
487 + window.run_button.invoke()
488 + for _ in range(500):
489 + window.update()
490 + if not window._busy:
491 + break
492 + time.sleep(0.02)
493 + if window._busy or window.controller.state != "ELIGIBLE":
494 + return 22
495 + if not window.controller.result or not window.controller.result.eligible_for_analyst_review:
496 + return 23
497 + rows = window.outcome_tree.get_children()
498 + if len(rows) != 5:
499 + return 24
500 + if any(
501 + window.outcome_tree.item(row, "values")[1] != "قابل بررسی"
502 + for row in rows
503 + ):
504 + return 25
505 + window.clear_button.invoke()
506 + if window.controller.result is not None or window.outcome_tree.get_children():
507 + return 26
508 + if str(window.run_button.cget("state")) != "disabled":
509 + return 27
510 + return 0
511 + finally:
512 + try:
513 + if window.winfo_exists():
514 + window.destroy()
515 + except tk.TclError:
516 + pass
517 +
518 +
519 def main(argv: list[str] | None = None) -> int:
520 args = list(sys.argv[1:] if argv is None else argv)
521 if args == ["--self-test"]:
522 return self_test()
523 if args == ["--ui-smoke"]:
524 return ui_smoke_test()
525 + if args == ["--ui-valid-smoke"]:
526 + return ui_valid_smoke_test()
527 if args:
465 - print("Supported: --self-test, --ui-smoke, or no arguments", file=sys.stderr)
528 + print("Supported: --self-test, --ui-smoke, --ui-valid-smoke, or no arguments", file=sys.stderr)
529 return 2
530 window = FiveStatementWindow()
531 window.mainloop()