feat: integrate NFC infrared peripherals and orchestration
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
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_unified_console_exposes_nfc_discovery_and_learning_flow() -> None:
|
||||
script = source("self-extension.js")
|
||||
styles = source("self-extension.css")
|
||||
html = source("index.html")
|
||||
|
||||
assert 'data-open-nfc-learning' in script
|
||||
assert '靠近读卡器后' in script
|
||||
assert '感应玩具 NFC' in script
|
||||
assert 'api("nfc/status")' in script
|
||||
assert 'function createToyFromNfc()' in script
|
||||
assert 'function bindCardToDevice(device, cardUid)' in script
|
||||
assert 'function importLegacyProfiles(value)' in script
|
||||
assert 'N7WEB_REQUEST_IR_TOY_PROFILES' in script
|
||||
assert 'IR_TOY_LEGACY_PROFILES' in script
|
||||
assert 'value.legacy_profiles' in script
|
||||
assert 'value.legacy_bridge_addresses' in script
|
||||
assert 'cardUid: normalizeCardUid(cardUid)' in script
|
||||
assert 'data-nfc-run-capability' in script
|
||||
assert 'data-nfc-learn-capability' in script
|
||||
assert 'data-nfc-relearn-capability' in script
|
||||
assert '重新学习' in script
|
||||
assert 'const targetSlot = relearning ? Number(capability.slot) : allocateSlot()' in script
|
||||
assert 'sendGatewayCommand("read", { slot: learning.draft.slot })' in script
|
||||
assert 'function infraredSignalFromResponse(value)' in script
|
||||
assert 'function infraredFingerprint(signal)' in script
|
||||
assert '学习回执成功,但物理槽位回读为空' in script
|
||||
assert 'signalSource: "n7web"' in script
|
||||
assert 'if (capability.signalSource === "n7web") return' in script
|
||||
assert '建立档案并开始学习' in script
|
||||
assert 'const activeCatalog = sensedCardUid' in script
|
||||
assert 'normalizeCardUid(item.card_uid) === sensedCardUid' in script
|
||||
assert '&& item.status === "learned"' in script
|
||||
assert 'slot: capability.slot' in script
|
||||
assert '当前未感应到外设' in script
|
||||
assert '将已绑定且已学习的 NFC 外设靠近读卡器后显示能力' in script
|
||||
|
||||
assert '.v2-nfc-inline' in styles
|
||||
assert '.v2-nfc-dialog' in styles
|
||||
assert '.v2-nfc-capability-grid' in styles
|
||||
assert 'self-extension.js?v=nfc-toy-33' in html
|
||||
assert 'self-extension.css?v=nfc-toy-33' in html
|
||||
|
||||
|
||||
def test_server_exposes_nfc_snapshot_through_same_origin_extension_api() -> None:
|
||||
server = (ROOT / "src" / "cognitive_agent" / "server.py").read_text(encoding="utf-8")
|
||||
|
||||
assert 'nfc = NfcReaderService()' in server
|
||||
assert 'path == "/api/extension/nfc/status"' in server
|
||||
assert '"nfc": self.nfc.snapshot()' in server
|
||||
assert 'SeatDemoHandler.nfc.start()' in server
|
||||
assert 'SeatDemoHandler.nfc.close()' in server
|
||||
assert "frame-src 'self' http://*:3001" in server
|
||||
Reference in New Issue
Block a user