From 14747c94f7bdc9245fb54e73a84b53c0c28955bf Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Fri, 27 Nov 2026 23:39:37 +0100 Subject: [PATCH] resolve test: anchors follow expanded ids --- crates/thing-core/tests/resolve.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/crates/thing-core/tests/resolve.rs b/crates/thing-core/tests/resolve.rs index 6980979..373b347 100644 --- a/crates/thing-core/tests/resolve.rs +++ b/crates/thing-core/tests/resolve.rs @@ -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}"); + } + }); +}