Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

test(cli): read Avatar initials from generated-content attribute (#10934)

astracat-bot[bot]706fc0306bed
diff --git a/packages/cli/api/render/render.test.mjs b/packages/cli/api/render/render.test.mjs
index 1972df884c..aae01c9496 100644
--- a/packages/cli/api/render/render.test.mjs
+++ b/packages/cli/api/render/render.test.mjs
@@ -1512,7 +1512,8 @@ export default function Page() {
async function initialsOf(name) {
await render(`initials/${name}.tsx`, {cwd: dir});
const html = fs.readFileSync(path.join(dir, 'initials', `${name}.html`), 'utf8');
- return [...html.matchAll(/<div data-name="\d+">([\s\S]*?)(?=<div data-name=|<\/main>)/g)].map(m => m[1].replace(/<[^>]+>/g, ''));
+ // Generated content draws the initials from this attribute, not a text node.
+ return [...html.matchAll(/<div data-name="\d+">([\s\S]*?)(?=<div data-name=|<\/main>)/g)].map(m => /\bdata-initials="([^"]*)"/.exec(m[1])?.[1] ?? '');
}
// On a Node build that crashes in Intl.Segmenter, both renders run without it.