|
| 1 | +use serde_json::Value; |
1 | 2 | use wp_api::{
|
2 |
| - JsonValue, |
3 | 3 | comments::{
|
4 | 4 | CommentId, CommentListParams, CommentRetrieveParams, CommentStatus, CommentType,
|
5 | 5 | SparseCommentFieldWithEditContext, SparseCommentFieldWithEmbedContext,
|
6 | 6 | SparseCommentFieldWithViewContext, WpApiParamCommentsOrderBy,
|
7 | 7 | },
|
8 | 8 | posts::PostId,
|
9 | 9 | users::UserAvatarSize,
|
| 10 | + wp_com::{WpComBaseUrl, endpoint::WpComDotOrgApiUrlResolver}, |
10 | 11 | };
|
11 |
| -use wp_api_integration_tests::prelude::*; |
| 12 | +use wp_api_integration_tests::{WpComTestCredentials, prelude::*}; |
12 | 13 |
|
13 | 14 | #[tokio::test]
|
14 | 15 | #[apply(list_cases)]
|
@@ -217,14 +218,64 @@ async fn parse_extras() {
|
217 | 218 | .await
|
218 | 219 | .assert_response()
|
219 | 220 | .data;
|
220 |
| - match comment.extras { |
221 |
| - JsonValue::Object(ref map) => { |
| 221 | + match comment.additional_fields.raw { |
| 222 | + Value::Object(ref map) => { |
222 | 223 | assert!(map.contains_key("_links"));
|
223 | 224 | }
|
224 | 225 | _ => panic!("Expected extras to be an object"),
|
225 | 226 | }
|
226 | 227 | }
|
227 | 228 |
|
| 229 | +#[tokio::test] |
| 230 | +#[parallel] |
| 231 | +#[ignore] |
| 232 | +async fn wpcom_comment_extension() { |
| 233 | + // You'll need to replace the site ID and comment ID with valid ones. |
| 234 | + let site_id = "site_id".to_string(); |
| 235 | + let comment_id = CommentId(2); |
| 236 | + let client = WpApiClient::new( |
| 237 | + Arc::new(WpComDotOrgApiUrlResolver::new( |
| 238 | + site_id, |
| 239 | + WpComBaseUrl::Production, |
| 240 | + )), |
| 241 | + WpApiClientDelegate { |
| 242 | + auth_provider: Arc::new(WpAuthenticationProvider::static_with_auth( |
| 243 | + WpAuthentication::Bearer { |
| 244 | + token: WpComTestCredentials::instance().bearer_token.to_string(), |
| 245 | + }, |
| 246 | + )), |
| 247 | + request_executor: Arc::new(ReqwestRequestExecutor::default()), |
| 248 | + middleware_pipeline: Arc::new(WpApiMiddlewarePipeline::default()), |
| 249 | + app_notifier: Arc::new(EmptyAppNotifier), |
| 250 | + }, |
| 251 | + ); |
| 252 | + use wp_api::wp_com::endpoint::extensions::comments::WpComCommentExtensionProvider; |
| 253 | + |
| 254 | + let comment = client |
| 255 | + .comments() |
| 256 | + .retrieve_with_view_context(&comment_id, &CommentRetrieveParams::default()) |
| 257 | + .await |
| 258 | + .assert_response() |
| 259 | + .data; |
| 260 | + assert!(comment.additional_fields.parse_extension().is_ok()); |
| 261 | + |
| 262 | + let comment = client |
| 263 | + .comments() |
| 264 | + .retrieve_with_edit_context(&comment_id, &CommentRetrieveParams::default()) |
| 265 | + .await |
| 266 | + .assert_response() |
| 267 | + .data; |
| 268 | + assert!(comment.additional_fields.parse_extension().is_ok()); |
| 269 | + |
| 270 | + let comment = client |
| 271 | + .comments() |
| 272 | + .retrieve_with_embed_context(&comment_id, &CommentRetrieveParams::default()) |
| 273 | + .await |
| 274 | + .assert_response() |
| 275 | + .data; |
| 276 | + assert!(comment.additional_fields.parse_extension().is_ok()); |
| 277 | +} |
| 278 | + |
228 | 279 | #[template]
|
229 | 280 | #[rstest]
|
230 | 281 | #[case::default(CommentListParams::default())]
|
|
0 commit comments