/* @vitest-environment jsdom */

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

import { PlatformDetailShareActions } from './PlatformDetailShareActions';

test('renders overlay detail share actions with copied share state', () => {
  render(
    <PlatformDetailShareActions
      workCode="CW-001"
      copyState="idle"
      onCopyWorkCode={vi.fn()}
      shareState="copied"
      onShare={vi.fn()}
      shareAriaLabel="分享作品 测试世界"
      leading={<span>已发布</span>}
      variant="overlay"
    />,
  );

  const codeButton = screen.getByRole('button', { name: '复制作品号 CW-001' });
  const shareButton = screen.getByRole('button', { name: '分享作品 测试世界' });

  expect(screen.getByText('已发布')).toBeTruthy();
  expect(codeButton.className).toContain('bg-white/72');
  expect(codeButton.className).toContain('tracking-[0.18em]');
  expect(shareButton.className).toContain('bg-white/72');
  expect(screen.getByText('已复制')).toBeTruthy();
});

test('renders solid detail share actions with compact work code chip', () => {
  render(
    <PlatformDetailShareActions
      workCode="PZ-001"
      copyState="idle"
      onCopyWorkCode={vi.fn()}
      shareState="idle"
      onShare={vi.fn()}
      shareAriaLabel="分享作品 拼图世界"
      leading={<span>已发布</span>}
      variant="solid"
    />,
  );

  const codeButton = screen.getByRole('button', { name: 'PZ-001' });
  const shareButton = screen.getByRole('button', { name: '分享作品 拼图世界' });

  expect(codeButton.className).toContain('bg-[var(--platform-neutral-bg)]');
  expect(shareButton.className).toContain('bg-[var(--platform-neutral-bg)]');
  expect(screen.getByText('已发布')).toBeTruthy();
});
