feat(n7web): enhance control workflows and status feedback
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
@@ -11,25 +12,44 @@ def source(name: str) -> str:
|
||||
return (WEB / name).read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def test_vue_presentation_assets_are_local_ordered_and_cached() -> None:
|
||||
def test_vue_vite_application_is_the_primary_frontend_entry() -> None:
|
||||
html = source("index.html")
|
||||
main = source("src/main.js")
|
||||
app = source("src/App.vue")
|
||||
package = json.loads(source("package.json"))
|
||||
vite = source("vite.config.js")
|
||||
service_worker = source("service-worker.js")
|
||||
runtime = "/vendor/vue/3.5.21/vue.runtime.global.prod.js"
|
||||
presentation = "/vue-ui.js?v=vue-presentation-3"
|
||||
|
||||
assert html.index(runtime) < html.index(presentation) < html.index(
|
||||
"/app.js?v=dual-seat-140"
|
||||
)
|
||||
assert html.index(presentation) < html.index(
|
||||
"/assistant-chat.js?v=codex-assistant-33"
|
||||
)
|
||||
assert f'"{runtime}"' in service_worker
|
||||
assert f'"{presentation}"' in service_worker
|
||||
assert 'const CACHE_VERSION = "cognitive-agent-pad-v305"' in service_worker
|
||||
assert '<div id="app" aria-busy="true"></div>' in html
|
||||
assert '<script type="module" src="/src/main.js"></script>' in html
|
||||
assert 'import { createApp, nextTick } from "vue"' in main
|
||||
assert 'import App from "./App.vue"' in main
|
||||
assert 'application.mount("#app")' in main
|
||||
assert 'defineOptions({ name: "N7ConsoleApp" })' in app
|
||||
assert 'class="workspace"' in app
|
||||
assert package["dependencies"]["vue"] == "3.5.21"
|
||||
assert package["scripts"]["build"] == "vite build"
|
||||
assert 'import vue from "@vitejs/plugin-vue"' in vite
|
||||
assert 'outDir: outputRoot' in vite
|
||||
assert 'const CACHE_VERSION = "cognitive-agent-pad-v315-vue-vite"' in service_worker
|
||||
assert "unpkg.com" not in html
|
||||
assert "cdn.jsdelivr.net" not in html
|
||||
|
||||
|
||||
def test_python_and_one_click_startup_use_the_vite_distribution() -> None:
|
||||
server = (ROOT / "src" / "cognitive_agent" / "server.py").read_text(
|
||||
encoding="utf-8"
|
||||
)
|
||||
launcher = (ROOT / "tools" / "start_n7web.py").read_text(encoding="utf-8")
|
||||
|
||||
assert 'WEB_CONSOLE_DIST_ROOT = WEB_CONSOLE_SOURCE_ROOT / "dist"' in server
|
||||
assert 'if (WEB_CONSOLE_DIST_ROOT / "index.html").is_file()' in server
|
||||
assert 'parser.add_argument(\n "--skip-web-build"' in launcher
|
||||
assert 'commands.append([str(npm), "ci"])' in launcher
|
||||
assert 'commands.append([str(npm), "run", "build"])' in launcher
|
||||
assert "_build_web_console(npm)" in launcher
|
||||
|
||||
|
||||
def test_vendored_vue_runtime_and_license_are_present() -> None:
|
||||
runtime = WEB / "vendor" / "vue" / "3.5.21" / "vue.runtime.global.prod.js"
|
||||
license_file = WEB / "vendor" / "vue" / "3.5.21" / "LICENSE"
|
||||
@@ -66,7 +86,7 @@ def test_vue_islands_render_modes_and_dispatched_controls() -> None:
|
||||
assert ".assistant-dispatched-controls-vue-host" in styles
|
||||
|
||||
|
||||
def test_existing_dom_renderers_remain_as_no_vue_fallbacks() -> None:
|
||||
def test_existing_dom_renderers_remain_as_transition_fallbacks() -> None:
|
||||
app = source("app.js")
|
||||
assistant = source("assistant-chat.js")
|
||||
|
||||
@@ -81,5 +101,7 @@ def test_existing_dom_renderers_remain_as_no_vue_fallbacks() -> None:
|
||||
'document.createElement("details")', command_vue_call
|
||||
)
|
||||
assert command_fallback > command_vue_call
|
||||
assert "renderDispatchedControls: () => false" in source("vue-ui.js")
|
||||
assert "renderModeChips: () => false" in source("vue-ui.js")
|
||||
vue_ui = source("vue-ui.js")
|
||||
assert 'from "vue"' in vue_ui
|
||||
assert "renderDispatchedControls: () => false" not in vue_ui
|
||||
assert "renderModeChips: () => false" not in vue_ui
|
||||
|
||||
Reference in New Issue
Block a user