Lines
100 %
Functions
Branches
//! The lossless fixture for create (plan 0016 W5): the entry posted through
//! the web form stores what the same entry stores through `rpc::forms::submit`.
use forms::{FormValues, TRANSACTION_CREATE};
use crate::common::new_page::{
Ids, created_id, post_form, seeded_ids, seeded_user, snapshot, without_entered,
};
fn entry(ids: &Ids) -> Vec<(&str, &str)> {
vec![
("date", "2026-10-27T09:15:42.123456Z"),
("note", "first line\r\nsecond \"quoted\" back\\slash"),
("tags", ""),
("tags.0.name", "trip"),
("tags.0.value", "japan"),
("tags.0.description", "spring \"trip\" \\ notes\nday two"),
("tags.1.name", "cleared"),
("tags.1.value", "yes"),
("tags.1.description", ""),
("splits", ""),
("splits.0.key", "n1"),
("splits.0.from", &ids.checking),
("splits.0.to", &ids.food),
("splits.0.from-commodity", &ids.usd),
("splits.0.to-commodity", &ids.eur),
("splits.0.value", "10"),
("splits.0.to-amount", "9"),
("splits.0.hidden", ""),
("splits.1.key", "n2"),
("splits.1.from", &ids.checking),
("splits.1.to", &ids.food),
("splits.1.from-commodity", &ids.usd),
("splits.1.value", "1/3"),
("splits.1.hidden", ""),
("split-tags", ""),
("split-tags.0.row", "n1"),
("split-tags.0.name", "memo"),
("split-tags.0.value", "m\\x"),
("split-tags.0.description", "split memo\nsecond line"),
("split-tags.1.row", "n2"),
("split-tags.1.name", "category"),
("split-tags.1.value", "food"),
]
}
#[supp_macro::shared_runtime_test]
async fn a_web_create_stores_what_the_rpc_submit_stores() {
let user = seeded_user().await;
let ids = seeded_ids(&user).await;
let entry = entry(&ids);
let posted = post_form(&user, &entry).await;
let pairs = entry
.iter()
.map(|(n, v)| ((*n).to_string(), (*v).to_string()));
let values = FormValues::from_pairs(&TRANSACTION_CREATE, pairs).expect("pairs");
let submitted = rpc::forms::submit(user.id, &TRANSACTION_CREATE, &values)
.await
.expect("rpc submit");
let web = snapshot(&user, created_id(&posted)).await;
let rpc = snapshot(&user, submitted.id).await;
assert!(web.iter().any(|f| f.starts_with("price ")), "{web:?}");
assert!(
web.iter()
.any(|f| f == "tag note first line\nsecond \"quoted\" back\\slash -"),
"{web:?}"
);
assert_eq!(without_entered(web), without_entered(rpc));