feat: add analytics date dimension bindings
Some checks failed
CI / verify (push) Has been cancelled
Some checks failed
CI / verify (push) Has been cancelled
- lock profile task tracking scope to user - add analytics date dimension module support and tests - regenerate SpacetimeDB Rust bindings with private APIs
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
use serde_json::json;
|
||||
use shared_contracts::runtime::{
|
||||
AdminUpsertProfileTaskConfigRequest, ProfileTaskConfigAdminResponse, TRACKING_SCOPE_KIND_USER,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn admin_upsert_profile_task_config_keeps_personal_task_scope_user() {
|
||||
let request: AdminUpsertProfileTaskConfigRequest = serde_json::from_value(json!({
|
||||
"taskId": "daily_login",
|
||||
"title": "每日登录",
|
||||
"description": "",
|
||||
"eventKey": "daily_login",
|
||||
"cycle": "daily",
|
||||
"scopeKind": "user",
|
||||
"threshold": 1,
|
||||
"rewardPoints": 10,
|
||||
"enabled": true,
|
||||
"sortOrder": 10
|
||||
}))
|
||||
.expect("个人任务配置请求应接受 user scope");
|
||||
|
||||
assert_eq!(request.scope_kind, TRACKING_SCOPE_KIND_USER);
|
||||
|
||||
let value = serde_json::to_value(request).expect("个人任务配置请求应可序列化");
|
||||
assert_eq!(value["scopeKind"], json!(TRACKING_SCOPE_KIND_USER));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn profile_task_config_admin_response_serializes_scope_kind_as_user() {
|
||||
let response = ProfileTaskConfigAdminResponse {
|
||||
task_id: "daily_login".to_string(),
|
||||
title: "每日登录".to_string(),
|
||||
description: "".to_string(),
|
||||
event_key: "daily_login".to_string(),
|
||||
cycle: "daily".to_string(),
|
||||
scope_kind: TRACKING_SCOPE_KIND_USER.to_string(),
|
||||
threshold: 1,
|
||||
reward_points: 10,
|
||||
enabled: true,
|
||||
sort_order: 10,
|
||||
created_by: "admin".to_string(),
|
||||
created_at: "2026-05-04T00:00:00Z".to_string(),
|
||||
updated_by: "admin".to_string(),
|
||||
updated_at: "2026-05-04T00:00:00Z".to_string(),
|
||||
};
|
||||
|
||||
let value = serde_json::to_value(response).expect("个人任务配置响应应可序列化");
|
||||
assert_eq!(value["scopeKind"], json!(TRACKING_SCOPE_KIND_USER));
|
||||
assert_eq!(value["taskId"], json!("daily_login"));
|
||||
assert_eq!(value["rewardPoints"], json!(10));
|
||||
}
|
||||
Reference in New Issue
Block a user