/* @vitest-environment jsdom */ import { fireEvent, render, screen } from '@testing-library/react'; import { expect, test, vi } from 'vitest'; import { PlatformDetailTopbar } from './PlatformDetailTopbar'; test('renders pill back action with trailing slot', () => { const onBack = vi.fn(); render( 已发布} />, ); const button = screen.getByRole('button', { name: '返回' }); expect(button.className).toContain('platform-button--ghost'); expect(button.className).toContain('px-3'); expect(screen.getByText('已发布')).toBeTruthy(); fireEvent.click(button); expect(onBack).toHaveBeenCalledTimes(1); }); test('renders icon back action and centered title', () => { render( 占位} />, ); const button = screen.getByRole('button', { name: '返回' }); const title = screen.getByText('详情'); expect(button.className).toContain('platform-icon-button'); expect(button.className).toContain('detail-icon-back'); expect(title.className).toContain('detail-topbar-title'); });