Skip to content

Commit 87d55e6

Browse files
NullVoxPopuliclaude
andcommitted
test: add failing tests for dynamic component names in debugRenderTree
Add tests for: - <this.dynamicComponent> invocations - <@argComponent> invocations Both currently produce '(unknown template-only component)' instead of the expected component name because dynamic resolution at runtime loses the invocation-site name information. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 497f868 commit 87d55e6

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

packages/@glimmer-workspace/integration-tests/test/debug-render-tree-test.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,56 @@ class DebugRenderTreeTest extends RenderTest {
142142
]);
143143
}
144144

145+
@test 'dynamic component via <this.dynamicComponent>'() {
146+
const HelloWorld = defComponent('{{@arg}}');
147+
148+
class Root extends GlimmerishComponent {
149+
HelloWorld = HelloWorld;
150+
}
151+
152+
const RootDef = defComponent(`<this.HelloWorld @arg="first"/>`, {
153+
component: Root,
154+
emit: { moduleName: 'root.hbs' },
155+
});
156+
157+
this.renderComponent(RootDef);
158+
159+
const rootChildren = this.delegate.getCapturedRenderTree()[0]?.children ?? [];
160+
const componentNode = rootChildren.find(
161+
(n: CapturedRenderNode) => n.type === 'component' && n.name !== '{ROOT}'
162+
);
163+
164+
this.assert.ok(componentNode, 'found a component child node');
165+
166+
this.assert.strictEqual(
167+
componentNode?.name,
168+
'HelloWorld',
169+
`dynamic <this.X> component name (got "${componentNode?.name}")`
170+
);
171+
}
172+
173+
@test 'dynamic component via <@argComponent>'() {
174+
const HelloWorld = defComponent('{{@arg}}');
175+
const Root = defComponent(`<@Greeting @arg="first"/>`, {
176+
emit: { moduleName: 'root.hbs' },
177+
});
178+
179+
this.renderComponent(Root, { Greeting: HelloWorld });
180+
181+
const rootChildren = this.delegate.getCapturedRenderTree()[0]?.children ?? [];
182+
const componentNode = rootChildren.find(
183+
(n: CapturedRenderNode) => n.type === 'component' && n.name !== '{ROOT}'
184+
);
185+
186+
this.assert.ok(componentNode, 'found a component child node');
187+
188+
this.assert.strictEqual(
189+
componentNode?.name,
190+
'HelloWorld',
191+
`dynamic <@X> component name (got "${componentNode?.name}")`
192+
);
193+
}
194+
145195
@test 'strict-mode modifiers'() {
146196
const state = trackedObj({ showSecond: false });
147197

0 commit comments

Comments
 (0)