Files
odysseus/tests/test_editor_quick_edit_recents.py
T
pewdiepie-archdaemonandClaude Opus 5.5 5fac693c1c feat(photo-editor): Ajax Image Editor client (Photoshop-parity tools)
Photoshop-parity editor client: layers, selection/masking, brushes,
smart filters, LUT import, Quick Edit, mobile gestures, workspaces,
batch operations, and the service-worker versioning (v978->v1006).

Source: vendor/photocraft (ad1cff44) photo-editor client files, merged
onto upstream/dev (a8c147b2). Conflict resolution documented in
pr_work/A_conflicts.md; editor files taken from vendor/photocraft
(upstream's editor is an earlier snapshot of the same feature).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 11:57:35 +00:00

47 lines
1.9 KiB
Python

from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
EDITOR = ROOT / "static/js/galleryEditor.js"
def test_recent_prompt_helpers_exist():
src = EDITOR.read_text(encoding="utf-8")
assert "_AI_RECENT_KEY = 'ge-ai-command-recent'" in src
assert "const _getRecentPrompts = () => {" in src
assert "const _pushRecentPrompt = (prompt) => {" in src
# Most-recent-first, de-duplicated (case-insensitive), capped.
assert "_AI_RECENT_MAX = 8" in src
assert "v.toLowerCase() !== p.toLowerCase()" in src
assert "list.unshift(p);" in src
assert "list.slice(0, _AI_RECENT_MAX)" in src
def test_recent_prompts_surface_as_suggestions_when_input_empty():
src = EDITOR.read_text(encoding="utf-8")
assert "if (!input.value.trim()) {" in src
assert "const recents = _getRecentPrompts();" in src
assert "recents.length" in src
assert "recents.map((p) => ({ label: p, insert: p, hint: 'Recent prompt', kind: 'Recent' }))" in src
def test_example_prompts_offer_starters_when_no_recents():
src = EDITOR.read_text(encoding="utf-8")
assert "const _AI_EXAMPLE_PROMPTS = [" in src
# A handful of concrete starters that map to real routes.
assert src.count("hint: '") >= 6
assert "insert: 'remove background'" in src
assert "insert: 'make it cinematic'" in src
# Empty box + no history -> Example chips.
assert ": _AI_EXAMPLE_PROMPTS.map((e) => ({ label: e.label, insert: e.insert, hint: e.hint, kind: 'Example' }))" in src
def test_submitting_a_prompt_records_it_as_recent():
src = EDITOR.read_text(encoding="utf-8")
assert "_pushRecentPrompt(input.value);" in src
# It must be recorded right before the job is enqueued.
idx = src.index("form.addEventListener('submit'")
block = src[idx:idx + 400]
assert "_pushRecentPrompt(input.value);" in block
assert "enqueueQuickEditJob(input.value, false);" in block