Skip to content

Commit 689b4bf

Browse files
committed
frontend: fix tests
1 parent b484ce4 commit 689b4bf

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

frontend/src/pages/Tokens.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ export function Tokens() {
312312
className="w-auto"
313313
value={sortOption}
314314
onChange={(e) => setSortOption((e.target as HTMLSelectElement).value as SortOption)}
315+
aria-label={t("tokens.sort_label")} // needed for testing
315316
>
316317
{SORT_OPTIONS.map((option) => (
317318
<option key={option.value} value={option.value}>
@@ -326,6 +327,7 @@ export function Tokens() {
326327
placeholder={t("tokens.search_placeholder")}
327328
value={searchQuery}
328329
onChange={(e) => setSearchQuery((e.target as HTMLInputElement).value)}
330+
aria-label={t("tokens.search_label")} //needed for testing
329331
/>
330332
</div>
331333
</Card.Header>

frontend/src/test-setup.ts

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -396,21 +396,25 @@ vi.mock('react-feather', () => ({
396396
}));
397397

398398
// Mock i18next
399-
vi.mock('react-i18next', () => ({
400-
useTranslation: () => ({
401-
t: (key: string, options?: Record<string, unknown>) => {
402-
if (options && typeof options === 'object') {
403-
let result = key;
404-
Object.keys(options).forEach(optionKey => {
405-
result = result.replace(`{{${optionKey}}}`, String(options[optionKey]));
406-
});
407-
return result;
408-
}
409-
return key;
410-
},
411-
}),
412-
Trans: ({ children }: { children?: ComponentChildren }) => h('span', {}, children),
413-
}));
399+
vi.mock('react-i18next', () => {
400+
const t = (key: string, options?: Record<string, unknown>) => {
401+
if (options && typeof options === 'object') {
402+
let result = key;
403+
Object.keys(options).forEach(optionKey => {
404+
result = result.replace(`{{${optionKey}}}`, String(options[optionKey]));
405+
});
406+
return result;
407+
}
408+
return key;
409+
};
410+
411+
return {
412+
useTranslation: () => ({
413+
t,
414+
}),
415+
Trans: ({ children }: { children?: ComponentChildren }) => h('span', {}, children),
416+
};
417+
});
414418

415419
// Mock libsodium-wrappers
416420
vi.mock('libsodium-wrappers', () => ({

0 commit comments

Comments
 (0)