mirror of
https://github.com/thegeneralist01/archivr
synced 2026-10-09 12:55:00 +02:00
fix: preserve X Article block order
This commit is contained in:
parent
b17db8d04a
commit
55a74ea3c2
3 changed files with 19 additions and 1 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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"] }
|
||||
|
|
|
|||
|
|
@ -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!({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue