Skip to content

Commit 497f868

Browse files
NullVoxPopuliclaude
andcommitted
fix: flatten render tree when checking component names in smoke test
The captureRenderTree API returns a nested tree structure. Component nodes are children of other nodes, so we need to recursively flatten the tree before searching for component names. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5e7eeda commit 497f868

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

smoke-tests/scenarios/basic-test.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,17 @@ function basicTest(scenarios: Scenarios, appName: string) {
230230
import { captureRenderTree } from '@ember/debug';
231231
import Component from '@glimmer/component';
232232
233+
function flattenTree(nodes) {
234+
let result = [];
235+
for (let node of nodes) {
236+
result.push(node);
237+
if (node.children) {
238+
result.push(...flattenTree(node.children));
239+
}
240+
}
241+
return result;
242+
}
243+
233244
class HelloWorld extends Component {
234245
<template>{{@arg}}</template>
235246
}
@@ -241,7 +252,8 @@ function basicTest(scenarios: Scenarios, appName: string) {
241252
await render(<template><HelloWorld @arg="first" /></template>);
242253
243254
let tree = captureRenderTree(this.owner);
244-
let names = tree.filter(n => n.type === 'component').map(n => n.name);
255+
let allNodes = flattenTree(tree);
256+
let names = allNodes.filter(n => n.type === 'component').map(n => n.name);
245257
assert.true(names.includes('HelloWorld'), 'HelloWorld component name is preserved in the render tree (found: ' + names.join(', ') + ')');
246258
});
247259
});

0 commit comments

Comments
 (0)