e6b3199490
之前遇到几次弹窗的样式不生效,bug 现在在画布agent的删除对话弹窗又出现了, 这个pr把类似的修改集中到最下层的UnifiedModal,适用于所有的modal, 一些特殊的modal有特殊处理. 画布agent的删除对话弹窗  --------- Co-authored-by: 段舒康 <kdletters@qq.com> Reviewed-on: http://192.168.35.82/git/GenarrativeAI/Genarrative/pulls/122 Reviewed-by: 段舒康 <kdletters@qq.com> Co-authored-by: 王德宇 <kvtodev@outlook.com> Co-committed-by: 王德宇 <kvtodev@outlook.com>
66 lines
2.0 KiB
TypeScript
66 lines
2.0 KiB
TypeScript
/* @vitest-environment jsdom */
|
|
|
|
import { fireEvent, render, screen, waitFor, within } from '@testing-library/react';
|
|
import { afterEach, expect, test, vi } from 'vitest';
|
|
|
|
import * as clipboardService from '../../services/clipboard';
|
|
import { PlatformReportDialog } from './PlatformReportDialog';
|
|
|
|
vi.mock('../../services/clipboard', () => ({
|
|
copyTextToClipboard: vi.fn(),
|
|
}));
|
|
|
|
vi.mock('../auth/AuthUiContext', () => ({
|
|
useAuthUi: () => ({ platformTheme: 'dark' }),
|
|
}));
|
|
|
|
afterEach(() => {
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
test('renders report fields and copies the joined report lines', async () => {
|
|
vi.mocked(clipboardService.copyTextToClipboard).mockResolvedValue(true);
|
|
|
|
render(
|
|
<PlatformReportDialog
|
|
open
|
|
title="统一报告"
|
|
onClose={() => {}}
|
|
copyIdleLabel="复制内容"
|
|
fields={[
|
|
{ label: '来源', value: '拼图草稿 puzzle-session-1' },
|
|
{ label: '状态', value: '已完成', multiline: true },
|
|
]}
|
|
/>,
|
|
);
|
|
|
|
const dialog = screen.getByRole('dialog', { name: '统一报告' });
|
|
expect(dialog.parentElement?.className).toContain('platform-theme--light');
|
|
expect(dialog.parentElement?.className).not.toContain('platform-theme--dark');
|
|
expect(within(dialog).getByText('拼图草稿 puzzle-session-1')).toBeTruthy();
|
|
expect(within(dialog).getByText('已完成')).toBeTruthy();
|
|
|
|
fireEvent.click(within(dialog).getByRole('button', { name: '复制内容' }));
|
|
|
|
expect(clipboardService.copyTextToClipboard).toHaveBeenCalledWith(
|
|
['来源:拼图草稿 puzzle-session-1', '状态:已完成'].join('\n'),
|
|
);
|
|
await waitFor(() => {
|
|
expect(within(dialog).getByRole('button', { name: '已复制' })).toBeTruthy();
|
|
});
|
|
});
|
|
|
|
test('does not render report fields when closed', () => {
|
|
render(
|
|
<PlatformReportDialog
|
|
open={false}
|
|
title="统一报告"
|
|
onClose={() => {}}
|
|
copyIdleLabel="复制内容"
|
|
fields={[]}
|
|
/>,
|
|
);
|
|
|
|
expect(screen.queryByRole('dialog', { name: '统一报告' })).toBeNull();
|
|
});
|