Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 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
4 changes: 2 additions & 2 deletions apps/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"ink-testing-library": "^4.0.0",
"rimraf": "^6.0.1",
"tsup": "^8.4.0",
"@vitest/coverage-v8": "^3.2.3",
"vitest": "^3.2.3"
"@vitest/coverage-v8": "^4.1.6",
"vitest": "^4.1.6"
}
}
2 changes: 1 addition & 1 deletion apps/cli/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "@roo-code/config-typescript/base.json",
"compilerOptions": {
"types": ["vitest/globals"],
"types": ["node", "vitest/globals"],
"outDir": "dist",
"jsx": "react-jsx",
"jsxImportSource": "react",
Expand Down
2 changes: 1 addition & 1 deletion apps/web-evals/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@
"@types/react": "^18.3.23",
"@types/react-dom": "^18.3.5",
"tailwindcss": "^4",
"vitest": "^3.2.3"
"vitest": "^4.1.6"
}
}
2 changes: 1 addition & 1 deletion apps/web-evals/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "@roo-code/config-typescript/nextjs.json",
"compilerOptions": {
"types": ["vitest/globals"],
"types": ["node", "vitest/globals"],
"plugins": [{ "name": "next" }],
"paths": { "@/*": ["./src/*"] }
},
Expand Down
3 changes: 2 additions & 1 deletion apps/web-roo-code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@
"@types/node": "20.x",
"@types/react": "^18.3.23",
"@types/react-dom": "^18.3.7",
"@vitejs/plugin-react": "^4.7.0",
"autoprefixer": "^10.4.23",
"next-sitemap": "^4.2.3",
"postcss": "^8.5.6",
"tailwindcss": "^3.4.17",
"vitest": "^4.0.18"
"vitest": "^4.1.6"
}
}
2 changes: 2 additions & 0 deletions apps/web-roo-code/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { defineConfig } from "vitest/config"
import path from "path"
import react from "@vitejs/plugin-react"

export default defineConfig({
plugins: [react()],
test: {
include: ["src/**/*.test.{ts,tsx}"],
environment: "node",
Expand Down
2 changes: 1 addition & 1 deletion packages/build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
"@roo-code/config-eslint": "workspace:^",
"@roo-code/config-typescript": "workspace:^",
"@types/node": "20.x",
"vitest": "^3.2.3"
"vitest": "^4.1.6"
}
}
2 changes: 1 addition & 1 deletion packages/build/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "@roo-code/config-typescript/base.json",
"compilerOptions": {
"types": ["vitest/globals"],
"types": ["node", "vitest/globals"],
"outDir": "dist"
},
"include": ["src"],
Expand Down
4 changes: 2 additions & 2 deletions packages/cloud/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@types/node": "^24.1.0",
"@types/vscode": "^1.102.0",
"globals": "^16.3.0",
"@vitest/coverage-v8": "^3.2.4",
"vitest": "^3.2.4"
"@vitest/coverage-v8": "^4.1.6",
"vitest": "^4.1.6"
}
}
18 changes: 12 additions & 6 deletions packages/cloud/src/__mocks__/vscode.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import type * as vscode from "vscode"

export const window = {
type VscodeWindowMock = Pick<typeof vscode.window, "showInformationMessage" | "showErrorMessage">

type VscodeEnvMock = Pick<typeof vscode.env, "openExternal">

type VscodeCommandsMock = Pick<typeof vscode.commands, "executeCommand">

export const window: VscodeWindowMock = {
showInformationMessage: vi.fn(),
showErrorMessage: vi.fn(),
}

export const env = {
export const env: VscodeEnvMock = {
openExternal: vi.fn(),
}

export const Uri = {
parse: vi.fn((uri: string) => ({ toString: () => uri })),
}

export const commands = {
export const commands: VscodeCommandsMock = {
executeCommand: vi.fn().mockResolvedValue(undefined),
}

Expand All @@ -28,9 +34,9 @@ export interface ExtensionContext {
}
globalState: {
get: <T>(key: string) => T | undefined
update: (key: string, value: any) => Promise<void>
update: (key: string, value: unknown) => Promise<void>
}
subscriptions: any[]
subscriptions: unknown[]
extension?: {
packageJSON?: {
version?: string
Expand Down
26 changes: 18 additions & 8 deletions packages/cloud/src/__tests__/CloudService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,21 @@ describe("CloudService", () => {
backfillMessages: vi.fn().mockResolvedValue(undefined),
}

vi.mocked(WebAuthService).mockImplementation(() => mockAuthService as unknown as WebAuthService)
vi.mocked(WebAuthService).mockImplementation(function () {
return mockAuthService as unknown as WebAuthService
})

vi.mocked(CloudSettingsService).mockImplementation(() => mockSettingsService as unknown as CloudSettingsService)
vi.mocked(CloudSettingsService).mockImplementation(function () {
return mockSettingsService as unknown as CloudSettingsService
})

vi.mocked(CloudShareService).mockImplementation(() => mockShareService as unknown as CloudShareService)
vi.mocked(CloudShareService).mockImplementation(function () {
return mockShareService as unknown as CloudShareService
})

vi.mocked(TelemetryClient).mockImplementation(() => mockTelemetryClient as unknown as TelemetryClient)
vi.mocked(TelemetryClient).mockImplementation(function () {
return mockTelemetryClient as unknown as TelemetryClient
})
})

afterEach(() => {
Expand Down Expand Up @@ -417,7 +425,9 @@ describe("CloudService", () => {
})

// Override the mock to return our properly typed instance
vi.mocked(CloudSettingsService).mockImplementation(() => mockCloudSettingsService)
vi.mocked(CloudSettingsService).mockImplementation(function () {
return mockCloudSettingsService
})

const cloudService = await CloudService.createInstance(mockContext)

Expand Down Expand Up @@ -450,9 +460,9 @@ describe("CloudService", () => {
}

// Override the mock to return a service that won't pass instanceof check
vi.mocked(CloudSettingsService).mockImplementation(
() => mockStaticSettingsService as unknown as CloudSettingsService,
)
vi.mocked(CloudSettingsService).mockImplementation(function () {
return mockStaticSettingsService as unknown as CloudSettingsService
})

// This should not throw even though the service doesn't pass instanceof check
const _cloudService = await CloudService.createInstance(mockContext)
Expand Down
41 changes: 22 additions & 19 deletions packages/cloud/src/__tests__/CloudSettingsService.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { ExtensionContext } from "vscode"
import type { Mock } from "vitest"

import type { OrganizationSettings, AuthService } from "@roo-code/types"
import type { OrganizationSettings, AuthService, AuthServiceEvents } from "@roo-code/types"

import { CloudSettingsService } from "../CloudSettingsService.js"
import { RefreshTimer } from "../RefreshTimer.js"
Expand All @@ -13,21 +14,23 @@ vi.mock("../config", () => ({

global.fetch = vi.fn()

type AuthStateChangedListener = (data: AuthServiceEvents["auth-state-changed"][0]) => unknown

describe("CloudSettingsService", () => {
let mockContext: ExtensionContext
let mockAuthService: {
getState: ReturnType<typeof vi.fn>
getSessionToken: ReturnType<typeof vi.fn>
hasActiveSession: ReturnType<typeof vi.fn>
on: ReturnType<typeof vi.fn>
getStoredOrganizationId: ReturnType<typeof vi.fn>
getState: Mock<AuthService["getState"]>
getSessionToken: Mock<() => string | undefined | null>
hasActiveSession: Mock<AuthService["hasActiveSession"]>
on: Mock<(event: string, listener: AuthStateChangedListener) => void>
getStoredOrganizationId: Mock<() => string | null>
}
let mockRefreshTimer: {
start: ReturnType<typeof vi.fn>
stop: ReturnType<typeof vi.fn>
start: Mock<() => void>
stop: Mock<() => void>
}
let cloudSettingsService: CloudSettingsService
let mockLog: ReturnType<typeof vi.fn>
let mockLog: Mock<(...args: unknown[]) => void>

const mockSettings: OrganizationSettings = {
version: 1,
Expand Down Expand Up @@ -72,10 +75,12 @@ describe("CloudSettingsService", () => {
stop: vi.fn(),
}

mockLog = vi.fn()
mockLog = vi.fn<(...args: unknown[]) => void>()

// Mock RefreshTimer constructor
vi.mocked(RefreshTimer).mockImplementation(() => mockRefreshTimer as unknown as RefreshTimer)
vi.mocked(RefreshTimer).mockImplementation(function () {
return mockRefreshTimer as unknown as RefreshTimer
})

cloudSettingsService = new CloudSettingsService(mockContext, mockAuthService as unknown as AuthService, mockLog)
})
Expand Down Expand Up @@ -502,10 +507,9 @@ describe("CloudSettingsService", () => {
await cloudSettingsService.initialize()

// Get the auth-state-changed handler
const authStateChangedHandler = mockAuthService.on.mock.calls.find(
(call: string[]) => call[0] === "auth-state-changed",
)?.[1]
expect(authStateChangedHandler).toBeDefined()
const [, authStateChangedHandler] = mockAuthService.on.mock.calls.find(
([event]) => event === "auth-state-changed",
) as [string, AuthStateChangedListener]

// Simulate active-session state change
authStateChangedHandler({
Expand All @@ -519,10 +523,9 @@ describe("CloudSettingsService", () => {
await cloudSettingsService.initialize()

// Get the auth-state-changed handler
const authStateChangedHandler = mockAuthService.on.mock.calls.find(
(call: string[]) => call[0] === "auth-state-changed",
)?.[1]
expect(authStateChangedHandler).toBeDefined()
const [, authStateChangedHandler] = mockAuthService.on.mock.calls.find(
([event]) => event === "auth-state-changed",
) as [string, AuthStateChangedListener]

// Simulate logged-out state change from active-session
await authStateChangedHandler({
Expand Down
2 changes: 1 addition & 1 deletion packages/cloud/src/__tests__/CloudShareService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ describe("CloudShareService", () => {
})

it("should handle errors gracefully", async () => {
;(mockSettingsService.getSettings as any).mockImplementation(() => {
;(mockSettingsService.getSettings as any).mockImplementation(function () {
throw new Error("Settings error")
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe("StaticSettingsService", () => {
})

it("should use console.log as default logger for errors", () => {
const consoleSpy = vi.spyOn(console, "log").mockImplementation(() => {})
const consoleSpy = vi.spyOn(console, "log").mockImplementation(function () {})
expect(() => new StaticSettingsService("invalid-base64!@#")).toThrow()

expect(consoleSpy).toHaveBeenCalledWith(
Expand Down
4 changes: 2 additions & 2 deletions packages/cloud/src/__tests__/TelemetryClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ describe("TelemetryClient", () => {
json: vi.fn().mockResolvedValue({}),
})

vi.spyOn(console, "info").mockImplementation(() => {})
vi.spyOn(console, "error").mockImplementation(() => {})
vi.spyOn(console, "info").mockImplementation(function () {})
vi.spyOn(console, "error").mockImplementation(function () {})
})

afterEach(() => {
Expand Down
14 changes: 8 additions & 6 deletions packages/cloud/src/__tests__/WebAuthService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ describe("WebAuthService", () => {
reset: vi.fn(),
}
const MockedRefreshTimer = vi.mocked(RefreshTimer)
MockedRefreshTimer.mockImplementation(() => mockTimer as unknown as RefreshTimer)
MockedRefreshTimer.mockImplementation(function () {
return mockTimer as unknown as RefreshTimer
})

// Setup config mocks - use production URL by default to maintain existing test behavior
vi.mocked(getClerkBaseUrl).mockReturnValue("https://clerk.roocode.com")
Expand Down Expand Up @@ -211,7 +213,7 @@ describe("WebAuthService", () => {
it("should handle credentials change events", async () => {
let onDidChangeCallback: (e: { key: string }) => void

mockContext.secrets.onDidChange.mockImplementation((callback: (e: { key: string }) => void) => {
mockContext.secrets.onDidChange.mockImplementation(function (callback: (e: { key: string }) => void) {
onDidChangeCallback = callback
return { dispose: vi.fn() }
})
Expand Down Expand Up @@ -302,7 +304,7 @@ describe("WebAuthService", () => {
})

it("should handle errors during login", async () => {
vi.mocked(crypto.randomBytes).mockImplementation(() => {
vi.mocked(crypto.randomBytes).mockImplementation(function () {
throw new Error("Crypto error")
})

Expand Down Expand Up @@ -1190,7 +1192,7 @@ describe("WebAuthService", () => {

let onDidChangeCallback: (e: { key: string }) => void

mockContext.secrets.onDidChange.mockImplementation((callback: (e: { key: string }) => void) => {
mockContext.secrets.onDidChange.mockImplementation(function (callback: (e: { key: string }) => void) {
onDidChangeCallback = callback
return { dispose: vi.fn() }
})
Expand Down Expand Up @@ -1220,7 +1222,7 @@ describe("WebAuthService", () => {

let onDidChangeCallback: (e: { key: string }) => void

mockContext.secrets.onDidChange.mockImplementation((callback: (e: { key: string }) => void) => {
mockContext.secrets.onDidChange.mockImplementation(function (callback: (e: { key: string }) => void) {
onDidChangeCallback = callback
return { dispose: vi.fn() }
})
Expand All @@ -1246,7 +1248,7 @@ describe("WebAuthService", () => {

let onDidChangeCallback: (e: { key: string }) => void

mockContext.secrets.onDidChange.mockImplementation((callback: (e: { key: string }) => void) => {
mockContext.secrets.onDidChange.mockImplementation(function (callback: (e: { key: string }) => void) {
onDidChangeCallback = callback
return { dispose: vi.fn() }
})
Expand Down
8 changes: 5 additions & 3 deletions packages/cloud/src/retry-queue/__tests__/RetryQueue.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ describe("RetryQueue", () => {

it("should not process retries when paused", async () => {
const fetchMock = vi.fn().mockResolvedValue({ ok: true })
global.fetch = fetchMock
global.fetch = fetchMock as typeof fetch

await retryQueue.enqueue("https://api.example.com/test", { method: "POST" }, "telemetry")

Expand Down Expand Up @@ -303,7 +303,7 @@ describe("RetryQueue", () => {
beforeEach(() => {
// Mock global fetch
fetchMock = vi.fn()
global.fetch = fetchMock
global.fetch = fetchMock as typeof fetch
})

afterEach(() => {
Expand Down Expand Up @@ -403,7 +403,9 @@ describe("RetryQueue", () => {
await retryQueue.enqueue("https://api.example.com/test", { method: "POST" }, "telemetry")

// Mock a slow response
fetchMock.mockImplementation(() => new Promise((resolve) => setTimeout(() => resolve({ ok: true }), 100)))
fetchMock.mockImplementation(function () {
return new Promise((resolve) => setTimeout(() => resolve({ ok: true }), 100))
})

// Start first retryAll (don't await)
const firstCall = retryQueue.retryAll()
Expand Down
2 changes: 1 addition & 1 deletion packages/config-typescript/vscode-library.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "./base.json",
"compilerOptions": {
"types": ["vitest/globals"],
"types": ["node", "vitest/globals"],
"outDir": "dist",
"module": "esnext",
"moduleResolution": "Bundler",
Expand Down
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@roo-code/config-eslint": "workspace:^",
"@roo-code/config-typescript": "workspace:^",
"@types/node": "^24.1.0",
"@vitest/coverage-v8": "^3.2.3",
"vitest": "^3.2.3"
"@vitest/coverage-v8": "^4.1.6",
"vitest": "^4.1.6"
}
}
Loading
Loading