Skip to content

Commit 151b548

Browse files
committed
fix: update AgentSelector and EditAgentControls localization keys and tests
- Update AgentSelector component to use chat:agentSelector.* keys - Update EditAgentControls to use chat:selectAgent key - Fix AgentSelector tests to use correct localization keys - Fix EditAgentControls tests to mock AgentSelector and use correct keys - All component tests now pass successfully
1 parent 202844a commit 151b548

File tree

4 files changed

+52
-20
lines changed

4 files changed

+52
-20
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export const AgentSelector = ({
157157
const showSearch = !disableSearch && modes.length > SEARCH_THRESHOLD
158158

159159
// Combine instruction text for tooltip
160-
const instructionText = `${t("chat:modeSelector.description")} ${modeShortcutText}`
160+
const instructionText = `${t("chat:agentSelector.description")} ${modeShortcutText}`
161161

162162
const trigger = (
163163
<PopoverTrigger
@@ -198,7 +198,7 @@ export const AgentSelector = ({
198198
ref={searchInputRef}
199199
value={searchValue}
200200
onChange={(e) => setSearchValue(e.target.value)}
201-
placeholder={t("chat:modeSelector.searchPlaceholder")}
201+
placeholder={t("chat:agentSelector.searchPlaceholder")}
202202
className="w-full h-8 px-2 py-1 text-xs bg-vscode-input-background text-vscode-input-foreground border border-vscode-input-border rounded focus:outline-0"
203203
data-testid="agent-search-input"
204204
/>
@@ -221,7 +221,7 @@ export const AgentSelector = ({
221221
<div className="max-h-[300px] overflow-y-auto">
222222
{filteredModes.length === 0 && searchValue ? (
223223
<div className="py-2 px-3 text-sm text-vscode-foreground/70">
224-
{t("chat:modeSelector.noResults")}
224+
{t("chat:agentSelector.noResults")}
225225
</div>
226226
) : (
227227
<div className="py-1">
@@ -257,7 +257,7 @@ export const AgentSelector = ({
257257
<div className="flex flex-row gap-1">
258258
<IconButton
259259
iconClass="codicon-extensions"
260-
title={t("chat:modeSelector.marketplace")}
260+
title={t("chat:agentSelector.marketplace")}
261261
onClick={() => {
262262
window.postMessage(
263263
{
@@ -272,7 +272,7 @@ export const AgentSelector = ({
272272
/>
273273
<IconButton
274274
iconClass="codicon-settings-gear"
275-
title={t("chat:modeSelector.settings")}
275+
title={t("chat:agentSelector.settings")}
276276
onClick={() => {
277277
vscode.postMessage({
278278
type: "switchTab",
@@ -291,7 +291,7 @@ export const AgentSelector = ({
291291
</StandardTooltip>
292292
)}
293293
<h4 className="m-0 font-medium text-sm text-vscode-descriptionForeground">
294-
{t("chat:modeSelector.title")}
294+
{t("chat:agentSelector.title")}
295295
</h4>
296296
</div>
297297
</div>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const EditAgentControls: React.FC<EditAgentControlsProps> = ({
4949
<div className="shrink-0">
5050
<AgentSelector
5151
value={mode}
52-
title={t("chat:selectMode")}
52+
title={t("chat:selectAgent")}
5353
onChange={onModeChange}
5454
triggerClassName="w-full"
5555
modeShortcutText={modeShortcutText}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ vi.mock("@/utils/vscode", () => ({
1414

1515
vi.mock("@/context/ExtensionStateContext", () => ({
1616
useExtensionState: () => ({
17-
hasOpenedAgentSelector: false,
18-
setHasOpenedAgentSelector: vi.fn(),
17+
hasOpenedModeSelector: false,
18+
setHasOpenedModeSelector: vi.fn(),
1919
}),
2020
}))
2121

@@ -50,7 +50,7 @@ describe("AgentSelector", () => {
5050
test("shows custom description from customModePrompts", () => {
5151
const customModePrompts = {
5252
code: {
53-
description: "Custom code mode description",
53+
description: "Custom code agent description",
5454
},
5555
}
5656

@@ -93,7 +93,7 @@ describe("AgentSelector", () => {
9393
expect(screen.getByTestId("agent-search-input")).toBeInTheDocument()
9494

9595
// Info icon should be visible
96-
expect(screen.getByText("chat:modeSelector.title")).toBeInTheDocument()
96+
expect(screen.getByText("chat:agentSelector.title")).toBeInTheDocument()
9797
const infoIcon = document.querySelector(".codicon-info")
9898
expect(infoIcon).toBeInTheDocument()
9999
})
@@ -117,7 +117,7 @@ describe("AgentSelector", () => {
117117
expect(screen.queryByTestId("agent-search-input")).not.toBeInTheDocument()
118118

119119
// Info blurb should be visible
120-
expect(screen.getByText(/chat:modeSelector.description/)).toBeInTheDocument()
120+
expect(screen.getByText(/chat:agentSelector.description/)).toBeInTheDocument()
121121

122122
// Info icon should NOT be visible
123123
const infoIcon = document.querySelector(".codicon-info")
@@ -174,7 +174,7 @@ describe("AgentSelector", () => {
174174
expect(screen.queryByTestId("agent-search-input")).not.toBeInTheDocument()
175175

176176
// Info blurb should be visible instead
177-
expect(screen.getByText(/chat:modeSelector.description/)).toBeInTheDocument()
177+
expect(screen.getByText(/chat:agentSelector.description/)).toBeInTheDocument()
178178

179179
// Info icon should NOT be visible
180180
const infoIcon = document.querySelector(".codicon-info")

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

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,48 @@ vi.mock("@/components/ui", () => ({
2121
StandardTooltip: ({ children, content }: any) => <div title={content}>{children}</div>,
2222
}))
2323

24-
// Mock ModeSelector
25-
vi.mock("../ModeSelector", () => ({
24+
// Mock AgentSelector
25+
vi.mock("../AgentSelector", () => ({
2626
default: ({ value, onChange, title }: any) => (
27-
<select value={value} onChange={(e) => onChange(e.target.value)} title={title}>
27+
<select value={value} onChange={(e) => onChange(e.target.value)} title={title || "chat:selectAgent"}>
2828
<option value="code">Code</option>
2929
<option value="architect">Architect</option>
3030
</select>
3131
),
3232
}))
3333

34+
// Mock ExtensionStateContext
35+
vi.mock("@/context/ExtensionStateContext", () => ({
36+
useExtensionState: () => ({
37+
hasOpenedModeSelector: false,
38+
setHasOpenedModeSelector: vi.fn(),
39+
}),
40+
}))
41+
42+
// Mock other dependencies
43+
vi.mock("@/utils/vscode", () => ({
44+
vscode: {
45+
postMessage: vi.fn(),
46+
},
47+
}))
48+
49+
vi.mock("@/components/ui/hooks/useRooPortal", () => ({
50+
useRooPortal: () => document.body,
51+
}))
52+
53+
vi.mock("@/utils/TelemetryClient", () => ({
54+
telemetryClient: {
55+
capture: vi.fn(),
56+
},
57+
}))
58+
59+
vi.mock("@roo/modes", () => ({
60+
getAllModes: () => [
61+
{ slug: "code", name: "Code", description: "Code mode" },
62+
{ slug: "architect", name: "Architect", description: "Architect mode" },
63+
],
64+
}))
65+
3466
describe("EditAgentControls", () => {
3567
const defaultProps = {
3668
mode: "code" as Mode,
@@ -52,8 +84,8 @@ describe("EditAgentControls", () => {
5284
it("renders all controls correctly", () => {
5385
render(<EditAgentControls {...defaultProps} />)
5486

55-
// Check for mode selector
56-
expect(screen.getByTitle("chat:selectMode")).toBeInTheDocument()
87+
// Check for agent selector
88+
expect(screen.getByTitle("chat:selectAgent")).toBeInTheDocument()
5789

5890
// Check for Cancel button
5991
expect(screen.getByText("Cancel")).toBeInTheDocument()
@@ -130,8 +162,8 @@ describe("EditAgentControls", () => {
130162
it("calls onModeChange when mode is changed", () => {
131163
render(<EditAgentControls {...defaultProps} />)
132164

133-
const modeSelector = screen.getByTitle("chat:selectMode")
134-
fireEvent.change(modeSelector, { target: { value: "architect" } })
165+
const agentSelector = screen.getByTitle("chat:selectAgent")
166+
fireEvent.change(agentSelector, { target: { value: "architect" } })
135167

136168
expect(defaultProps.onModeChange).toHaveBeenCalledWith("architect")
137169
})

0 commit comments

Comments
 (0)