rho-coding-agent 3.13.0

A fast Rust agent harness with a small footprint and opinionated defaults
Documentation
use super::CardTab;
use pretty_assertions::assert_eq;

// Covers: a browser call's card links the tab it acted on: the current one
// as it started, even when the call moved the current tab elsewhere; the
// one it opened when there was none; the one a new or switched-to tab
// call ends on; and none once that tab closed, as a popup that closed
// itself on a click. Otherwise a card links a tab the call never touched.
// Owner: browser tool card links
#[test]
fn a_card_links_the_tab_the_call_acted_on_while_it_is_open() {
    let open = ["tab-1", "tab-2"];
    let cases = [
        (
            "an act on the current tab",
            CardTab::ActedOn,
            Some("tab-1"),
            Some("tab-1"),
            Some("tab-1"),
        ),
        (
            "a navigate that opened the first tab",
            CardTab::ActedOn,
            None,
            Some("tab-1"),
            Some("tab-1"),
        ),
        (
            "a click that closed its popup",
            CardTab::ActedOn,
            Some("tab-3"),
            Some("tab-1"),
            None,
        ),
        (
            "a call naming its tab",
            CardTab::Named("tab-2".into()),
            Some("tab-1"),
            Some("tab-1"),
            Some("tab-2"),
        ),
        (
            "a new tab",
            CardTab::Current,
            Some("tab-1"),
            Some("tab-2"),
            Some("tab-2"),
        ),
        (
            "a tab list",
            CardTab::Nothing,
            Some("tab-1"),
            Some("tab-1"),
            None,
        ),
    ];
    for (case, card, before, after, expected) in cases {
        assert_eq!(
            card.linked(before, after, |id| open.contains(&id)),
            expected.map(str::to_owned),
            "{case}"
        );
    }
}