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

afterEach(cleanup);

test('renders one accessible Semi detail sheet with shared identity and status', () => {
  const onCancel = vi.fn();
  render(<WorkspaceDetailSideSheet
    className="test-detail-sheet"
    visible
    ariaLabel="车辆证据详情"
    closeLabel="关闭证据详情"
    title="车辆详情"
    description="粤A00001 · VIN-001"
    badge="状态正常"
    badgeColor="green"
    onCancel={onCancel}
  >
    <p>详情内容</p>
  </WorkspaceDetailSideSheet>);

  const dialog = screen.getByRole('dialog', { name: '车辆证据详情' });
  expect(dialog.closest('.semi-sidesheet')).toHaveClass('v2-workspace-detail-sidesheet', 'test-detail-sheet');
  expect(screen.getByText('粤A00001 · VIN-001')).toBeInTheDocument();
  expect(screen.getByText('状态正常').closest('.semi-tag')).toHaveClass('semi-tag-green-light');
  fireEvent.click(screen.getByRole('button', { name: '关闭证据详情' }));
  expect(onCancel).toHaveBeenCalledTimes(1);
});
