resolve test: anchors follow expanded ids

This commit is contained in:
Meta Vens 2026-11-27 23:39:37 +01:00
commit 14747c94f7

View file

@ -597,3 +597,29 @@ fn resolve_reads_only_through_read() {
let _: &dyn StatePort = &state;
});
}
#[test]
fn an_anchor_in_a_body_follows_the_expanded_ids() {
big(|| {
let overlay = |anchor: &str| {
Node::Overlay(OverlayNode {
common: common("pop"),
anchor: Anchor::Node(AnchorNode { node: nid(anchor) }),
modal: false,
dismiss: CommandRef::Param(param("dismiss")),
children: vec![],
})
};
let body = boxed("b", vec![text("target", "t"), overlay("target"), {
let Node::Overlay(root_anchored) = overlay("b") else { unreachable!() };
Node::Overlay(OverlayNode { common: common("pop-root"), ..root_anchored })
}]);
let document = surface(boxed("root", vec![use_of("u", "c", vec![command_arg("dismiss", "real")])]), &["real"]);
let resolution = run(&document, &state_with(&[composition("c", &[("dismiss", ParamKind::Command)], body)]));
assert_eq!(resolution.diagnostics, vec![]);
for (id, target) in [("u/pop", "u/target"), ("u/pop-root", "u")] {
let Node::Overlay(found) = node_of(&resolution, id) else { panic!("not an Overlay") };
assert_eq!(found.anchor, Anchor::Node(AnchorNode { node: nid(target) }), "{id}");
}
});
}