import { describe, it, expect } from 'vitest';
import { screen } from '@testing-library/react';
import { renderWithProviders } from '../../test/utils';
import PurchaseSubscriptionSidebar from './PurchaseSubscriptionSidebar';

describe('PurchaseSubscriptionSidebar — settings menu', () => {
  it('lists secretary and staff management (moved out of the main nav)', () => {
    renderWithProviders(<PurchaseSubscriptionSidebar active="staff" />, { route: '/admin/staff' });

    const secretary = screen.getByRole('link', { name: 'مدیریت منشی' });
    const staff = screen.getByRole('link', { name: 'پرسنل' });

    expect(secretary).toHaveAttribute('href', '/admin/my-secretaries');
    expect(staff).toHaveAttribute('href', '/admin/staff');
  });

  it('highlights the active item (aria-current) for staff', () => {
    renderWithProviders(<PurchaseSubscriptionSidebar active="staff" />, { route: '/admin/staff' });
    expect(screen.getByRole('link', { name: 'پرسنل' })).toHaveAttribute('aria-current', 'page');
    expect(screen.getByRole('link', { name: 'مدیریت منشی' })).not.toHaveAttribute('aria-current');
  });

  // regression: the settings menu must stay visible on mobile (was `hidden lg:block`,
  // which dropped the whole menu below the lg breakpoint → no settings nav on phones).
  it('is not hidden on mobile', () => {
    renderWithProviders(<PurchaseSubscriptionSidebar active="staff" />, { route: '/admin/staff' });
    const nav = screen.getByRole('complementary', { name: 'منوی تنظیمات' });
    expect(nav.className).not.toMatch(/\bhidden\b/);
  });
});
