import { render } from '@testing-library/vue';
import { describe, expect, test, beforeEach, afterEach, vi } from 'vitest';
import UiSidebarPopover from '../UiSidebarPopover.vue';
import UiSidebarPopoverMenu from '../UiSidebarPopoverMenu.vue';
import UiSidebarPopoverMenuItem from '../UiSidebarPopoverMenuItem.vue';
import {
  createSidebarShell,
  mockMatchMediaDesktop,
} from './sidebar-test-helpers';

beforeEach(() => mockMatchMediaDesktop());
afterEach(() => vi.restoreAllMocks());

describe('UiSidebarPopover', () => {
  test('renders trigger label and menu content', () => {
    const { getByText } = render(
      createSidebarShell(
        `
        <UiSidebarPopover label="Switch team" tooltip="Teams">
          <UiSidebarPopoverMenu label="Workspace">
            <UiSidebarPopoverMenuItem label="Alpha" />
          </UiSidebarPopoverMenu>
        </UiSidebarPopover>
      `,
        {
          UiSidebarPopover,
          UiSidebarPopoverMenu,
          UiSidebarPopoverMenuItem,
        },
      ),
    );
    expect(getByText('Switch team')).toBeInTheDocument();
  });
});
