""" Deleting a photo from the Photos app (harness/photo_delete_probe.py). On a right-clicked tile and in the lightbox's bar, which is how a phone gets at it. Offered on the rule Files applies and the node enforces: the node's operator, or whoever uploaded the photo. Never without the page's own confirmation, and never from Search, which is read-only. """ import json import shutil import subprocess import sys from pathlib import Path import pytest HARNESS = Path(__file__).parent / "harness" / "photo_delete_probe.py" @pytest.fixture(scope="module") def cases(): if shutil.which("google-chrome") is None: pytest.skip("Chrome is not available") proc = subprocess.run([sys.executable, str(HARNESS)], capture_output=True, text=True, timeout=180) assert proc.returncode == 0, f"probe failed: {proc.stdout}{proc.stderr}" out = json.loads(proc.stdout) assert "error" not in out, out["error"] assert out["logs"] == [] return {c["case"]: c for c in out["cases"]} def test_ones_own_photo_is_deleted_only_once_confirmed(cases): c = cases["tile"] assert "Delete" in c["labels"] assert c["asked"].startswith("Delete beach.jpg?") assert c["after_no"] == {"deleted": 0, "tiles": 3} assert c["deleted"] == [["p1", "sign-fn"]] assert c["tiles"] == 2 def test_somebody_elses_photo_offers_no_delete(cases): assert "Delete" not in cases["not mine"]["menu_without_delete"] def test_the_operator_may_delete_any_photo(cases): assert cases["operator"]["delete_offered"] == [True, True, True] def test_the_lightbox_deletes_and_shows_the_next_photo(cases): c = cases["lightbox"] assert c["button"] and c["dialog_on_top"] assert c["deleted"] == ["p1"] assert c["open"] and c["before"] == "beach.jpg" and c["after"] == "dunes.jpg" def test_search_results_offer_no_delete(cases): c = cases["read only"] assert "Delete" not in c["labels"] and not c["lightbox_button"]