Files
odysseus/tests/test_editor_blend_modes_js.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

61 lines
1.9 KiB
Python

from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
BLEND = ROOT / "static/js/editor/blend-modes.js"
LAYER_CLIPPING = ROOT / "static/js/editor/layer-clipping.js"
ADJUSTMENT_LAYER = ROOT / "static/js/editor/adjustment-layer.js"
LAYER_GROUPS = ROOT / "static/js/editor/layer-groups.js"
CONTROLS = ROOT / "static/js/editor/build/controls.js"
CODEC = ROOT / "static/js/editor/document-codec.js"
SW = ROOT / "static/sw.js"
EXTRA_MODES = [
"dissolve",
"linear-burn",
"linear-dodge",
"darker-color",
"lighter-color",
"vivid-light",
"linear-light",
"pin-light",
"hard-mix",
"subtract",
"divide",
]
def test_blend_modes_module_shape():
src = BLEND.read_text(encoding="utf-8")
assert "export const NATIVE_BLEND_MODES" in src
assert "export const EXTRA_BLEND_MODES" in src
assert "export function blendDraw" in src
assert "export function isNativeBlendMode" in src
# Canvas natively supports linear-dodge via 'lighter'.
assert "linear-dodge" in src and "lighter" in src
def test_extra_blend_modes_are_declared():
src = BLEND.read_text(encoding="utf-8")
for mode in EXTRA_MODES:
assert f"'{mode}'" in src or f'"{mode}"' in src, mode
def test_blend_draw_is_wired_into_all_draw_paths():
for path in (LAYER_CLIPPING, ADJUSTMENT_LAYER, LAYER_GROUPS):
src = path.read_text(encoding="utf-8")
assert "blendDraw" in src, path
assert "blendDraw(" in src, path
def test_blend_select_and_codec_offer_extra_modes():
controls = CONTROLS.read_text(encoding="utf-8")
codec = CODEC.read_text(encoding="utf-8")
for mode in EXTRA_MODES:
assert f'value="{mode}"' in controls, mode
assert f"'{mode}'" in codec or f'"{mode}"' in codec, mode
def test_blend_modes_precached():
assert "/static/js/editor/blend-modes.js" in SW.read_text(encoding="utf-8")