forked from cline/cline
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
feat: Cloud agents in extension #8470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 12 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
e76d22e
First pass of cloud agents in extension, with mock data
brunobergher 3d7debb
Mock data fix
brunobergher cffea36
Empty state for no cloud agents
brunobergher bb2937b
Mock data fiz
brunobergher 2cb056f
Merge main
brunobergher 8577101
It works
brunobergher 8c99fff
i18n
brunobergher 0e8048d
Removes debug console.log calls
brunobergher dd4b2a9
PR Feedback
brunobergher a255a14
Fixes tests
brunobergher 6ce9ce5
Test fixes
brunobergher a1f98f9
PR Review
brunobergher 14d5eba
PR feedback
mrubens 1367792
Layout tweaks
mrubens dde8d3e
Fix tests
mrubens 1147106
PR feedback
mrubens File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| import { describe, it, expect, vi, beforeEach } from "vitest" | ||
| import { CloudAPI } from "../CloudAPI.js" | ||
| import { AuthenticationError } from "../errors.js" | ||
| import type { AuthService } from "@roo-code/types" | ||
|
|
||
| // Mock fetch globally | ||
| global.fetch = vi.fn() | ||
|
|
||
| describe("CloudAPI", () => { | ||
| let mockAuthService: Partial<AuthService> | ||
| let cloudAPI: CloudAPI | ||
|
|
||
| beforeEach(() => { | ||
| // Mock only the methods we need for testing | ||
| mockAuthService = { | ||
| getSessionToken: vi.fn().mockReturnValue("test-token"), | ||
| } | ||
|
|
||
| cloudAPI = new CloudAPI(mockAuthService as AuthService) | ||
| vi.clearAllMocks() | ||
| }) | ||
|
|
||
| describe("getCloudAgents", () => { | ||
| it("should return cloud agents on success", async () => { | ||
| const mockAgents = [ | ||
| { id: "1", name: "Agent 1", type: "code", icon: "code" }, | ||
| { id: "2", name: "Agent 2", type: "chat", icon: "chat" }, | ||
| ] | ||
|
|
||
| // Mock successful response | ||
| ;(global.fetch as ReturnType<typeof vi.fn>).mockResolvedValueOnce({ | ||
| ok: true, | ||
| json: async () => ({ success: true, data: mockAgents }), | ||
| }) | ||
|
|
||
| const agents = await cloudAPI.getCloudAgents() | ||
|
|
||
| expect(agents).toEqual(mockAgents) | ||
| expect(global.fetch).toHaveBeenCalledWith( | ||
| expect.stringContaining("/api/cloud-agents"), | ||
| expect.objectContaining({ | ||
| method: "GET", | ||
| headers: expect.objectContaining({ | ||
| Authorization: "Bearer test-token", | ||
| }), | ||
| }), | ||
| ) | ||
| }) | ||
|
|
||
| it("should throw AuthenticationError on 401 response", async () => { | ||
| // Mock 401 response | ||
| ;(global.fetch as ReturnType<typeof vi.fn>).mockResolvedValueOnce({ | ||
| ok: false, | ||
| status: 401, | ||
| statusText: "Unauthorized", | ||
| json: async () => ({ error: "Authentication required" }), | ||
| }) | ||
|
|
||
| await expect(cloudAPI.getCloudAgents()).rejects.toThrow(AuthenticationError) | ||
| }) | ||
|
|
||
| it("should throw AuthenticationError when no session token", async () => { | ||
| // Mock no session token | ||
| mockAuthService.getSessionToken = vi.fn().mockReturnValue(null) | ||
|
|
||
| await expect(cloudAPI.getCloudAgents()).rejects.toThrow(AuthenticationError) | ||
| }) | ||
|
|
||
| it("should return empty array when data is missing", async () => { | ||
| // Mock response with no data | ||
| ;(global.fetch as ReturnType<typeof vi.fn>).mockResolvedValueOnce({ | ||
| ok: true, | ||
| json: async () => ({ success: true }), | ||
| }) | ||
|
|
||
| const agents = await cloudAPI.getCloudAgents() | ||
|
|
||
| expect(agents).toEqual([]) | ||
| }) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.