/* @vitest-environment jsdom */

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

import { PlatformAcknowledgeStatusDialog } from './PlatformAcknowledgeStatusDialog';

test('renders a standard acknowledge action and closes through 知道了', () => {
  const onClose = vi.fn();

  render(
    <PlatformAcknowledgeStatusDialog
      status="error"
      title="提示"
      description="至少保留一个可扮演角色。"
      onClose={onClose}
    />,
  );

  const action = screen.getByRole('button', { name: '知道了' });

  expect(action.className).toContain('platform-button');
  fireEvent.click(action);
  expect(onClose).toHaveBeenCalledTimes(1);
});

test('supports custom action styling and header notice layout', () => {
  render(
    <PlatformAcknowledgeStatusDialog
      status="error"
      title="发布失败"
      description="还缺少 16 个基础动作"
      onClose={() => {}}
      showHeader
      showCloseButton
      closeOnBackdrop
      iconLabel="发布失败提示"
      actionClassName="border-slate-950 bg-slate-950 text-white"
    />,
  );

  const action = screen.getByRole('button', { name: '知道了' });
  const dialog = screen.getByRole('dialog', { name: '发布失败' });

  expect(action.className).toContain('border-slate-950');
  expect(action.className).toContain('bg-slate-950');
  expect(dialog.querySelector('[aria-label="发布失败提示"]')).toBeTruthy();
});
