fix(web): unify mode previews and label window positions
This commit is contained in:
@@ -204,7 +204,7 @@ def test_default_bundle_rows_show_each_passenger_action_separately(render_rows):
|
||||
|
||||
assert [(row["label"], row["value"]) for row in rows] == [
|
||||
("空调电源", "开启"),
|
||||
("主驾车窗", "完全关闭(目标开度 0%)"),
|
||||
("左前车窗(主驾)", "完全关闭(目标开度 0%)"),
|
||||
("副驾座椅通风", "开启 · 1档"),
|
||||
("副驾靠背位置", "45%"),
|
||||
("副驾腿托位置", "35%"),
|
||||
@@ -227,3 +227,55 @@ def test_cinema_draft_shows_all_four_axes_and_ventilation(render_rows):
|
||||
("副驾腿托位置", "53%"),
|
||||
("副驾座椅通风", "关闭"),
|
||||
]
|
||||
|
||||
|
||||
def test_collapsible_preview_keeps_all_actions_and_identifies_each_window():
|
||||
node = shutil.which("node")
|
||||
assert node
|
||||
source = (ROOT / "apps/web-console/assistant-chat.js").read_text(encoding="utf-8")
|
||||
start = source.index(" const assistantControlLabels =")
|
||||
end = source.index(" function focusLatestDispatchedControls", start)
|
||||
actions = [
|
||||
action("seat.set_longitudinal_position", {"position_pct": 51}, "passenger"),
|
||||
action("seat.set_cushion_tilt", {"position_pct": 30}, "passenger"),
|
||||
action("seat.set_backrest_recline", {"position_pct": 44}, "passenger"),
|
||||
action("seat.set_legrest_height", {"position_pct": 53}, "passenger"),
|
||||
action("seat.set_ventilation", {"state": "off"}, "passenger"),
|
||||
*(action("window.set_position", {"position_pct": value}, zone)
|
||||
for zone, value in [("front_left", 0), ("front_right", 50),
|
||||
("rear_left", 100), ("rear_right", 0)]),
|
||||
action("climate.set_power", {"state": "on"}, "vehicle"),
|
||||
action("ambient_light.set_power", {"state": "on"}, "vehicle"),
|
||||
]
|
||||
payload = {
|
||||
"execution_mode": "dry_run", "mode_profile_draft": {"name": "浪漫影院模式"},
|
||||
"actions": actions,
|
||||
# IDs can collide across domains, and seat display projections may be absent.
|
||||
"validated_control_commands": [{
|
||||
"operation": {**operation, "id": "shared-operation-id"},
|
||||
"actual_command": f"command-{index}",
|
||||
} for index, operation in enumerate(actions[5:])],
|
||||
}
|
||||
script = "const window = {};\n" + source[start:end] + "\n" + r'''
|
||||
const payload = JSON.parse(require('node:fs').readFileSync(0, 'utf8'));
|
||||
const show = (value) => assistantDispatchedCommands(value).map(item => ({
|
||||
label: item.category, value: assistantControlValue(item), command: item.command,
|
||||
}));
|
||||
const preview = show(payload);
|
||||
delete payload.validated_control_commands;
|
||||
console.log(JSON.stringify({preview, withoutProjections: show(payload)}));
|
||||
'''
|
||||
output = subprocess.run([node, "-e", script], input=json.dumps(payload),
|
||||
check=True, capture_output=True, text=True, encoding="utf-8")
|
||||
results = json.loads(output.stdout)
|
||||
for rows in (results["preview"], results["withoutProjections"]):
|
||||
assert len(rows) == len(actions)
|
||||
assert [row["value"] for row in rows[:5]] == ["51%", "30%", "44%", "53%", "关闭"]
|
||||
assert [(row["label"], row["value"]) for row in rows[5:9]] == [
|
||||
("左前车窗(主驾)", "0%(完全关闭)"), ("右前车窗(副驾)", "50%"),
|
||||
("左后车窗", "100%(完全打开)"), ("右后车窗", "0%(完全关闭)"),
|
||||
]
|
||||
assert [row["label"] for row in rows[-2:]] == ["空调电源", "氛围灯"]
|
||||
assert [row["command"] for row in results["preview"][5:]] == [
|
||||
f"command-{index}" for index in range(6)
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user