Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

Commit 9d2d27c

Browse files
committed
Fix webview tests after telemetry removal
1 parent 1e49eef commit 9d2d27c

4 files changed

Lines changed: 45 additions & 1 deletion

File tree

webview-ui/src/components/chat/ShareButton.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export const ShareButton = ({ item, disabled = false }: ShareButtonProps) => {
3535
// Use enhanced cloud upsell hook with auto-open on auth success
3636
const {
3737
isOpen: connectModalOpen,
38+
openUpsell,
3839
closeUpsell,
3940
handleConnect,
4041
isAuthenticated: cloudIsAuthenticated,
@@ -94,7 +95,11 @@ export const ShareButton = ({ item, disabled = false }: ShareButtonProps) => {
9495
setShareDropdownOpen(false)
9596
}
9697

97-
const handleShareButtonClick = () => {}
98+
const handleShareButtonClick = () => {
99+
if (!cloudIsAuthenticated) {
100+
openUpsell()
101+
}
102+
}
98103

99104
// Determine share button state
100105
const getShareButtonState = () => {

webview-ui/src/components/chat/__tests__/ChatView.keyboard-fix.spec.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,16 @@ import { vscode } from "@src/utils/vscode"
1010
import ChatView, { ChatViewProps } from "../ChatView"
1111

1212
// Mock vscode API
13+
vi.mock("@src/utils/vscode", () => ({
14+
vscode: {
15+
postMessage: vi.fn(),
16+
},
17+
}))
1318

1419
// Mock use-sound hook
20+
vi.mock("use-sound", () => ({
21+
default: vi.fn(() => [vi.fn()]),
22+
}))
1523

1624
// Mock components
1725

webview-ui/src/components/chat/__tests__/ModeSelector.spec.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ import type { Mode } from "@roo/modes"
66

77
import { ModeSelector } from "../ModeSelector"
88

9+
const mockSetHasOpenedModeSelector = vi.hoisted(() => vi.fn())
10+
11+
vi.mock("@/context/ExtensionStateContext", () => ({
12+
useExtensionState: () => ({
13+
hasOpenedModeSelector: false,
14+
setHasOpenedModeSelector: mockSetHasOpenedModeSelector,
15+
}),
16+
}))
17+
918
// Create a variable to control what getAllModes returns.
1019
let mockModes: ModeConfig[] = []
1120

webview-ui/src/components/chat/__tests__/ShareButton.spec.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,30 @@ import { useTranslation } from "react-i18next"
22

33
import { render, screen, fireEvent, waitFor } from "@/utils/test-utils"
44
import { vscode } from "@/utils/vscode"
5+
import { useExtensionState } from "@/context/ExtensionStateContext"
56

67
import { ShareButton } from "../ShareButton"
78

89
// Mock the vscode utility
10+
vi.mock("@/utils/vscode", () => ({
11+
vscode: {
12+
postMessage: vi.fn(),
13+
},
14+
}))
915

1016
// Mock react-i18next
17+
vi.mock("react-i18next", () => ({
18+
useTranslation: vi.fn(),
19+
}))
1120

1221
// Mock the extension state context
22+
vi.mock("@/context/ExtensionStateContext", () => ({
23+
useExtensionState: vi.fn(),
24+
}))
1325

1426
const mockUseTranslation = vi.mocked(useTranslation)
1527
const mockVscode = vi.mocked(vscode)
28+
const mockUseExtensionState = vi.mocked(useExtensionState)
1629

1730
describe("ShareButton", () => {
1831
const mockT = vi.fn((key: string) => key)
@@ -29,6 +42,15 @@ describe("ShareButton", () => {
2942
beforeEach(() => {
3043
vi.clearAllMocks()
3144

45+
mockUseExtensionState.mockReturnValue({
46+
cloudIsAuthenticated: true,
47+
sharingEnabled: true,
48+
publicSharingEnabled: true,
49+
cloudUserInfo: {
50+
organizationName: "Test Organization",
51+
},
52+
} as any)
53+
3254
mockUseTranslation.mockReturnValue({
3355
t: mockT,
3456
i18n: {} as any,

0 commit comments

Comments
 (0)