import { fireEvent, render, screen } from '@testing-library/react';
import { describe, expect, test, vi } from 'vitest';
import { MetricActionButton } from './MetricActionButton';

describe('MetricActionButton', () => {
  test('uses a pressed Semi button for the active metric filter', () => {
    const onClick = vi.fn();
    render(<MetricActionButton label="未处理" value="12" tone="warning" active ariaLabel="筛选未处理告警，共 12 条" onClick={onClick} />);

    const button = screen.getByRole('button', { name: '筛选未处理告警，共 12 条', pressed: true });
    expect(button).toHaveClass('semi-button', 'v2-metric-action', 'is-active');
    fireEvent.click(button);
    expect(onClick).toHaveBeenCalledTimes(1);
  });
});
