Skip to content

Commit 0989f01

Browse files
committed
Add tests for TaskHeader component and mock i18next for translations
1 parent 86a4e5b commit 0989f01

File tree

5 files changed

+406
-534
lines changed

5 files changed

+406
-534
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Mock for i18next
2+
const i18next = {
3+
use: function (plugin: any) {
4+
return this
5+
},
6+
init: function () {
7+
return this
8+
},
9+
t: function (key: string) {
10+
const parts = key.split(":")
11+
return parts.length > 1 ? parts[1] : key
12+
},
13+
changeLanguage: () => new Promise(() => {}),
14+
addResourceBundle: () => {},
15+
}
16+
17+
export default i18next
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Mock for react-i18next
2+
3+
export const initReactI18next = {
4+
type: "3rdParty",
5+
init: () => {},
6+
}
7+
8+
// Mock the useTranslation hook
9+
export const useTranslation = () => ({
10+
t: (key: string) => {
11+
// Handle number format suffixes
12+
if (key === "number_format.million_suffix") return "M"
13+
if (key === "number_format.thousand_suffix") return "K"
14+
15+
// Return the key part after the colon or the whole key if no colon
16+
const parts = key.split(":")
17+
return parts.length > 1 ? parts[1] : key
18+
},
19+
i18n: {
20+
changeLanguage: () => new Promise(() => {}),
21+
t: (key: string) => {
22+
if (key === "number_format.million_suffix") return "M"
23+
if (key === "number_format.thousand_suffix") return "K"
24+
const parts = key.split(":")
25+
return parts.length > 1 ? parts[1] : key
26+
},
27+
},
28+
})
29+
30+
// Mock the Trans component
31+
export const Trans = ({ children }: { children: any }) => children

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ const TaskHeader: React.FC<TaskHeaderProps> = ({
7171
<div className="flex justify-between items-center gap-2">
7272
<div
7373
className="flex items-center cursor-pointer -ml-0.5 select-none grow min-w-0"
74-
onClick={() => setIsTaskExpanded(!isTaskExpanded)}>
74+
onClick={() => setIsTaskExpanded(!isTaskExpanded)}
75+
data-testid="task-header" // Added data-testid here
76+
>
7577
<div className="flex items-center shrink-0">
7678
<span className={`codicon codicon-chevron-${isTaskExpanded ? "down" : "right"}`}></span>
7779
</div>

0 commit comments

Comments
 (0)