45 lines
1.2 KiB
Python
45 lines
1.2 KiB
Python
|
|
"""End-to-end smoke test for Undo."""
|
||
|
|
import sys
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
|
||
|
|
|
||
|
|
from tools.automation.harness import Harness
|
||
|
|
|
||
|
|
|
||
|
|
def main():
|
||
|
|
with Harness.launch(run_name="undo") as h:
|
||
|
|
h.load_mission("campaign_01", 0)
|
||
|
|
h.screenshot("01_loaded")
|
||
|
|
initial = h.state()
|
||
|
|
assert len(initial['pieces']) == 0
|
||
|
|
|
||
|
|
h.place("Pawn", (0, 0), (0, 1))
|
||
|
|
h.place("Pawn", (1, 0), (1, 1))
|
||
|
|
h.screenshot("02_two_pieces")
|
||
|
|
s = h.state()
|
||
|
|
assert len(s['pieces']) == 2, f"expected 2 pieces, got {len(s['pieces'])}"
|
||
|
|
|
||
|
|
r = h.undo()
|
||
|
|
print(f"[undo] {r}")
|
||
|
|
h.screenshot("03_after_first_undo")
|
||
|
|
s = h.state()
|
||
|
|
assert len(s['pieces']) == 1, f"expected 1 piece, got {len(s['pieces'])}"
|
||
|
|
|
||
|
|
r = h.undo()
|
||
|
|
print(f"[undo] {r}")
|
||
|
|
h.screenshot("04_after_second_undo")
|
||
|
|
s = h.state()
|
||
|
|
assert len(s['pieces']) == 0
|
||
|
|
assert s['remainingStock']['Pawn'] == 4
|
||
|
|
|
||
|
|
r = h.undo()
|
||
|
|
print(f"[undo empty] {r}")
|
||
|
|
assert r['undone'] is False
|
||
|
|
|
||
|
|
print("OK — Undo works")
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
main()
|