From a09bf89701ad4faa4c631d15c5709e4542a58022 Mon Sep 17 00:00:00 2001 From: Lorenz Vanthillo Date: Sun, 23 Aug 2026 21:41:16 +0200 Subject: [PATCH] fix(status): show 'No target configured' instead of empty target label (#985) --- .../commands/status/__tests__/action.test.ts | 30 +++++++++++++++++++ src/cli/commands/status/action.ts | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/cli/commands/status/__tests__/action.test.ts b/src/cli/commands/status/__tests__/action.test.ts index faceb2812..7accf32cc 100644 --- a/src/cli/commands/status/__tests__/action.test.ts +++ b/src/cli/commands/status/__tests__/action.test.ts @@ -941,6 +941,36 @@ describe('handleProjectStatus — live enrichment', () => { }); }); +describe('handleProjectStatus — target resolution', () => { + afterEach(() => vi.clearAllMocks()); + + it('returns undefined targetName when no targets are configured', async () => { + const ctx = { + project: baseProject, + awsTargets: [], + deployedState: { targets: {} }, + } as unknown as StatusContext; + + const result = await handleProjectStatus(ctx); + + assert(result.success); + expect(result.targetName).toBeUndefined(); + }); + + it('returns the configured target name when a target exists', async () => { + const ctx = { + project: baseProject, + awsTargets: [{ name: 'dev', region: 'us-east-1', account: '123456789' }], + deployedState: { targets: {} }, + } as unknown as StatusContext; + + const result = await handleProjectStatus(ctx); + + assert(result.success); + expect(result.targetName).toBe('dev'); + }); +}); + describe('handleProjectStatus — knowledge base enrichment', () => { beforeEach(() => { mockGetKnowledgeBase.mockReset(); diff --git a/src/cli/commands/status/action.ts b/src/cli/commands/status/action.ts index 12bccd24d..6c008a0c9 100644 --- a/src/cli/commands/status/action.ts +++ b/src/cli/commands/status/action.ts @@ -726,7 +726,7 @@ export async function handleProjectStatus( return { success: true, projectName: project.name, - targetName: selectedTargetName ?? '', + targetName: selectedTargetName, targetRegion: targetConfig?.region, resources, deployedState,