Conversation
|
Cursor Agent can help with this pull request. Just |
Adds a new 'resend emails get <id>' subcommand that retrieves a sent email by ID using the existing resend.emails.get() SDK method. Interactive output shows from, to, subject, status (last_event), date, and scheduled_at fields. JSON output returns the full email object. Also adds tests covering SDK call, JSON output, auth error, and fetch error paths. Co-authored-by: Vitor Capretz <capretzvitor@gmail.com>
f3a022e to
9fedf82
Compare
There was a problem hiding this comment.
2 issues found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="tests/commands/emails/get.test.ts">
<violation number="1" location="tests/commands/emails/get.test.ts:9">
P2: This test uses Bun’s test runtime (`bun:test`) and Bun-only mocking APIs (`mock.module`), but the existing suite and helpers are built around Vitest. Under the Vitest runner this file will fail to import/use Bun APIs. Align this test with Vitest (e.g., `import { describe, test, expect, vi } from 'vitest'` and use `vi.fn/vi.mock/vi.spyOn`).</violation>
<violation number="2" location="tests/commands/emails/get.test.ts:59">
P2: `setupOutputSpies()` doesn’t return a `restore()` method, so `spies?.restore()` will throw when spies are set. Restore the specific spies instead.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
tests/commands/emails/get.test.ts
Outdated
|
|
||
| afterEach(() => { | ||
| restoreEnv(); | ||
| spies?.restore(); |
There was a problem hiding this comment.
P2: setupOutputSpies() doesn’t return a restore() method, so spies?.restore() will throw when spies are set. Restore the specific spies instead.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At tests/commands/emails/get.test.ts, line 59:
<comment>`setupOutputSpies()` doesn’t return a `restore()` method, so `spies?.restore()` will throw when spies are set. Restore the specific spies instead.</comment>
<file context>
@@ -0,0 +1,132 @@
+
+ afterEach(() => {
+ restoreEnv();
+ spies?.restore();
+ errorSpy?.mockRestore();
+ stderrSpy?.mockRestore();
</file context>
tests/commands/emails/get.test.ts
Outdated
| mock, | ||
| spyOn, | ||
| test, | ||
| } from 'bun:test'; |
There was a problem hiding this comment.
P2: This test uses Bun’s test runtime (bun:test) and Bun-only mocking APIs (mock.module), but the existing suite and helpers are built around Vitest. Under the Vitest runner this file will fail to import/use Bun APIs. Align this test with Vitest (e.g., import { describe, test, expect, vi } from 'vitest' and use vi.fn/vi.mock/vi.spyOn).
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At tests/commands/emails/get.test.ts, line 9:
<comment>This test uses Bun’s test runtime (`bun:test`) and Bun-only mocking APIs (`mock.module`), but the existing suite and helpers are built around Vitest. Under the Vitest runner this file will fail to import/use Bun APIs. Align this test with Vitest (e.g., `import { describe, test, expect, vi } from 'vitest'` and use `vi.fn/vi.mock/vi.spyOn`).</comment>
<file context>
@@ -0,0 +1,132 @@
+ mock,
+ spyOn,
+ test,
+} from 'bun:test';
+import {
+ captureTestEnv,
</file context>
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="tests/commands/emails/get.test.ts">
<violation number="1" location="tests/commands/emails/get.test.ts:76">
P2: This assertion no longer verifies call count, so the test can pass even if `emails.get` is invoked multiple times.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| ); | ||
| await getEmailCommand.parseAsync(['email_abc123'], { from: 'user' }); | ||
|
|
||
| expect(mockGet).toHaveBeenCalledWith('email_abc123'); |
There was a problem hiding this comment.
P2: This assertion no longer verifies call count, so the test can pass even if emails.get is invoked multiple times.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At tests/commands/emails/get.test.ts, line 76:
<comment>This assertion no longer verifies call count, so the test can pass even if `emails.get` is invoked multiple times.</comment>
<file context>
@@ -74,8 +73,7 @@ describe('emails get command', () => {
- expect(mockGet).toHaveBeenCalledTimes(1);
- expect(mockGet.mock.calls[0][0]).toBe('email_abc123');
+ expect(mockGet).toHaveBeenCalledWith('email_abc123');
});
</file context>
| expect(mockGet).toHaveBeenCalledWith('email_abc123'); | |
| expect(mockGet).toHaveBeenCalledTimes(1); | |
| expect(mockGet).toHaveBeenCalledWith('email_abc123'); |
Add
resend emails get <id>command to support retrieving email details.The existing
resend emails receiving get <id>command only retrieves details for received emails. This PR introduces a newresend emails get <id>command that leverages theresend.emails.get(id)SDK method to retrieve details for any email, aligning with user expectations for a general email retrieval command.Slack Thread
Summary by cubic
Adds
resend emails get <id>to fetch a sent email by ID, providing a general email lookup aligned with the SDK. This replaces the need to use the receiving-only path for basic lookups.New Features
resend emails get <id>usingresend.emails.get(id)with interactive output (From, To, Subject, Status, Date, Scheduled) and--jsonfor the full object.auth_error,fetch_error); added tests for SDK call, JSON output, auth error, and fetch error.Bug Fixes
emails getsuite.Written for commit f720c4e. Summary will update on new commits.