Skip to content

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

TypeScript

test(cli): guard component detail levels and fix import-hint tests (#7146)

Joey69be735f515a
diff --git a/packages/cli/api/component/component.test.mjs b/packages/cli/api/component/component.test.mjs
index cec562c1d3..261b7535c1 100644
--- a/packages/cli/api/component/component.test.mjs
+++ b/packages/cli/api/component/component.test.mjs
@@ -199,3 +199,35 @@ describe('component dispatcher — detail and lang guards', () => {
expect(zh.type).toBe('component.detail');
}, SLOW);
});
+
+describe('component dispatcher — detail levels on single component (text only)', () => {
+ it('--detail compact returns less text than full', async () => {
+ const full = await runCli(['component', 'Button'], cwd);
+ const compact = await runCli(['component', 'Button', '--detail', 'compact'], cwd);
+ expect(full.code).toBe(0);
+ expect(compact.code).toBe(0);
+ expect(compact.stdout.length).toBeLessThan(full.stdout.length);
+ // Compact still shows the name and import
+ expect(compact.stdout).toContain('Button');
+ expect(compact.stdout).toContain('@astryxdesign/core');
+ }, SLOW);
+
+ it('--detail brief returns less text than compact', async () => {
+ const compact = await runCli(['component', 'Button', '--detail', 'compact'], cwd);
+ const brief = await runCli(['component', 'Button', '--detail', 'brief'], cwd);
+ expect(brief.code).toBe(0);
+ expect(brief.stdout.length).toBeLessThan(compact.stdout.length);
+ expect(brief.stdout).toContain('Button');
+ }, SLOW);
+
+ it('--json --detail compact returns the same full JSON as --json (contract)', async () => {
+ const full = await runCli(['--json', 'component', 'Button'], cwd);
+ const compact = await runCli(['--json', 'component', 'Button', '--detail', 'compact'], cwd);
+ expect(full.code).toBe(0);
+ expect(compact.code).toBe(0);
+ const fullData = JSON.parse(full.stdout);
+ const compactData = JSON.parse(compact.stdout);
+ // JSON shape is identical — detail is a text-only projection
+ expect(Object.keys(compactData.data).sort()).toEqual(Object.keys(fullData.data).sort());
+ }, SLOW);
+});
diff --git a/packages/cli/clients/cli/commands/import-hint-correctness.test.mjs b/packages/cli/clients/cli/commands/import-hint-correctness.test.mjs
index faa9f6046b..9fa8bd3906 100644
--- a/packages/cli/clients/cli/commands/import-hint-correctness.test.mjs
+++ b/packages/cli/clients/cli/commands/import-hint-correctness.test.mjs
@@ -85,7 +85,7 @@ describe('import hint correctness', () => {
}
});
- describe('CLI --detail brief shows correct import path', () => {
+ describe('CLI --detail compact shows correct import path', () => {
// Test a representative set across different patterns
const representative = [
{name: 'Button', expected: '@astryxdesign/core/Button'},
@@ -101,8 +101,8 @@ describe('import hint correctness', () => {
];
for (const {name, expected} of representative) {
- it(`npx astryx component ${name} --detail brief shows ${expected}`, async () => {
- const result = await runCli(['component', name, '--detail', 'brief'], REPO_ROOT);
+ it(`npx astryx component ${name} --detail compact shows ${expected}`, async () => {
+ const result = await runCli(['component', name, '--detail', 'compact'], REPO_ROOT);
expect(result.code).toBe(0);
expect(result.stdout).toContain(expected);
});
@@ -179,11 +179,11 @@ describe('import hint correctness', () => {
}
});
- it('component <Name> --detail brief also shows the integration package', async () => {
+ it('component <Name> --detail compact also shows the integration package', async () => {
const fixtureDir = createIntegrationFixture();
try {
const result = await runCli(
- ['component', 'Widget', '--detail', 'brief'],
+ ['component', 'Widget', '--detail', 'compact'],
fixtureDir,
);
expect(result.code).toBe(0);