create-caspian-app 1.3.9 → 1.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AGENTS.md +4 -3
- package/dist/index.js +1 -1
- package/dist/main.py +14 -3
- package/dist/public/js/pp-reactive-v2.min.js +1 -1
- package/dist/tests/test_main_helpers.py +42 -0
- package/package.json +1 -1
|
@@ -122,3 +122,45 @@ class TestDeferComponentRoots:
|
|
|
122
122
|
out = main.finalize_html(html)
|
|
123
123
|
assert "<script>console.log(1)</script>" in out
|
|
124
124
|
assert "<template" in out
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
class TestDevConsoleBridge:
|
|
128
|
+
"""The dev log bridge must be dev-only by code, not by convention.
|
|
129
|
+
|
|
130
|
+
`CASPIAN_BROWSER_SYNC_PORT` is normally set only by settings/python-server.ts,
|
|
131
|
+
which is why the tag does not reach production in practice. That is a fact
|
|
132
|
+
about who sets the variable, not an enforcement -- so a stray value in a
|
|
133
|
+
production environment used to inject `<script src="/__pp-devlog.js">` into
|
|
134
|
+
every page, where BrowserSync is not running to serve it.
|
|
135
|
+
"""
|
|
136
|
+
|
|
137
|
+
PAGE = "<html><head><title>t</title></head><body>x</body></html>"
|
|
138
|
+
|
|
139
|
+
def test_injects_in_development_when_port_is_set(self, monkeypatch):
|
|
140
|
+
monkeypatch.setattr(main, "IS_PRODUCTION", False)
|
|
141
|
+
monkeypatch.setenv("CASPIAN_BROWSER_SYNC_PORT", "5090")
|
|
142
|
+
|
|
143
|
+
assert "__pp-devlog.js" in main._inject_dev_console_bridge(self.PAGE)
|
|
144
|
+
|
|
145
|
+
def test_never_injects_in_production(self, monkeypatch):
|
|
146
|
+
"""The guard under test: set variable, production, must stay out."""
|
|
147
|
+
monkeypatch.setattr(main, "IS_PRODUCTION", True)
|
|
148
|
+
monkeypatch.setenv("CASPIAN_BROWSER_SYNC_PORT", "5090")
|
|
149
|
+
|
|
150
|
+
assert main._inject_dev_console_bridge(self.PAGE) == self.PAGE
|
|
151
|
+
|
|
152
|
+
def test_skips_when_port_is_unset(self, monkeypatch):
|
|
153
|
+
monkeypatch.setattr(main, "IS_PRODUCTION", False)
|
|
154
|
+
monkeypatch.delenv("CASPIAN_BROWSER_SYNC_PORT", raising=False)
|
|
155
|
+
|
|
156
|
+
assert main._inject_dev_console_bridge(self.PAGE) == self.PAGE
|
|
157
|
+
|
|
158
|
+
def test_does_not_double_inject(self, monkeypatch):
|
|
159
|
+
monkeypatch.setattr(main, "IS_PRODUCTION", False)
|
|
160
|
+
monkeypatch.setenv("CASPIAN_BROWSER_SYNC_PORT", "5090")
|
|
161
|
+
|
|
162
|
+
once = main._inject_dev_console_bridge(self.PAGE)
|
|
163
|
+
twice = main._inject_dev_console_bridge(once)
|
|
164
|
+
|
|
165
|
+
assert twice == once
|
|
166
|
+
assert twice.count("__pp-devlog.js") == 1
|