Merge branch 'worktree-playwright-tests'

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-21 17:12:37 +02:00
21 changed files with 1656 additions and 160 deletions
+36 -6
View File
@@ -1,4 +1,5 @@
import json
import shutil
from pathlib import Path
@@ -18,13 +19,29 @@ def test_export_writes_entry_folder(base_url, page, seed_state, pages_dir):
assert any(dest.iterdir()) if dest.exists() else True # may not exist in test env
def test_export_sets_status_exported(base_url, page, seed_state, flask_app):
def test_export_sets_status_exported(base_url, page, seed_state, flask_app, pages_dir):
album_id = seed_state("phase6_state")
page.request.post(
# Ensure dest folder does not exist so export proceeds without conflict
daily_dest = Path(pages_dir) / "01.trips" / "central-asia-2023" / "01.dailies"
if daily_dest.exists():
shutil.rmtree(daily_dest)
res = page.request.post(
f"{base_url}/export/run",
data=json.dumps({"album_id": album_id, "overwrite_ids": []}),
data=json.dumps({"album_id": album_id}),
headers={"Content-Type": "application/json"},
)
data = res.json()
# Must not be a conflict — export should succeed
assert data.get("ok") is True, f"Expected ok response, got: {data}"
# The journal entry.md file must exist on disk
entry_files = list(daily_dest.glob("**/entry.md")) if daily_dest.exists() else []
assert len(entry_files) >= 1, "entry.md not written to disk"
# Status must be exported in state
with flask_app.app_context():
from app.state import load_state
state = load_state(album_id, flask_app)
@@ -34,11 +51,24 @@ def test_export_sets_status_exported(base_url, page, seed_state, flask_app):
def test_skipped_groups_not_exported(base_url, page, seed_state, pages_dir):
album_id = seed_state("phase6_state")
# Clean dest so there's no conflict
daily_dest = Path(pages_dir) / "01.trips" / "central-asia-2023" / "01.dailies"
if daily_dest.exists():
shutil.rmtree(daily_dest)
res = page.request.post(
f"{base_url}/export/run",
data=json.dumps({"album_id": album_id, "overwrite_ids": []}),
data=json.dumps({"album_id": album_id}),
headers={"Content-Type": "application/json"},
)
data = res.json()
exported_titles = [r.get("title") for r in data.get("results", [])]
assert "The Market" not in exported_titles # g2 is skipped in fixture
# Response shape: {"ok": true, "exported": N, "failed": [...]}
# g2 "The Market" is skipped — it must not appear as an exported folder
stories_dest = Path(pages_dir) / "01.trips" / "central-asia-2023" / "04.stories"
market_dirs = list(stories_dest.glob("*the-market*")) if stories_dest.exists() else []
assert len(market_dirs) == 0, "Skipped group 'The Market' must not be exported"
# And the response must not include a conflict (only written groups are exported)
assert data.get("ok") is True, f"Expected ok response, got: {data}"