import { describe, it, expect, beforeEach, vi } from 'vitest';
import { mount, flushPromises } from '@vue/test-utils';
import { createPinia, setActivePinia } from 'pinia';
import { createVuetify } from 'vuetify';
import DashboardView from '../../resources/js/views/DashboardView.vue';

describe('DashboardView — KPI count-up', () => {
    beforeEach(() => {
        setActivePinia(createPinia());
        Object.defineProperty(window, 'matchMedia', {
            writable: true,
            configurable: true,
            value: vi.fn().mockReturnValue({ matches: false, addEventListener: vi.fn(), removeEventListener: vi.fn() }),
        });
    });

    it('renders KPI strip with JetBrains Mono number', async () => {
        const w = mount(DashboardView, {
            global: { plugins: [createVuetify()], stubs: { RouterLink: true } },
        });
        await flushPromises();
        const kpis = w.findAll('.ld-kpi__value');
        expect(kpis.length).toBeGreaterThan(0);
        expect(kpis[0].classes()).toContain('ld-mono');
    });

    it('shows live pulse indicator', () => {
        const w = mount(DashboardView, {
            global: { plugins: [createVuetify()], stubs: { RouterLink: true } },
        });
        expect(w.find('.ld-pulse').exists()).toBe(true);
    });
});
