| from __future__ import annotations |
|
|
| from pathlib import Path |
|
|
| ROOT = Path(__file__).resolve().parent.parent |
| EXT = ROOT / "extension" |
| WIDGET = ROOT / "app" / "static" / "widget.js" |
| BLOCK = EXT / "extensions" / "chat-widget" / "blocks" / "chat.liquid" |
| APP_TOML = EXT / "shopify.app.toml" |
|
|
|
|
| def test_widget_js_supports_signed_proxy_mode(): |
| js = WIDGET.read_text(encoding="utf-8") |
| assert 'searchParams.get("proxy")' in js |
| assert '"/apps/chat"' in js |
| assert "message:" in js and "session_id:" in js |
| assert "localStorage" in js |
|
|
|
|
| def test_block_is_app_embed_loading_widget_in_proxy_mode(): |
| liquid = BLOCK.read_text(encoding="utf-8") |
| assert "{% schema %}" in liquid |
| assert '"target": "body"' in liquid |
| assert "proxy=1" in liquid |
| assert "widget.js" in liquid |
|
|
|
|
| def test_app_toml_scopes_and_proxy(): |
| toml = APP_TOML.read_text(encoding="utf-8") |
| assert "read_orders" in toml and "read_products" in toml and "read_customers" in toml |
| assert "[app_proxy]" in toml |
| assert 'subpath = "chat"' in toml |
| assert 'prefix = "apps"' in toml |
| |
| assert "app/uninstalled" in toml |
| assert "app_subscriptions/update" in toml |
|
|