mirror of
https://github.com/Tencent/BrowserSkill.git
synced 2026-09-10 13:01:23 +08:00
Lock system.heartbeat wire name with a contract test
The extension emits the literal event string "system.heartbeat"; assert the daemon-side serde name serialises to the same value and round-trips from the exact frame shape the extension sends, so a future rename cannot silently break keepalive and liveness. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -238,6 +238,24 @@ impl<'de> Visitor<'de> for FrameVisitor {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn system_heartbeat_serialises_as_dotted_name() {
|
||||
// The extension hardcodes the literal string "system.heartbeat"
|
||||
// when it emits the keepalive event; this locks the daemon-side
|
||||
// serde name to the same wire value so a rename cannot silently
|
||||
// break liveness/keepalive.
|
||||
let v = serde_json::to_value(EventKind::SystemHeartbeat).unwrap();
|
||||
assert_eq!(v, serde_json::json!("system.heartbeat"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn system_heartbeat_event_frame_round_trips_from_extension_shape() {
|
||||
// Mirrors exactly what the extension sends: { event, payload: {} }.
|
||||
let wire = serde_json::json!({ "event": "system.heartbeat", "payload": {} });
|
||||
let frame: EventFrame = serde_json::from_value(wire).unwrap();
|
||||
assert_eq!(frame.event, EventKind::SystemHeartbeat);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn session_user_interrupt_serialises_as_snake_case() {
|
||||
let v = serde_json::to_value(EventKind::SessionUserInterrupt).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user