/* @vitest-environment jsdom */

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

import { PlatformRuntimeStatusToast } from './PlatformRuntimeStatusToast';

test('renders error runtime toast with alert semantics', () => {
  render(
    <PlatformRuntimeStatusToast tone="error" className="mt-2">
      操作失败
    </PlatformRuntimeStatusToast>,
  );

  const toast = screen.getByRole('alert');

  expect(toast.className).toContain('platform-runtime-status-toast');
  expect(toast.className).toContain('rounded-full');
  expect(toast.className).toContain(
    'text-[var(--platform-button-danger-text)]',
  );
  expect(toast.className).toContain('mt-2');
  expect(toast.getAttribute('aria-live')).toBe('assertive');
});

test('supports dark and solid runtime surfaces', () => {
  const { rerender } = render(
    <PlatformRuntimeStatusToast tone="success" surface="dark" shape="rounded">
      命中
    </PlatformRuntimeStatusToast>,
  );

  expect(screen.getByRole('status').className).toContain(
    'border-emerald-200/35',
  );
  expect(screen.getByRole('status').className).toContain('rounded-[1.2rem]');

  rerender(
    <PlatformRuntimeStatusToast tone="error" surface="solid" size="md">
      运行失败
    </PlatformRuntimeStatusToast>,
  );

  expect(screen.getByRole('alert').className).toContain('bg-rose-600');
  expect(screen.getByRole('alert').className).toContain('px-4');
});
