Skip to content

Commit fe6e097

Browse files
committed
feat: ignore workflows that are not enabled
1 parent 4ec43f7 commit fe6e097

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/__tests__/cli-commands.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,32 @@ describe('CLI Commands', () => {
432432
expect(result.messages).toHaveLength(3) // Header + 2 workflow items
433433
})
434434

435+
it('should handle disabled workflows', async () => {
436+
// Add a second workflow item
437+
const secondWorkflow = {
438+
...mockWorkflows[0],
439+
id: 'create-stuff',
440+
description: 'Another workflow description',
441+
isEnabled: false
442+
}
443+
mockWorkflows.push(secondWorkflow)
444+
445+
// Mock API call
446+
nock('http://localhost:3000')
447+
.get('/api/v1/workflow')
448+
.reply(200, mockWorkflows)
449+
450+
// Execute the function
451+
const result = await printWorkflows()
452+
453+
// Verify the result
454+
expect(result.success).toBe(true)
455+
expect(result.messages[0]).toBe('Compliance workflows available:')
456+
expect(result.messages[1]).toContain(mockWorkflows[0].id)
457+
expect(result.messages[1]).toContain(mockWorkflows[0].description)
458+
expect(result.messages).toHaveLength(2) // Header + 1 enabled workflow item
459+
})
460+
435461
it('should handle API errors gracefully', async () => {
436462
// Mock API error
437463
nock('http://localhost:3000')

src/cli-commands.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ export const printWorkflows = async (): Promise<CommandResult> => {
125125
}
126126
messages.push('Compliance workflows available:')
127127
workflows.forEach((workflow) => {
128-
messages.push(`- ${workflow.id}: ${workflow.description}`)
128+
if (workflow.isEnabled) {
129+
messages.push(`- ${workflow.id}: ${workflow.description}`)
130+
}
129131
})
130132
} catch (error) {
131133
messages.push(`❌ Failed to retrieve compliance workflow items: ${error instanceof Error ? error.message : 'Unknown error'}`)

0 commit comments

Comments
 (0)