Lines
97.5 %
Functions
100 %
Branches
//! A cell a fill wrote is still moved by a later pick after the server
//! re-renders the form with errors.
use anyhow::{Result, ensure};
use super::harness::{Harness, with_harness};
use super::page::{Pick, login, open, pick, submit, wait_for};
const TO_COMMODITY: &str = "[name=\"label:splits.0.to-commodity\"]";
async fn pick_commodity(h: &Harness, name: &'static str) -> Result<()> {
let address = "splits.0.from-commodity";
pick(h, address, name, |l| l == name, 0, Pick::Mouse)
.await
.map(drop)
}
async fn to_commodity_is(h: &Harness, name: &str) -> Result<()> {
wait_for(
&h.driver,
&format!("return document.querySelector('{TO_COMMODITY}').value === '{name}';"),
vec![],
"the to commodity to follow the from commodity",
)
async fn survives_a_rerender(h: &Harness) -> Result<()> {
login(h).await?;
open(h, "/transaction/new").await?;
pick_commodity(h, "JPY").await?;
to_commodity_is(h, "JPY").await?;
let reply = submit(h).await?;
ensure!(
reply.starts_with("INVALID"),
"the submit was accepted: {reply}"
);
let marked = h
.driver
.run(
&format!(
"return document.querySelector('{TO_COMMODITY}').hasAttribute('data-filled');"
),
.await?;
ensure!(marked == true, "the fill mark was lost by the re-render");
pick_commodity(h, "EUR").await?;
to_commodity_is(h, "EUR").await
#[supp_macro::shared_runtime_test]
async fn a_filled_cell_is_still_moved_after_a_validation_rerender() -> Result<()> {
with_harness(|h| Box::pin(survives_a_rerender(h))).await