/* @vitest-environment jsdom */
import { render, screen, within } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { describe, expect, test, vi } from 'vitest';
import { PlatformProfileTaskCenterModal } from './PlatformProfileTaskCenterModal';
describe('PlatformProfileTaskCenterModal', () => {
test('renders claimable tasks and forwards claim action', async () => {
const user = userEvent.setup();
const onClaim = vi.fn();
render(
,
);
const dialog = screen.getByRole('dialog', { name: '每日任务' });
expect(within(dialog).getByText('66泥点')).toBeTruthy();
expect(within(dialog).getByText('每日登录')).toBeTruthy();
expect(within(dialog).getByText('1/1')).toBeTruthy();
expect(within(dialog).getByText('可领取')).toBeTruthy();
await user.click(within(dialog).getByRole('button', { name: '领取' }));
expect(onClaim).toHaveBeenCalledWith('task-1');
});
test('keeps incomplete tasks disabled', () => {
render(
,
);
expect(
screen.getByRole('button', { name: '未完成' }).hasAttribute('disabled'),
).toBe(true);
});
});