Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "resend-cli",
"version": "2.26.0",
"version": "2.26.1",
"description": "The official CLI for Resend",
"license": "MIT",
"repository": {
Expand Down
6 changes: 4 additions & 2 deletions src/commands/automations/runs/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const listAutomationRunsCommand = new Command('list')
)
.action(async (automationIdArg, opts, cmd) => {
const globalOpts = cmd.optsWithGlobals() as GlobalOpts;
const status = opts.status?.replace(/\s+/g, '');
const automationId = await pickId(
automationIdArg,
automationPickerConfig,
Expand All @@ -56,9 +57,9 @@ export const listAutomationRunsCommand = new Command('list')
resend.automations.runs.list({
automationId,
...paginationOpts,
...(opts.status
...(status
? {
status: opts.status as Parameters<
status: status as Parameters<
typeof resend.automations.runs.list
>[0]['status'],
}
Expand All @@ -83,6 +84,7 @@ export const listAutomationRunsCommand = new Command('list')
before: opts.before,
apiKey: globalOpts.apiKey,
profile: globalOpts.profile,
...(status && { extraFlags: `--status ${status}` }),
});
},
},
Expand Down
1 change: 1 addition & 0 deletions src/commands/contacts/imports/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export const listContactImportsCommand = new Command('list')
before: opts.before,
apiKey: globalOpts.apiKey,
profile: globalOpts.profile,
...(opts.status && { extraFlags: `--status ${opts.status}` }),
});
},
},
Expand Down
99 changes: 99 additions & 0 deletions tests/commands/automations/runs/list.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { listAutomationRunsCommand } from '../../../../src/commands/automations/runs/list';
import { captureTestEnv, setupOutputSpies } from '../../../helpers';

const run = {
object: 'automation_run',
id: 'run-1',
status: 'failed',
started_at: '2026-05-15 18:32:37.823+00',
completed_at: '2026-05-15 18:33:42.916+00',
};

const mockList = vi.fn(async () => ({
data: { object: 'list', has_more: false, data: [run] },
error: null,
}));

vi.mock('resend', () => ({
Resend: class MockResend {
constructor(public key: string) {}
automations = { runs: { list: mockList } };
},
}));

describe('automations runs list command', () => {
const restoreEnv = captureTestEnv();

beforeEach(() => {
process.env.RESEND_API_KEY = 're_test_key';
mockList.mockClear();
});

afterEach(() => {
restoreEnv();
});

it('passes --status filter to the SDK', async () => {
setupOutputSpies();

await listAutomationRunsCommand.parseAsync(
['auto-1', '--status', 'failed'],
{ from: 'user' },
);

expect(mockList).toHaveBeenCalledWith({
automationId: 'auto-1',
limit: 10,
status: 'failed',
});
});

it('strips spaces from a comma-separated --status', async () => {
setupOutputSpies();

await listAutomationRunsCommand.parseAsync(
['auto-1', '--status', 'running, failed'],
{ from: 'user' },
);

expect(mockList).toHaveBeenCalledWith({
automationId: 'auto-1',
limit: 10,
status: 'running,failed',
});
});

it.each([
['failed', '--status failed'],
['running, failed', '--status running,failed'],
])('preserves --status %j in the next-page hint', async (status, expected) => {
mockList.mockResolvedValueOnce({
data: { object: 'list', has_more: true, data: [run] },
error: null,
});
// Interactive mode: the hint only prints when TTY and not a CI env.
Object.defineProperty(process.stdin, 'isTTY', {
value: true,
writable: true,
});
Object.defineProperty(process.stdout, 'isTTY', {
value: true,
writable: true,
});
delete process.env.CI;
delete process.env.GITHUB_ACTIONS;
delete process.env.TERM;
const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {});

await listAutomationRunsCommand.parseAsync(['auto-1', '--status', status], {
from: 'user',
});

const output = logSpy.mock.calls.map((c) => c[0]).join('\n');
logSpy.mockRestore();
expect(output).toContain(
`automations runs list auto-1 --after run-1 --limit 10 ${expected}`,
);
});
});
30 changes: 30 additions & 0 deletions tests/commands/contacts/imports/list.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,36 @@ describe('contacts imports list command', () => {
expect(mockList).toHaveBeenCalledWith({ limit: 10, status: 'completed' });
});

it('preserves --status in the next-page hint', async () => {
mockList.mockResolvedValueOnce({
data: { object: 'list', has_more: true, data: [contactImport] },
error: null,
});
// Interactive mode: the hint only prints when TTY and not a CI env.
Object.defineProperty(process.stdin, 'isTTY', {
value: true,
writable: true,
});
Object.defineProperty(process.stdout, 'isTTY', {
value: true,
writable: true,
});
delete process.env.CI;
delete process.env.GITHUB_ACTIONS;
delete process.env.TERM;
const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {});

await listContactImportsCommand.parseAsync(['--status', 'failed'], {
from: 'user',
});

const output = logSpy.mock.calls.map((c) => c[0]).join('\n');
logSpy.mockRestore();
expect(output).toContain(
'contacts imports list --after 479e3145-dd38-476b-932c-529ceb705947 --limit 10 --status failed',
);
});

it('passes --after cursor to the SDK', async () => {
spies = setupOutputSpies();

Expand Down