import { computed, ref } from 'vue' import { mount } from '@vue/test-utils' import { beforeEach, describe, expect, it, vi } from 'vitest' import AppTopBar from '../../components/AppTopBar.vue' const heartbeat = vi.hoisted(() => vi.fn((_options: unknown) => ({ clientId: 'presence-tab', isRunning: ref(false), sendNow: vi.fn(), }))) vi.mock('../../composables/usePresenceHeartbeat', () => ({ usePresenceHeartbeat: heartbeat, })) vi.mock('../../composables/usePlatformContext', () => ({ usePlatformContext: vi.fn(() => ({ isIntegrated: computed(() => true), context: ref({ isIntegrated: true, theme: 'system' }), plugin: computed(() => ({ id: 'LEAF', name: 'Leaf Analysis' })), user: computed(() => undefined), theme: computed(() => 'system' as const), features: computed(() => undefined), navigate: vi.fn(), notify: vi.fn(), sendToPlatform: vi.fn(), })), })) describe('AppTopBar presence', () => { beforeEach(() => vi.clearAllMocks()) it('should report the integrated plugin id as the presence scope', () => { const wrapper = mount(AppTopBar, { props: { title: 'LEAF' } }) const options = heartbeat.mock.calls[0]?.[0] as { enabled: { value: boolean } scope: { value: string } } expect({ enabled: options.enabled.value, scope: options.scope.value }).toEqual({ enabled: true, scope: 'LEAF', }) wrapper.unmount() }) })