Lines
100 %
Functions
Branches
//! A Reports window counts its own palette lookups: another window's lookup never supersedes them.
use super::report_args::{lookup_ids, options, run};
use super::*;
use crate::tabs::fetch::Fetch;
use crate::tabs::reports::ReportsTab;
fn loading(app: &App, window: WindowId) -> bool {
let state = app.win::<ReportsTab>(window).map(|tab| &tab.state);
matches!(state, Some(Fetch::Loading { .. }))
}
#[tokio::test]
async fn report_lookups_of_two_windows_both_land() {
let mut app = crate::test_support::app();
app.attach_echo();
let first = app.window_of(ViewId::Reports);
run(&mut app, "reports balance target=usd");
let second = app.open_extra(ViewId::Reports);
let ids = lookup_ids(&app);
assert_eq!(ids.len(), 2);
for id in ids {
app.route_reply(id, &options(&["USD"]));
assert!(loading(&app, first));
assert!(loading(&app, second));
async fn a_lookup_reply_runs_the_report_in_its_own_window_not_the_front_one() {
assert_eq!(app.front_window(), Some(second));
app.route_reply(ids[0], &options(&["USD"]));
assert!(loading(&app, first), "the report did not run in its window");
assert!(!loading(&app, second), "the report ran in the front window");