/* @vitest-environment jsdom */
import { fireEvent, render, screen, within } from '@testing-library/react';
import { expect, test, vi } from 'vitest';
import { PlatformToolModalShell } from './PlatformToolModalShell';
vi.mock('../auth/AuthUiContext', () => ({
useAuthUi: () => ({ platformTheme: 'light' }),
}));
test('renders shared platform tool modal shell with remapped panel chrome', () => {
render(
{}}
footer={}
panelClassName="!max-h-[min(90vh,42rem)]"
>
这里是正文
,
);
const dialog = screen.getByRole('dialog', { name: '发布拼图作品' });
expect(dialog.parentElement?.className).toContain('platform-theme--light');
expect(dialog.className).toContain('platform-remap-surface');
expect(dialog.className).toContain('shadow-[0_24px_80px_rgba(0,0,0,0.55)]');
expect(dialog.className).toContain('!max-h-[min(90vh,42rem)]');
expect(within(dialog).getByText('这里是正文')).toBeTruthy();
expect(within(dialog).getByRole('button', { name: '取消' })).toBeTruthy();
});
test('supports fixed aria label while keeping visible title text', () => {
const onClose = vi.fn();
render(
这里是正文
,
);
const dialog = screen.getByRole('dialog', { name: '关卡详情' });
expect(within(dialog).getByText('雨夜猫街')).toBeTruthy();
expect(screen.getByRole('button', { name: '关闭关卡详情' })).toBeTruthy();
fireEvent.click(dialog.parentElement as HTMLElement);
expect(onClose).toHaveBeenCalledTimes(1);
});