1
//! Saving a commodity twice from one edit page: the second save must not be stale.
2

            
3
use anyhow::{Result, ensure};
4

            
5
use super::harness::{Harness, with_harness};
6
use super::page::{login, open, set_text, submit};
7

            
8
1
async fn save_twice(h: &Harness) -> Result<()> {
9
1
    login(h).await?;
10
1
    open(h, &format!("/commodity/{}/edit", h.commodity("JPY"))).await?;
11
1
    for name in ["Yen one", "Yen two"] {
12
2
        set_text(h, "name", name).await?;
13
2
        let reply = submit(h).await?;
14
2
        ensure!(reply.starts_with("Commodity updated with ID"), "{reply}");
15
    }
16
1
    Ok(())
17
1
}
18

            
19
#[supp_macro::shared_runtime_test]
20
1
async fn a_second_save_from_the_same_page_is_not_stale() -> Result<()> {
21
1
    with_harness(|h| Box::pin(save_twice(h))).await
22
}