use serde_json::json;
use tinyhumans_sdk::TinyHumansClient;
use wiremock::matchers::{method, path};
use wiremock::{Mock, MockServer, ResponseTemplate};
#[tokio::test]
async fn get_latest_announcements_unwraps_envelope() {
let server = MockServer::start().await;
Mock::given(method("GET"))
.and(path("/announcements/latest"))
.respond_with(
ResponseTemplate::new(200).set_body_json(json!({"success": true, "data": {
"id": "a_1",
"title": "Maintenance",
"body": "Scheduled maintenance",
"severity": "INFO",
"cta": null,
"startsAt": null,
"expiresAt": null,
"createdAt": "2026-07-27T00:00:00Z"
}})),
)
.mount(&server)
.await;
let client = TinyHumansClient::new(server.uri());
let result = client
.announcements()
.get_latest_announcements()
.await
.unwrap();
assert_eq!(result.unwrap().id, "a_1");
}