feat: ds
This commit is contained in:
@@ -202,15 +202,6 @@ def normalize_landing_template(value: str | None) -> str:
|
||||
return template
|
||||
|
||||
|
||||
def ensure_route_js(weifile_dir: Path) -> Path:
|
||||
src = xxbb_build.SOURCE_WEIFILE / "route.js"
|
||||
if not src.is_file():
|
||||
raise SystemExit(f"missing weifile router: {src}")
|
||||
dest = weifile_dir / "route.js"
|
||||
dest.write_text(src.read_text(encoding="utf-8"), encoding="utf-8")
|
||||
return dest
|
||||
|
||||
|
||||
def apply_landing_template(weifile_dir: Path, template: str) -> Path:
|
||||
template = normalize_landing_template(template)
|
||||
src = LANDING_TEMPLATE_ROOT / f"{template}.html"
|
||||
@@ -282,7 +273,9 @@ def pack_channel(
|
||||
encoding="utf-8",
|
||||
)
|
||||
apply_landing_template(weifile_dest, landing_template)
|
||||
ensure_route_js(weifile_dest)
|
||||
leftover_route = weifile_dest / "route.js"
|
||||
if leftover_route.is_file():
|
||||
leftover_route.unlink()
|
||||
|
||||
if channel_out.exists():
|
||||
shutil.rmtree(channel_out)
|
||||
|
||||
@@ -83,18 +83,18 @@ class XxbbBuildTest(unittest.TestCase):
|
||||
self.assertFalse((artifact / "weifile").exists())
|
||||
self.assertTrue((weifile / "index.js").is_file())
|
||||
self.assertTrue((weifile / "weifile.html").is_file())
|
||||
self.assertTrue((weifile / "route.js").is_file())
|
||||
self.assertFalse((weifile / "route.js").is_file())
|
||||
html = (weifile / "weifile.html").read_text(encoding="utf-8")
|
||||
route = (weifile / "route.js").read_text(encoding="utf-8")
|
||||
self.assertNotIn("__CHANNEL_C__", html)
|
||||
self.assertNotIn("/t.js", html)
|
||||
self.assertIn("route.js", html)
|
||||
self.assertIn("location.pathname", route)
|
||||
self.assertIn("/next-chain", route)
|
||||
self.assertIn("boot.js", route)
|
||||
self.assertIn("10 * 60 * 1000", route)
|
||||
self.assertNotIn("channeICode", route)
|
||||
self.assertIn("index.js", route)
|
||||
self.assertNotIn('src="route.js"', html)
|
||||
self.assertIn("location.pathname", html)
|
||||
self.assertIn("/next-chain", html)
|
||||
self.assertIn("config.js", html)
|
||||
self.assertIn("holdFresh", html)
|
||||
self.assertIn("10 * 60 * 1000", html)
|
||||
self.assertNotIn("channeICode", html)
|
||||
self.assertIn("index.js", html)
|
||||
index_js = (weifile / "index.js").read_text(encoding="utf-8")
|
||||
expected_host = generate_domains(channel_c, 1)[0]
|
||||
self.assertIn(expected_host, index_js)
|
||||
@@ -321,15 +321,19 @@ class XxbbBuildTest(unittest.TestCase):
|
||||
self.assertEqual(stripped, "head;")
|
||||
html = pack_channel.inject_tjs("<html><head></head><body></body></html>")
|
||||
self.assertIn('/t.js', html)
|
||||
route = (xxbb_build.SOURCE_WEIFILE / "route.js").read_text(encoding="utf-8")
|
||||
self.assertIn("location.pathname", route)
|
||||
self.assertIn("/next-chain", route)
|
||||
self.assertIn("boot.js", route)
|
||||
self.assertIn("10 * 60 * 1000", route)
|
||||
self.assertNotIn("channeICode", route)
|
||||
self.assertFalse((xxbb_build.SOURCE_WEIFILE / "route.js").is_file())
|
||||
for name in ("weifile.html", "templates/blank.html", "templates/test.html"):
|
||||
landing = (xxbb_build.SOURCE_WEIFILE / name).read_text(encoding="utf-8")
|
||||
self.assertIn("route.js", landing)
|
||||
self.assertNotIn('src="route.js"', landing)
|
||||
self.assertIn("location.pathname", landing)
|
||||
self.assertIn("/next-chain", landing)
|
||||
self.assertIn("config.js", landing)
|
||||
self.assertIn("boot.js", landing)
|
||||
self.assertNotIn("__LAB_RUN_BOOT__", landing)
|
||||
self.assertNotIn("iframe", landing)
|
||||
self.assertIn("holdFresh", landing)
|
||||
self.assertIn("10 * 60 * 1000", landing)
|
||||
self.assertNotIn("channeICode", landing)
|
||||
self.assertNotIn('src="index.js"', landing)
|
||||
|
||||
def test_source_details_has_lab_passworded_wap_and_sms(self) -> None:
|
||||
|
||||
Reference in New Issue
Block a user