Lines
91.67 %
Functions
85.71 %
Branches
100 %
//! Saving a tag twice from one edit page: the second save must not be stale.
use anyhow::{Result, anyhow, ensure};
use server::command::{CmdResult, tag::CreateTag};
use uuid::Uuid;
use super::harness::{Harness, with_harness};
use super::page::{login, open, set_text, submit};
async fn tag(h: &Harness) -> Result<Uuid> {
let created = CreateTag::new()
.user_id(h.tenant.id)
.name("kind".to_string())
.value("fiat".to_string())
.run()
.await
.map_err(|e| anyhow!("{e:?}"))?;
match created {
Some(CmdResult::Uuid(id)) => Ok(id),
other => Err(anyhow!("unexpected create result {other:?}")),
}
async fn save_twice(h: &Harness) -> Result<()> {
let id = tag(h).await?;
login(h).await?;
open(h, &format!("/tag/edit/{id}")).await?;
for value in ["crypto", "stock"] {
set_text(h, "value", value).await?;
let reply = submit(h).await?;
ensure!(reply.starts_with("Tag updated"), "{reply}");
Ok(())
#[supp_macro::shared_runtime_test]
async fn a_second_tag_save_from_the_same_page_is_not_stale() -> Result<()> {
with_harness(|h| Box::pin(save_twice(h))).await