refactor(gui-v2): imports-first in shell specs, drop eslint-disable
Vitest hoists vi.mock()/vi.hoisted() above all imports, so the component import can sit with the other imports (import/first satisfied) without the eslint-disable-next-line directives — the mock factories only deref their refs at mount time. Honors the no-eslint-disable rule. 28/28 affected specs green. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -21,12 +21,16 @@ import { mount } from '@vue/test-utils'
|
||||
import { ref } from 'vue'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { useShellUiStore } from '@/stores/useShellUiStore'
|
||||
import AppSidebar from '@/components-v2/layout/AppSidebar.vue'
|
||||
import type { V2NavGroup } from '@/types/v2/nav'
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Mock @vueuse/core so we can control `isMobile` per test.
|
||||
// AppSidebar uses useBreakpoints(breakpointsTailwind).smaller('lg').
|
||||
// We return an object whose .smaller() method returns a controllable ref.
|
||||
// Vitest hoists vi.mock() above all imports, so the mock is registered
|
||||
// before AppSidebar's transitive @vueuse/core import resolves; the
|
||||
// factory only dereferences mockIsMobileRef inside .smaller(), invoked
|
||||
// at component-mount time (well after this const initialises).
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const mockIsMobileRef = ref(false)
|
||||
@@ -38,13 +42,6 @@ vi.mock('@vueuse/core', () => ({
|
||||
}),
|
||||
}))
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Import component AFTER mock is set up
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// eslint-disable-next-line import/first -- intentional: mock must be declared first
|
||||
import AppSidebar from '@/components-v2/layout/AppSidebar.vue'
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// A minimal nav group fixture
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user