import { render, screen } from '@testing-library/react';
import { describe, it, expect } from 'vitest';
import { ListingsAttentionWidget } from '../listings-attention-widget';

describe('ListingsAttentionWidget', () => {
  it('renders the count and a link to the filtered listings page', () => {
    render(<ListingsAttentionWidget count={4} />);

    expect(screen.getByText(/4 listings need attention/i)).toBeInTheDocument();
    expect(screen.getByRole('link')).toHaveAttribute('href', '/seller/listings?filter=needs-attention');
  });

  it('pluralises correctly for 1', () => {
    render(<ListingsAttentionWidget count={1} />);
    expect(screen.getByText(/1 listing needs attention/i)).toBeInTheDocument();
  });

  it('renders an empty-state tone when count is 0', () => {
    render(<ListingsAttentionWidget count={0} />);
    expect(screen.getByText(/all listings look good/i)).toBeInTheDocument();
  });
});
