1
//! The web transaction list behaviour W0a pinned, as W7 flipped it.
2

            
3
use axum::http::StatusCode;
4

            
5
use crate::common::list_page::{add, list, listed_notes};
6
use crate::common::new_page::seeded_user;
7

            
8
/// Flipped in W7: an unparseable `from` or `to` was dropped without an error
9
/// and the list was unfiltered; it is now an inline field error.
10
#[supp_macro::shared_runtime_test]
11
1
async fn bad_list_date_filter_is_reported_inline() {
12
1
    let user = seeded_user().await;
13
1
    add(
14
1
        &user,
15
1
        "2020-03-04T05:06:00Z",
16
1
        "needle-note",
17
1
        "Expenses:Food",
18
1
        "5",
19
1
    )
20
1
    .await;
21

            
22
1
    let valid = list(&user, "from=2030-01-01").await;
23
1
    assert_eq!(valid.status, StatusCode::OK, "{}", valid.body);
24
1
    assert!(
25
1
        listed_notes(&valid.body).is_empty(),
26
        "a valid filter must exclude"
27
    );
28

            
29
1
    let bad = list(&user, "from=not-a-date&to=31.31.2020").await;
30
1
    assert_eq!(bad.status, StatusCode::UNPROCESSABLE_ENTITY, "{}", bad.body);
31
1
    assert!(!bad.body.contains("needle-note"), "{}", bad.body);
32
1
    assert_eq!(bad.body.matches("class=\"field-error\"").count(), 2);
33
}