Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/7337-vi-mock-i18n-inherit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
---

Sweep the `vi.mock('@object-ui/i18n', …)` factories that hand-list the mock's
export surface over to the obtain-and-spread form, and fix the
`check-vi-mock-inherit` recogniser's nested-generic blind spot
(objectui#7337). Test and CI-script only; no package is released by this
change.
95 changes: 0 additions & 95 deletions apps/console/dev/__tests__/setup/common-mocks.ts

This file was deleted.

3 changes: 2 additions & 1 deletion apps/console/src/pages/docs-portal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ vi.mock('@object-ui/plugin-markdown', () => ({
extractToc: () => [],
}));

vi.mock('@object-ui/i18n', () => ({
vi.mock('@object-ui/i18n', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useObjectTranslation: () => ({ t: (_k: string, o?: { defaultValue?: string }) => o?.defaultValue ?? _k }),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ const { approvalsApiStub, ADAPTER, AUTH, I18N } = vi.hoisted(() => {
return { approvalsApiStub, ADAPTER, AUTH, I18N };
});

vi.mock('@object-ui/i18n', () => ({ useObjectTranslation: () => I18N }));
vi.mock('@object-ui/i18n', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useObjectTranslation: () => I18N,
}));

vi.mock('@object-ui/auth', () => {
const authFetch = vi.fn(async () => new Response('{}', { status: 200 }));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ const { approvalsApiStub, getObjectSchema, ADAPTER, AUTH, I18N, OWNER_DISPLAY, A
return { approvalsApiStub, getObjectSchema, ADAPTER, AUTH, I18N, OWNER_DISPLAY, AMOUNT_DISPLAY };
});

vi.mock('@object-ui/i18n', () => ({ useObjectTranslation: () => I18N }));
vi.mock('@object-ui/i18n', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useObjectTranslation: () => I18N,
}));

vi.mock('@object-ui/auth', () => {
const authFetch = vi.fn(async () => new Response('{}', { status: 200 }));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ const { approvalsApiStub, getObjectSchema, ADAPTER, AUTH, I18N, ROW } = vi.hoist
return { approvalsApiStub, getObjectSchema, ADAPTER, AUTH, I18N, ROW };
});

vi.mock('@object-ui/i18n', () => ({ useObjectTranslation: () => I18N }));
vi.mock('@object-ui/i18n', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useObjectTranslation: () => I18N,
}));

vi.mock('@object-ui/auth', () => {
const authFetch = vi.fn(async () => new Response('{}', { status: 200 }));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,10 @@ const { approvalsApiStub, getObjectSchema, SCHEMAS, ADAPTER, AUTH, I18N, ROWS }
return { approvalsApiStub, getObjectSchema, SCHEMAS, ADAPTER, AUTH, I18N, ROWS };
});

vi.mock('@object-ui/i18n', () => ({ useObjectTranslation: () => I18N }));
vi.mock('@object-ui/i18n', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useObjectTranslation: () => I18N,
}));

vi.mock('@object-ui/auth', () => {
const authFetch = vi.fn(async () => new Response('{}', { status: 200 }));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ const { approvalsApiStub, adapterFind, ADAPTER, AUTH, I18N } = vi.hoisted(() =>
return { approvalsApiStub, adapterFind, ADAPTER, AUTH, I18N };
});

vi.mock('@object-ui/i18n', () => ({ useObjectTranslation: () => I18N }));
vi.mock('@object-ui/i18n', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useObjectTranslation: () => I18N,
}));

vi.mock('@object-ui/auth', () => {
const authFetch = vi.fn(async () => new Response('{}', { status: 200 }));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ const { adapterFind, approvalsApiStub, rows, ADAPTER, AUTH, I18N } = vi.hoisted(
return { adapterFind, approvalsApiStub, rows, ADAPTER, AUTH, I18N };
});

vi.mock('@object-ui/i18n', () => ({ useObjectTranslation: () => I18N }));
vi.mock('@object-ui/i18n', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useObjectTranslation: () => I18N,
}));

vi.mock('@object-ui/auth', () => {
const authFetch = vi.fn(async () => new Response('{}', { status: 200 }));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ const { approvalsApiStub, setFlowSteps, ADAPTER, AUTH, I18N } = vi.hoisted(() =>
return { approvalsApiStub, setFlowSteps, ADAPTER, AUTH, I18N };
});

vi.mock('@object-ui/i18n', () => ({ useObjectTranslation: () => I18N }));
vi.mock('@object-ui/i18n', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useObjectTranslation: () => I18N,
}));

vi.mock('@object-ui/auth', () => {
const authFetch = vi.fn(async () => new Response('{}', { status: 200 }));
Expand Down
3 changes: 2 additions & 1 deletion packages/app-shell/src/console/ai/LiveCanvas.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
import { render, screen, fireEvent } from '@testing-library/react';
import { LiveCanvas } from './LiveCanvas';

vi.mock('@object-ui/i18n', () => ({
vi.mock('@object-ui/i18n', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useObjectTranslation: () => ({
t: (key: string, options?: Record<string, unknown>) => String(options?.defaultValue ?? key),
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import { render, screen, fireEvent, waitFor, act } from '@testing-library/react'
import { CreateWorkspaceDialog } from '../CreateWorkspaceDialog';
import { provisionProductionEnvironment } from '../provisionEnvironment';

vi.mock('@object-ui/i18n', () => ({
vi.mock('@object-ui/i18n', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useObjectTranslation: () => ({
t: (key: string, options?: Record<string, unknown>) => String(options?.defaultValue ?? key),
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import '@testing-library/jest-dom/vitest';
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { render, screen, fireEvent, waitFor, within } from '@testing-library/react';

vi.mock('@object-ui/i18n', () => ({
vi.mock('@object-ui/i18n', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useObjectTranslation: () => ({
t: (key: string, options?: Record<string, unknown>) => String(options?.defaultValue ?? key),
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import '@testing-library/jest-dom/vitest';
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { render, screen, waitFor, fireEvent } from '@testing-library/react';

vi.mock('@object-ui/i18n', () => ({
vi.mock('@object-ui/i18n', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useObjectTranslation: () => ({
t: (key: string, options?: Record<string, unknown>) => String(options?.defaultValue ?? key),
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import '@testing-library/jest-dom/vitest';
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { render, screen, waitFor } from '@testing-library/react';

vi.mock('@object-ui/i18n', () => ({
vi.mock('@object-ui/i18n', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useObjectTranslation: () => ({
t: (key: string, options?: Record<string, unknown>) => String(options?.defaultValue ?? key),
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import '@testing-library/jest-dom/vitest';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { fireEvent, render, screen, waitFor } from '@testing-library/react';

vi.mock('@object-ui/i18n', () => ({
vi.mock('@object-ui/i18n', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useObjectTranslation: () => ({
t: (key: string, options?: Record<string, unknown>) => String(options?.defaultValue ?? key),
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ vi.mock('@object-ui/auth', () => ({
createAuthenticatedFetch: () => authFetchSpy,
}));

vi.mock('@object-ui/i18n', () => ({
vi.mock('@object-ui/i18n', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useObjectLabel: () => ({
fieldLabel: (_o: any, _n: any, l: any) => l,
fieldOptionLabel: (_o: any, _f: any, _v: any, l: any) => l,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ vi.mock('react-router-dom', () => ({
useParams: () => ({ appName: 'crm' }),
}));

vi.mock('@object-ui/i18n', () => ({
vi.mock('@object-ui/i18n', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useObjectTranslation: () => ({
// Echo the interpolated defaultValue so assertions read naturally; fall
// back to the key when a test doesn't provide one.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ import type { ActivityItem, ActivityItemType } from '../activityItemType.js';

// Key-echoing stub: the assertions below address the filter badges by their
// i18n key, so a stub returning the key verbatim is what makes them legible.
vi.mock('@object-ui/i18n', () => ({
vi.mock('@object-ui/i18n', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useObjectTranslation: () => ({ language: 'en', t: (key: string) => key }),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
import { render, screen, fireEvent } from '@testing-library/react';
import type { AiUsageResponse, AiMeterUsage } from '../../hooks/useAiUsage';

vi.mock('@object-ui/i18n', () => ({
vi.mock('@object-ui/i18n', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useObjectTranslation: () => ({
// Interpolates `{{name}}` from the options object (mirrors real i18next
// closely enough for count-driven copy like `resetsWeeklyDays`) — a plain
Expand Down
3 changes: 2 additions & 1 deletion packages/app-shell/src/layout/__tests__/ChatDock.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import { describe, it, expect, vi } from 'vitest';
import { render, screen, fireEvent } from '@testing-library/react';
import { ChatDockPanel, ChatDockMobileSheet, type ChatDockState } from '../ChatDock';

vi.mock('@object-ui/i18n', () => ({
vi.mock('@object-ui/i18n', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useObjectTranslation: () => ({
t: (key: string, options?: Record<string, unknown>) => String(options?.defaultValue ?? key),
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { describe, it, expect, vi } from 'vitest';
import { render, screen, fireEvent } from '@testing-library/react';
import { ConsoleChatbotFab } from '../ConsoleChatbotFab';

vi.mock('@object-ui/i18n', () => ({
vi.mock('@object-ui/i18n', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useObjectTranslation: () => ({
t: (key: string, options?: Record<string, unknown>) => {
if (key === 'topbar.openAssistant') return `Open ${String(options?.name)} assistant`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ import '@testing-library/jest-dom/vitest';
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { render, screen, waitFor, act } from '@testing-library/react';

vi.mock('@object-ui/i18n', () => ({
vi.mock('@object-ui/i18n', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useObjectTranslation: () => ({
t: (key: string, options?: Record<string, unknown>) => String(options?.defaultValue ?? key),
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import '@testing-library/jest-dom/vitest';
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { render, screen, waitFor } from '@testing-library/react';

vi.mock('@object-ui/i18n', () => ({
vi.mock('@object-ui/i18n', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useObjectTranslation: () => ({
t: (key: string, options?: Record<string, unknown>) => String(options?.defaultValue ?? key),
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import * as React from 'react';
import { afterEach, describe, expect, it, vi } from 'vitest';
import { fireEvent, render, screen, waitFor } from '@testing-library/react';

vi.mock('@object-ui/i18n', () => ({
vi.mock('@object-ui/i18n', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useObjectTranslation: () => ({
t: (_k: string, o?: { defaultValue?: string }) => o?.defaultValue ?? _k,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ vi.mock('../PreviewModeContext', () => ({
markPreviewExit: vi.fn(),
PREVIEW_QUERY_FLAG: 'preview',
}));
vi.mock('@object-ui/i18n', () => ({
vi.mock('@object-ui/i18n', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useObjectTranslation: () => ({
t: (_k: string, o?: { defaultValue?: string }) => o?.defaultValue ?? _k,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ vi.mock('./MetadataInspector', () => ({
}));
vi.mock('../providers/AdapterProvider', () => ({ useAdapter: () => ({}) }));
vi.mock('../providers/ExpressionProvider', () => ({ useExpressionContext: () => ({ app: undefined }) }));
vi.mock('@object-ui/i18n', () => ({
vi.mock('@object-ui/i18n', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useObjectTranslation: () => ({ t: (k: string) => k }),
useObjectLabel: () => ({
dashboardLabel: ({ label, name }: any) => label ?? name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ vi.mock('./MetadataInspector', () => ({
}));
vi.mock('../providers/AdapterProvider', () => ({ useAdapter: () => ({}) }));
vi.mock('../providers/ExpressionProvider', () => ({ useExpressionContext: () => ({ app: undefined }) }));
vi.mock('@object-ui/i18n', () => ({
vi.mock('@object-ui/i18n', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useObjectTranslation: () => ({ t: (k: string) => k }),
// Pass-through: the i18n bundle is a SEPARATE channel with its own tests, and
// resolving through it here would let a bundle entry answer for the key this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ vi.mock('./runtime-metadata-persistence', () => ({ persistRuntimeMetadata: vi.fn
vi.mock('../providers/AdapterProvider', () => ({ useAdapter: () => ({}) }));
vi.mock('../providers/ExpressionProvider', () => ({ useExpressionContext: () => ({ app: undefined }) }));
vi.mock('@object-ui/auth', () => ({ useWorkspaceAdminStatus: () => ({ isAdmin: true, isResolved: true }) }));
vi.mock('@object-ui/i18n', () => ({
vi.mock('@object-ui/i18n', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useObjectTranslation: () => ({ t: (k: string) => k }),
createSafeTranslation: (defaults: Record<string, string>) => () => ({
t: (k: string) => defaults?.[k] ?? k,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ vi.mock('../../utils/getIcon', () => ({
* worth anything if the APPROVER NAMES actually land in it, so the assertions
* below read the composed English sentence rather than a key name.
*/
vi.mock('@object-ui/i18n', () => ({
vi.mock('@object-ui/i18n', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useObjectLabel: () => ({
actionLabel: (_o: unknown, _n: unknown, fallback: string) => fallback,
actionConfirm: (_o: unknown, _n: unknown, fallback?: string) => fallback,
Expand Down
Loading
Loading