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