Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

test(managed): the mock factory brings its own imports

Mauriceede54d10cd87
diff --git a/client/tests/unit/mobile/admin/MAdmin.managed.test.tsx b/client/tests/unit/mobile/admin/MAdmin.managed.test.tsx
index f14c681a9..79a4fa542 100644
--- a/client/tests/unit/mobile/admin/MAdmin.managed.test.tsx
+++ b/client/tests/unit/mobile/admin/MAdmin.managed.test.tsx
@@ -1,4 +1,3 @@
-import { CreditCard, LifeBuoy } from 'lucide-react';
import { http, HttpResponse } from 'msw';
import { Route, Routes } from 'react-router';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
@@ -11,28 +10,33 @@ import { resetAllStores, seedStore } from '../../../helpers/store';
// An install that fills the admin-tab attachment point (managed/index.tsx): one tab
// with a phone layout of its own, one without.
-vi.mock('../../../../src/managed', () => ({
- managedRoutes: [],
- managedNavItems: [],
- visibleManagedNavItems: () => [],
- managedAdminTabs: [
- {
- id: 'subscription',
- label: 'Subscription',
- Icon: CreditCard,
- group: 'maintenance',
- element: <div data-testid="desktop-subscription" />,
- mobileElement: <div data-testid="phone-subscription" />,
- },
- {
- id: 'support',
- label: 'Help and support',
- Icon: LifeBuoy,
- group: 'maintenance',
- element: <div data-testid="desktop-support" />,
- },
- ],
-}));
+vi.mock('../../../../src/managed', async () => {
+ // vi.mock is hoisted above the imports, so the factory brings its own.
+ const { createElement } = await import('react');
+ const { CreditCard, LifeBuoy } = await import('lucide-react');
+ return {
+ managedRoutes: [],
+ managedNavItems: [],
+ visibleManagedNavItems: () => [],
+ managedAdminTabs: [
+ {
+ id: 'subscription',
+ label: 'Subscription',
+ Icon: CreditCard,
+ group: 'maintenance',
+ element: createElement('div', { 'data-testid': 'desktop-subscription' }),
+ mobileElement: createElement('div', { 'data-testid': 'phone-subscription' }),
+ },
+ {
+ id: 'support',
+ label: 'Help and support',
+ Icon: LifeBuoy,
+ group: 'maintenance',
+ element: createElement('div', { 'data-testid': 'desktop-support' }),
+ },
+ ],
+ };
+});
function renderAdmin() {
return render(