Files
cd59def04b refactor(spaces): migrate Spaces feature to the new architecture (#7082)
* refactor(spaces): migrate Spaces feature to the new architecture

* refactor(spaces): update import path for useCurrentSpaceId hook

* refactor(spaces): move Spaces page components to the new feature architecture folder

* refactor(spaces): consolidate imports for hooks and member roles in spaces feature

* refactor(spaces): consolidate hook imports

* refactor(spaces): consolidate imports across components

* refactor(spaces): update component structure

* test: fix tests

* refactor(spaces): fix review comments

* refactor(tests): update analytics mocks across multiple test files

* refactor(spaces): remove unused hook imports from InviteBanner and SpaceCard components

* refactor(spaces): remove useSpaceSafeCount hook and its import

* fix: resolve circular dependency in useIsSpaceRoute

Import useCurrentSpaceId directly from hook file instead of barrel
to break circular dependency chain:
__core__/index → createFeatureHandle → useChains → ... → useIsSpaceRoute
→ features/spaces/index → __core__/index

This was causing "Cannot access '_createFeatureHandle' before
initialization" in 4 test suites.

* fix: resolve circular deps and feature architecture violation

- utils.ts: use relative import for MemberStatus/MemberRole instead of
  barrel to break circular dependency (utils ↔ index.ts)
- useIsSpaceRoute: inline Redux selector instead of importing
  useCurrentSpaceId from internal feature path, fixing both the circular
  dep chain and the feature architecture rule violation

---------

Co-authored-by: katspaugh <[email protected]>

Co-authored-by: Hanzo Dev <[email protected]>
2026-02-20 13:24:06 +01:00

47 lines
1.4 KiB
TypeScript

/**
* Reusable mock for @/services/analytics
*
* This mock provides common analytics exports including EventType enum
* that can be used across test files.
*
* Usage (from @safe-global/web tests):
* jest.mock('@/services/analytics', () =>
* (jest.requireActual('@safe-global/test/mocks/analytics') as { createAnalyticsMock: () => object }).createAnalyticsMock(),
* )
*
* Or with additional test-specific overrides:
* jest.mock('@/services/analytics', () => ({
* ...(jest.requireActual('@safe-global/test/mocks/analytics') as { createAnalyticsMock: () => object }).createAnalyticsMock(),
* ASSETS_EVENTS: { ... },
* }))
*
* Note: Use jest.requireActual() inside jest.mock() to avoid hoisting issues with ES6 imports.
*/
export const EventType = {
PAGEVIEW: 'pageview',
CLICK: 'customClick',
META: 'metadata',
SAFE_APP: 'safeApp',
SAFE_CREATED: 'safe_created',
SAFE_ACTIVATED: 'safe_activated',
SAFE_OPENED: 'safe_opened',
WALLET_CONNECTED: 'wallet_connected',
TX_CREATED: 'tx_created',
TX_CONFIRMED: 'tx_confirmed',
TX_EXECUTED: 'tx_executed',
} as const
/**
* Factory function that creates a fresh analytics mock.
* Use this in jest.mock() calls to avoid hoisting issues.
*/
export function createAnalyticsMock() {
return {
trackEvent: jest.fn(),
trackSafeAppEvent: jest.fn(),
trackMixpanelEvent: jest.fn(),
EventType,
}
}