this repo has no description
1mod common; 2 3use common::{base_url, client, create_account_and_login}; 4use reqwest::StatusCode; 5use serde_json::{json, Value}; 6 7#[tokio::test] 8async fn test_get_author_feed_returns_appview_data() { 9 let client = client(); 10 let base = base_url().await; 11 let (jwt, did) = create_account_and_login(&client).await; 12 let res = client 13 .get(format!( 14 "{}/xrpc/app.bsky.feed.getAuthorFeed?actor={}", 15 base, did 16 )) 17 .header("Authorization", format!("Bearer {}", jwt)) 18 .send() 19 .await 20 .unwrap(); 21 assert_eq!(res.status(), StatusCode::OK); 22 let body: Value = res.json().await.unwrap(); 23 assert!(body["feed"].is_array(), "Response should have feed array"); 24 let feed = body["feed"].as_array().unwrap(); 25 assert_eq!(feed.len(), 1, "Feed should have 1 post from appview"); 26 assert_eq!( 27 feed[0]["post"]["record"]["text"].as_str(), 28 Some("Author feed post from appview"), 29 "Post text should match appview response" 30 ); 31} 32 33#[tokio::test] 34async fn test_get_actor_likes_returns_appview_data() { 35 let client = client(); 36 let base = base_url().await; 37 let (jwt, did) = create_account_and_login(&client).await; 38 let res = client 39 .get(format!( 40 "{}/xrpc/app.bsky.feed.getActorLikes?actor={}", 41 base, did 42 )) 43 .header("Authorization", format!("Bearer {}", jwt)) 44 .send() 45 .await 46 .unwrap(); 47 assert_eq!(res.status(), StatusCode::OK); 48 let body: Value = res.json().await.unwrap(); 49 assert!(body["feed"].is_array(), "Response should have feed array"); 50 let feed = body["feed"].as_array().unwrap(); 51 assert_eq!(feed.len(), 1, "Feed should have 1 liked post from appview"); 52 assert_eq!( 53 feed[0]["post"]["record"]["text"].as_str(), 54 Some("Liked post from appview"), 55 "Post text should match appview response" 56 ); 57} 58 59#[tokio::test] 60async fn test_get_post_thread_returns_appview_data() { 61 let client = client(); 62 let base = base_url().await; 63 let (jwt, did) = create_account_and_login(&client).await; 64 let res = client 65 .get(format!( 66 "{}/xrpc/app.bsky.feed.getPostThread?uri=at://{}/app.bsky.feed.post/test123", 67 base, did 68 )) 69 .header("Authorization", format!("Bearer {}", jwt)) 70 .send() 71 .await 72 .unwrap(); 73 assert_eq!(res.status(), StatusCode::OK); 74 let body: Value = res.json().await.unwrap(); 75 assert!(body["thread"].is_object(), "Response should have thread object"); 76 assert_eq!( 77 body["thread"]["$type"].as_str(), 78 Some("app.bsky.feed.defs#threadViewPost"), 79 "Thread should be a threadViewPost" 80 ); 81 assert_eq!( 82 body["thread"]["post"]["record"]["text"].as_str(), 83 Some("Thread post from appview"), 84 "Post text should match appview response" 85 ); 86} 87 88#[tokio::test] 89async fn test_get_feed_returns_appview_data() { 90 let client = client(); 91 let base = base_url().await; 92 let (jwt, _did) = create_account_and_login(&client).await; 93 let res = client 94 .get(format!( 95 "{}/xrpc/app.bsky.feed.getFeed?feed=at://did:plc:test/app.bsky.feed.generator/test", 96 base 97 )) 98 .header("Authorization", format!("Bearer {}", jwt)) 99 .send() 100 .await 101 .unwrap(); 102 assert_eq!(res.status(), StatusCode::OK); 103 let body: Value = res.json().await.unwrap(); 104 assert!(body["feed"].is_array(), "Response should have feed array"); 105 let feed = body["feed"].as_array().unwrap(); 106 assert_eq!(feed.len(), 1, "Feed should have 1 post from appview"); 107 assert_eq!( 108 feed[0]["post"]["record"]["text"].as_str(), 109 Some("Custom feed post from appview"), 110 "Post text should match appview response" 111 ); 112} 113 114#[tokio::test] 115async fn test_register_push_proxies_to_appview() { 116 let client = client(); 117 let base = base_url().await; 118 let (jwt, _did) = create_account_and_login(&client).await; 119 let res = client 120 .post(format!( 121 "{}/xrpc/app.bsky.notification.registerPush", 122 base 123 )) 124 .header("Authorization", format!("Bearer {}", jwt)) 125 .json(&json!({ 126 "serviceDid": "did:web:example.com", 127 "token": "test-push-token", 128 "platform": "ios", 129 "appId": "xyz.bsky.app" 130 })) 131 .send() 132 .await 133 .unwrap(); 134 assert_eq!(res.status(), StatusCode::OK); 135}