dbfdb9b99b
新增 PlatformMudPointConfirmDialog 统一承接标准泥点消耗确认壳层 迁移拼图与抓大鹅创作工作台复用共享泥点确认弹窗 迁移拼图与抓大鹅结果页素材生成流程复用共享泥点确认弹窗 补充共享组件测试并更新 PlatformUiKit 收口文档与决策记录
54 lines
1.5 KiB
TypeScript
54 lines
1.5 KiB
TypeScript
/* @vitest-environment jsdom */
|
|
|
|
import { fireEvent, render, screen, within } from '@testing-library/react';
|
|
import { expect, test, vi } from 'vitest';
|
|
|
|
import { PlatformMudPointConfirmDialog } from './PlatformMudPointConfirmDialog';
|
|
|
|
test('renders standard mud point confirmation copy and forwards confirm', () => {
|
|
const onClose = vi.fn();
|
|
const onConfirm = vi.fn();
|
|
|
|
render(
|
|
<PlatformMudPointConfirmDialog
|
|
open
|
|
points={8}
|
|
onClose={onClose}
|
|
onConfirm={onConfirm}
|
|
portal={false}
|
|
/>,
|
|
);
|
|
|
|
const dialog = screen.getByRole('dialog', { name: '确认消耗泥点' });
|
|
|
|
expect(within(dialog).getByText('消耗 8 泥点')).toBeTruthy();
|
|
|
|
fireEvent.click(within(dialog).getByRole('button', { name: '确定' }));
|
|
expect(onConfirm).toHaveBeenCalledTimes(1);
|
|
});
|
|
|
|
test('supports extra detail copy and close button override', () => {
|
|
const onClose = vi.fn();
|
|
|
|
render(
|
|
<PlatformMudPointConfirmDialog
|
|
open
|
|
points={7}
|
|
title="保存正式素材"
|
|
description="角色形象"
|
|
onClose={onClose}
|
|
onConfirm={vi.fn()}
|
|
showCloseButton={false}
|
|
portal={false}
|
|
>
|
|
本次会覆盖当前待确认素材。
|
|
</PlatformMudPointConfirmDialog>,
|
|
);
|
|
|
|
const dialog = screen.getByRole('dialog', { name: '保存正式素材' });
|
|
|
|
expect(within(dialog).getByText('消耗 7 泥点')).toBeTruthy();
|
|
expect(within(dialog).getByText('本次会覆盖当前待确认素材。')).toBeTruthy();
|
|
expect(screen.queryByRole('button', { name: '关闭' })).toBeNull();
|
|
});
|