Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(artifact-download): update tests for downloads-only artifact saving

Steven Enamakel4c6441f33191
diff --git a/app/src/services/__tests__/artifactDownloadService.test.ts b/app/src/services/__tests__/artifactDownloadService.test.ts
index 1836ab9653..7412388885 100644
--- a/app/src/services/__tests__/artifactDownloadService.test.ts
+++ b/app/src/services/__tests__/artifactDownloadService.test.ts
@@ -437,7 +437,7 @@ describe('revealArtifactInFileManager', () => {
});
});
-describe('saveArtifactViaDialog (#3162)', () => {
+describe('saveArtifactViaDialog (dialog removed with rfd)', () => {
beforeEach(() => {
vi.clearAllMocks();
hoisted.isTauri.mockReturnValue(true);
@@ -462,46 +462,27 @@ describe('saveArtifactViaDialog (#3162)', () => {
expect(callCoreRpc).not.toHaveBeenCalled();
});
- it('saves to the user-chosen path and returns it', async () => {
+ it('routes to the Downloads copy rather than a dialog command', async () => {
resolveOk();
- hoisted.invoke.mockResolvedValueOnce('/Users/me/Desktop/Deck.pptx');
+ hoisted.invoke.mockResolvedValueOnce('/Users/me/Downloads/Deck.pptx');
const outcome = await saveArtifactViaDialog('a-1', 'Deck', 'pptx');
- expect(outcome).toEqual({ ok: true, path: '/Users/me/Desktop/Deck.pptx' });
- expect(hoisted.invoke).toHaveBeenCalledWith('save_artifact_via_dialog', {
+ expect(outcome).toEqual({ ok: true, path: '/Users/me/Downloads/Deck.pptx' });
+ expect(hoisted.invoke).toHaveBeenCalledWith('download_artifact_to_downloads', {
sourcePath: '/ws/artifacts/a-1/deck.pptx',
- suggestedFilename: 'Deck.pptx',
+ filename: 'Deck.pptx',
});
+ // The removed `rfd` command must never be invoked again.
+ expect(hoisted.invoke).not.toHaveBeenCalledWith('save_artifact_via_dialog', expect.anything());
});
- it('treats a null result (dialog dismissed) as CANCELLED, not an error', async () => {
- resolveOk();
- hoisted.invoke.mockResolvedValueOnce(null);
- const outcome = await saveArtifactViaDialog('a-1', 'Deck', 'pptx');
- expect(outcome).toEqual({ ok: false, code: 'CANCELLED', error: expect.any(String) });
- });
-
- it('falls back to the Downloads copy when the dialog is unavailable', async () => {
- const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
- // First resolve (dialog path) → invoke throws; fallback re-resolves
- // then invokes the Downloads command successfully.
+ it('surfaces a copy failure as DOWNLOAD_FAILED', async () => {
resolveOk();
- hoisted.invoke.mockRejectedValueOnce(new Error('no portal'));
- vi.mocked(callCoreRpc).mockResolvedValueOnce({
- absolute_path: '/ws/artifacts/a-1/deck.pptx',
- meta: { id: 'a-1', title: 'Deck' },
- } as never);
- hoisted.invoke.mockResolvedValueOnce('/Users/me/Downloads/Deck.pptx');
-
+ hoisted.invoke.mockRejectedValueOnce(new Error('disk full'));
const outcome = await saveArtifactViaDialog('a-1', 'Deck', 'pptx');
- expect(outcome).toEqual({ ok: true, path: '/Users/me/Downloads/Deck.pptx' });
- expect(hoisted.invoke).toHaveBeenNthCalledWith(2, 'download_artifact_to_downloads', {
- sourcePath: '/ws/artifacts/a-1/deck.pptx',
- filename: 'Deck.pptx',
- });
- warn.mockRestore();
+ expect(outcome).toEqual({ ok: false, code: 'DOWNLOAD_FAILED', error: 'disk full' });
});
- it('propagates resolve failures without showing a dialog', async () => {
+ it('propagates resolve failures without invoking the shell', async () => {
vi.mocked(callCoreRpc).mockRejectedValueOnce(new Error('rpc down'));
const outcome = await saveArtifactViaDialog('a-1', 'Deck', 'pptx');
expect(outcome).toEqual({ ok: false, code: 'RESOLVE_FAILED', error: 'rpc down' });