feat(desktop): add i18n infrastructure with react-intl (#8105)

This commit is contained in:
jh-block
2026-03-27 19:39:50 +01:00
committed by GitHub
parent d596113e72
commit a6765fbcd9
172 changed files with 13793 additions and 2054 deletions
@@ -1,9 +1,13 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { render, screen, act } from '@testing-library/react';
import { render, type RenderOptions, screen, act } from '@testing-library/react';
import { ExtensionInstallModal } from './ExtensionInstallModal';
import { addExtensionFromDeepLink } from './settings/extensions/deeplink';
import { IntlTestWrapper } from '../i18n/test-utils';
const renderWithIntl = (ui: React.ReactElement, options?: RenderOptions) =>
render(ui, { wrapper: IntlTestWrapper, ...options });
vi.mock('./settings/extensions/deeplink', () => ({
addExtensionFromDeepLink: vi.fn(),
@@ -51,7 +55,7 @@ describe('ExtensionInstallModal', () => {
it('should handle trusted extension (default behaviour, no allowlist)', async () => {
mockElectron.getAllowedExtensions.mockResolvedValue([]);
render(<ExtensionInstallModal addExtension={mockAddExtension} setView={mockSetView} />);
renderWithIntl(<ExtensionInstallModal addExtension={mockAddExtension} setView={mockSetView} />);
const eventHandler = getAddExtensionEventHandler();
@@ -68,7 +72,7 @@ describe('ExtensionInstallModal', () => {
it('should handle trusted extension (from allowlist)', async () => {
mockElectron.getAllowedExtensions.mockResolvedValue(['npx test-extension']);
render(<ExtensionInstallModal addExtension={mockAddExtension} setView={mockSetView} />);
renderWithIntl(<ExtensionInstallModal addExtension={mockAddExtension} setView={mockSetView} />);
const eventHandler = getAddExtensionEventHandler();
@@ -86,7 +90,7 @@ describe('ExtensionInstallModal', () => {
});
mockElectron.getAllowedExtensions.mockResolvedValue(['uvx allowed-package']);
render(<ExtensionInstallModal addExtension={mockAddExtension} setView={mockSetView} />);
renderWithIntl(<ExtensionInstallModal addExtension={mockAddExtension} setView={mockSetView} />);
const eventHandler = getAddExtensionEventHandler();
@@ -105,7 +109,7 @@ describe('ExtensionInstallModal', () => {
it('should handle i-ching-mcp-server as allowed command', async () => {
mockElectron.getAllowedExtensions.mockResolvedValue([]);
render(<ExtensionInstallModal addExtension={mockAddExtension} setView={mockSetView} />);
renderWithIntl(<ExtensionInstallModal addExtension={mockAddExtension} setView={mockSetView} />);
const eventHandler = getAddExtensionEventHandler();
@@ -124,7 +128,7 @@ describe('ExtensionInstallModal', () => {
it('should handle blocked extension', async () => {
mockElectron.getAllowedExtensions.mockResolvedValue(['uvx allowed-package']);
render(<ExtensionInstallModal addExtension={mockAddExtension} setView={mockSetView} />);
renderWithIntl(<ExtensionInstallModal addExtension={mockAddExtension} setView={mockSetView} />);
const eventHandler = getAddExtensionEventHandler();
@@ -143,7 +147,7 @@ describe('ExtensionInstallModal', () => {
it('should dismiss modal correctly', async () => {
mockElectron.getAllowedExtensions.mockResolvedValue([]);
render(<ExtensionInstallModal addExtension={mockAddExtension} setView={mockSetView} />);
renderWithIntl(<ExtensionInstallModal addExtension={mockAddExtension} setView={mockSetView} />);
const eventHandler = getAddExtensionEventHandler();
@@ -164,7 +168,7 @@ describe('ExtensionInstallModal', () => {
vi.mocked(addExtensionFromDeepLink).mockResolvedValue(undefined);
mockElectron.getAllowedExtensions.mockResolvedValue([]);
render(<ExtensionInstallModal addExtension={mockAddExtension} setView={mockSetView} />);
renderWithIntl(<ExtensionInstallModal addExtension={mockAddExtension} setView={mockSetView} />);
const eventHandler = getAddExtensionEventHandler();