阶段4验证埋点持久化与后台读取
Project CI / Repository checks (pull_request) Has been cancelled
Project CI / Frontend tests (pull_request) Has been cancelled
Project CI / Backend tests (pull_request) Has been cancelled
Project CI / Native shell tests (pull_request) Has been cancelled

补充 tracking draft、runtime input 和 outbox round-trip 验证

覆盖 SpacetimeDB mapper 与 metadata object 校验

补充账号态和 External API Key 后台 tracking readback 回归
This commit is contained in:
2026-09-02 10:17:59 +00:00
parent 01159a2698
commit c75c61521d
5 changed files with 372 additions and 5 deletions
@@ -1643,4 +1643,55 @@ mod tests {
})
);
}
#[test]
fn tracking_input_normalizes_and_preserves_agc_metadata_and_owner() {
let input = build_runtime_tracking_event_input(
"event-225".to_string(),
"editor_image_generation_submit".to_string(),
RuntimeTrackingScopeKind::User,
"owner-225".to_string(),
None,
Some("owner-225".to_string()),
None,
Some("editor".to_string()),
r#" { "route": "/api/external/v1/editor/images/generations", "client": "agc" } "#
.to_string(),
1_756_800_000_000_000,
)
.expect("tracking input should accept object metadata");
assert_eq!(input.event_id, "event-225");
assert_eq!(input.scope_id, "owner-225");
assert_eq!(input.owner_user_id.as_deref(), Some("owner-225"));
assert_eq!(input.user_id, None);
assert_eq!(input.module_key.as_deref(), Some("editor"));
assert_eq!(
serde_json::from_str::<Value>(&input.metadata_json)
.expect("normalized metadata should parse"),
serde_json::json!({
"route": "/api/external/v1/editor/images/generations",
"client": "agc",
})
);
}
#[test]
fn tracking_input_rejects_non_object_metadata() {
let error = build_runtime_tracking_event_input(
"event-225-invalid".to_string(),
"editor_projects_view".to_string(),
RuntimeTrackingScopeKind::User,
"user-225".to_string(),
Some("user-225".to_string()),
Some("user-225".to_string()),
None,
Some("editor".to_string()),
r#"["not-an-object"]"#.to_string(),
1_756_800_000_000_000,
)
.expect_err("tracking metadata must remain an object");
assert_eq!(error, RuntimeProfileFieldError::InvalidInviteCodeMetadata);
}
}