diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ac8f7cf..5cbfac3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,33 @@ accepts both, but the store flags the old spelling as deprecated ## Unreleased +### Web UI: ES modules and one form model (stage 1) + +- The web UI gains a native ES-module layer, loaded with + `', page) + assert tag, "base.html must load js/core/boot.js as a versioned module script" + # After every classic script, so nothing classic can depend on it at load. + assert page.index(tag.group(0)) > page.index("plugins_manager.js") + + +@pytest.mark.parametrize("module", MODULES, ids=[m.name for m in MODULES]) +def test_every_import_resolves_inside_the_module_tree(module): + source = module.read_text(encoding="utf-8") + for spec in _IMPORT.findall(source): + assert spec.startswith("./") or spec.startswith("../"), ( + f"{module.name}: {spec!r} -- no bundler, so only relative imports work") + target = (module.parent / spec).resolve() + assert target.is_file(), f"{module.name}: {spec!r} does not exist" + assert any(target.parent == d.resolve() for d in MODULE_DIRS), ( + f"{module.name}: {spec!r} leaves js/core and js/pages") + + +def _registered_pages(): + boot = (JS / "core" / "boot.js").read_text(encoding="utf-8") + return re.findall(r"registry\.register\('([\w-]+)',\s*function\(\)\s*\{\s*return import\('\.\./pages/([\w-]+)\.js'\)", + boot) + + +def test_every_registered_page_has_its_module_and_partial(): + pages = _registered_pages() + assert ("cache", "cache") in pages + for name, module in pages: + assert name == module, "a page is named after its module" + assert (JS / "pages" / f"{module}.js").is_file() + partials = [p for p in PARTIALS.glob("*.html") + if f'data-page="{name}"' in p.read_text(encoding="utf-8")] + assert len(partials) == 1, f"one partial roots page {name!r}: {partials}" + + +def test_converted_partials_carry_no_inline_script(): + for partial in PARTIALS.glob("*.html"): + text = partial.read_text(encoding="utf-8") + if "data-page=" in text: + assert " - + + + + diff --git a/web_interface/templates/v3/partials/cache.html b/web_interface/templates/v3/partials/cache.html index 08d30b04..d1debe63 100644 --- a/web_interface/templates/v3/partials/cache.html +++ b/web_interface/templates/v3/partials/cache.html @@ -1,4 +1,7 @@ -
View and manage cached API responses. Cache files help reduce API calls and improve performance.
@@ -11,7 +14,7 @@Cache Directory
Loading...