diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-10-10 13:13:57 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-10-10 13:13:57 +0200 |
| commit | 914d2f0af848fb80d70d517901f44420a4e47764 (patch) | |
| tree | e264c669df7311df941c0e935dedf71c892eeed6 /packages/meshbay-hub/tests/test_photo_delete.py | |
| parent | a0793dd37030f7213ecb07a018b11e6a8adf9238 (diff) | |
| download | meshbay-914d2f0af848fb80d70d517901f44420a4e47764.tar.gz | |
feat(hub): delete a photo from the Photos app
On a right-clicked tile and in the lightbox bar, after a confirmation, for
the node's operator or the photo's uploader, as in Files.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-hub/tests/test_photo_delete.py')
| -rw-r--r-- | packages/meshbay-hub/tests/test_photo_delete.py | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/packages/meshbay-hub/tests/test_photo_delete.py b/packages/meshbay-hub/tests/test_photo_delete.py new file mode 100644 index 0000000..bcc943f --- /dev/null +++ b/packages/meshbay-hub/tests/test_photo_delete.py @@ -0,0 +1,60 @@ +""" +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"] |