86 lines
3.3 KiB
Python
86 lines
3.3 KiB
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
WEB = ROOT / "apps" / "web-console"
|
|
|
|
|
|
def source(name: str) -> str:
|
|
return (WEB / name).read_text(encoding="utf-8")
|
|
|
|
|
|
def test_vue_presentation_assets_are_local_ordered_and_cached() -> None:
|
|
html = source("index.html")
|
|
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-135"
|
|
)
|
|
assert html.index(presentation) < html.index(
|
|
"/assistant-chat.js?v=codex-assistant-32"
|
|
)
|
|
assert f'"{runtime}"' in service_worker
|
|
assert f'"{presentation}"' in service_worker
|
|
assert 'const CACHE_VERSION = "cognitive-agent-pad-v290"' in service_worker
|
|
assert "unpkg.com" not in html
|
|
assert "cdn.jsdelivr.net" not in html
|
|
|
|
|
|
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"
|
|
|
|
assert runtime.is_file()
|
|
assert runtime.stat().st_size > 50_000
|
|
assert "vue v3.5.21" in runtime.read_text(encoding="utf-8")[:500]
|
|
assert license_file.is_file()
|
|
assert "The MIT License" in license_file.read_text(encoding="utf-8")
|
|
|
|
|
|
def test_vue_islands_render_modes_and_dispatched_controls() -> None:
|
|
vue_ui = source("vue-ui.js")
|
|
app = source("app.js")
|
|
assistant = source("assistant-chat.js")
|
|
styles = source("assistant-chat.css")
|
|
|
|
assert 'name: "N7ModeChipRail"' in vue_ui
|
|
assert 'name: "N7DispatchedControlsCard"' in vue_ui
|
|
assert 'container.dataset.vueSurface = "mode-chips"' in vue_ui
|
|
assert 'container.dataset.vueSurface = "dispatched-controls"' in vue_ui
|
|
assert "renderModeChips" in vue_ui
|
|
assert "renderDispatchedControls" in vue_ui
|
|
assert "window.CognitiveAgentVueUI = Object.freeze" in vue_ui
|
|
assert '"data-mode-run": "true"' in vue_ui
|
|
|
|
assert "function vueModeChipEntries(modes)" in app
|
|
assert "window.CognitiveAgentVueUI?.renderModeChips?.(" in app
|
|
assert "window.CognitiveAgentVueUI?.renderDispatchedControls" in assistant
|
|
assert 'host.className = "assistant-dispatched-controls-vue-host"' in assistant
|
|
assert "deliveryLabel: String(item.deliveryLabel" in assistant
|
|
assert "deliveryDetail: String(item.deliveryDetail" in assistant
|
|
assert "下发状态:" in vue_ui
|
|
assert ".assistant-dispatched-controls-vue-host" in styles
|
|
|
|
|
|
def test_existing_dom_renderers_remain_as_no_vue_fallbacks() -> None:
|
|
app = source("app.js")
|
|
assistant = source("assistant-chat.js")
|
|
|
|
mode_vue_call = app.index("window.CognitiveAgentVueUI?.renderModeChips?.(")
|
|
mode_fallback = app.index("const runtimeModeIds = new Set", mode_vue_call)
|
|
assert mode_fallback > mode_vue_call
|
|
|
|
command_vue_call = assistant.index(
|
|
"window.CognitiveAgentVueUI?.renderDispatchedControls"
|
|
)
|
|
command_fallback = assistant.index(
|
|
'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")
|