c812a1a595
Integrate the remote firmware workbench, OTA delivery, and timed mode schedules while preserving the local N7 scene and runtime changes.
104 lines
4.1 KiB
Python
104 lines
4.1 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 section(content: str, start: str, end: str) -> str:
|
|
start_index = content.index(start)
|
|
end_index = content.index(end, start_index)
|
|
return content[start_index:end_index]
|
|
|
|
|
|
def test_vehicle_twin_renders_on_demand_and_throttles_hotspot_layout() -> None:
|
|
app = source("app.js")
|
|
animation = section(app, " function animate(timestamp = 0) {", " setTwinSelection(")
|
|
|
|
assert "function requestRender({ hotspots = true, settleFrames = 36 } = {})" in app
|
|
assert "if (twinNeedsAnimation(twin)) queueTwinFrame();" in animation
|
|
assert "window.requestAnimationFrame(animate)" not in animation
|
|
assert "document.visibilityState !== \"visible\"" in app
|
|
assert "new IntersectionObserver" in app
|
|
assert "timestamp - twin.hotspotLastLayoutAt >= 100" in animation
|
|
assert "hotspotMetrics: new Map()" in app
|
|
assert "label?.offsetWidth" in app
|
|
assert "renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 1.5))" in app
|
|
|
|
|
|
def test_unchanged_vehicle_state_skips_dom_and_device_panel_rebuilds() -> None:
|
|
app = source("app.js")
|
|
console = source("console-v2.js")
|
|
seat_render = section(app, "function renderSeatState(actuatorState) {", "\nfunction renderDomainState")
|
|
|
|
assert "vehicleRenderFingerprint(mergedActuatorState)" in seat_render
|
|
assert "renderFingerprint === state.seatRenderFingerprint" in seat_render
|
|
assert "resetSeatState();" not in seat_render
|
|
assert 'new CustomEvent("cognitive-agent:vehicle-state-rendered"' in app
|
|
assert '"cognitive-agent:vehicle-state-rendered"' in console
|
|
assert "observe(cabinBand" not in console
|
|
assert "observe(stateBand" not in console
|
|
assert 'if (!panelVisible("devices"))' in console
|
|
assert "renderSyncedDevices({ force: true })" in console
|
|
|
|
|
|
def test_nfc_polling_keeps_its_frequency_without_rendering_hidden_surfaces() -> None:
|
|
extension = source("self-extension.js")
|
|
|
|
assert "const NFC_POLL_INTERVAL_MS = 700" in extension
|
|
assert "currentNfcDialogFingerprint()" in extension
|
|
assert "if (!force && !dialog.open)" in extension
|
|
assert "renderFingerprint === nfcDialogFingerprint" in extension
|
|
assert 'panel?.classList.contains("is-collapsed")' in extension
|
|
assert "renderFingerprint === unifiedExtensionFingerprint" in extension
|
|
assert '"cognitive-agent:side-panel-visibility"' in extension
|
|
|
|
|
|
def test_hidden_energy_monitor_samples_without_repainting() -> None:
|
|
monitor = source("energy-monitor.js")
|
|
|
|
assert "SAMPLE_INTERVAL_MS = 1000" in monitor
|
|
assert "() => sampleNow({ render: monitor.open })" in monitor
|
|
assert "if (next)" in monitor
|
|
assert "renderMonitor();" in section(monitor, " function setOpen(open) {", "\n function selectSeries")
|
|
|
|
|
|
def test_high_frequency_fields_and_hotspots_do_not_add_compositor_blur() -> None:
|
|
theme = source("codepen-glass-theme.css")
|
|
field_rule = section(
|
|
theme,
|
|
"body.console-v2 :is(input, textarea, select),",
|
|
"body.console-v2 :is(input, textarea, select):focus",
|
|
)
|
|
|
|
assert "backdrop-filter" not in field_rule
|
|
assert "body.console-v2 .v2-twin-device-popover {" in theme
|
|
shared_hotspot_rule = section(
|
|
theme,
|
|
"body.console-v2 .v2-twin-hotspot-label,",
|
|
"body.console-v2 .v2-twin-device-popover {\n -webkit-backdrop-filter",
|
|
)
|
|
assert "backdrop-filter" not in shared_hotspot_rule
|
|
|
|
|
|
def test_performance_assets_have_a_new_cache_generation() -> None:
|
|
html = source("index.html")
|
|
worker = source("service-worker.js")
|
|
|
|
for asset in (
|
|
"/app.js?v=dual-seat-145-n7-dispatch",
|
|
"/console-v2.js?v=local-first-77-performance",
|
|
"/self-extension.js?v=pet-settings-53-performance",
|
|
"/energy-monitor.js?v=energy-monitor-5-performance",
|
|
):
|
|
assert asset in html
|
|
assert f'"{asset}"' in worker
|
|
assert 'const CACHE_VERSION = "cognitive-agent-pad-v322-n7-firmware-merge"' in worker
|
|
assert '"/codepen-glass-theme.css?v=creative-cloud-6-performance"' in worker
|