diff --git a/Cargo.lock b/Cargo.lock index ac0434c..731f292 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1543,6 +1543,7 @@ version = "1.0.150" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8014e44b4736ed0538adeecded0fce2a272f22dc9578a7eb6b2d9993c74cfb9" dependencies = [ + "indexmap", "itoa", "memchr", "serde", diff --git a/Cargo.toml b/Cargo.toml index e7229da..433ccbb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ hex = "0.4.3" regex = "1.12.2" rusqlite = { version = "0.32.1", features = ["bundled"] } serde = { version = "1.0.228", features = ["derive"] } -serde_json = "1.0.132" +serde_json = { version = "1.0.132", features = ["preserve_order"] } sha3 = "0.10.8" tempfile = "3.13.0" tokio = { version = "1.41.1", features = ["macros", "rt-multi-thread", "net", "fs", "io-util"] } diff --git a/crates/archivr-core/src/summarizer.rs b/crates/archivr-core/src/summarizer.rs index 21d9ff4..6b1741c 100644 --- a/crates/archivr-core/src/summarizer.rs +++ b/crates/archivr-core/src/summarizer.rs @@ -1274,6 +1274,23 @@ mod tests { ); } + #[test] + fn extract_tweet_text_keeps_article_block_object_field_order() { + let tweet: serde_json::Value = serde_json::from_str( + r#"{ + "article": { + "title": "Ordered block", + "blocks": [{"heading": "Opening", "content": "Body copy"}] + } + }"#, + ) + .unwrap(); + assert_eq!( + extract_tweet_text(&tweet).as_deref(), + Some("Ordered block\n\nOpening\n\nBody copy") + ); + } + #[test] fn extract_tweet_text_falls_back_from_article_preview_to_summary_then_tweet_body() { let preview = serde_json::json!({