071faa482c
纳入 AGC Cargo workspace 的统一 rustfmt 检查与格式化入口 完成项目 TypeScript/Prettier 与 Rust 全量格式化 修复 Pingora expected executable 门禁的空白敏感误报 同步开发运维文档与 AGC skill pack 格式化忽略规则
56 lines
1.7 KiB
TypeScript
56 lines
1.7 KiB
TypeScript
/* @vitest-environment jsdom */
|
|
|
|
import { fireEvent, render, screen, within } from '@testing-library/react';
|
|
import { expect, test, vi } from 'vitest';
|
|
|
|
import { PlatformUnsavedLeaveConfirmDialog } from './PlatformUnsavedLeaveConfirmDialog';
|
|
|
|
test('renders the platform variant with leave/continue actions', () => {
|
|
const onClose = vi.fn();
|
|
const onConfirm = vi.fn();
|
|
|
|
render(
|
|
<PlatformUnsavedLeaveConfirmDialog
|
|
open
|
|
title="确认关闭"
|
|
onClose={onClose}
|
|
onConfirm={onConfirm}
|
|
>
|
|
当前修改尚未保存,确认关闭吗?
|
|
</PlatformUnsavedLeaveConfirmDialog>,
|
|
);
|
|
|
|
const dialog = screen.getByRole('dialog', { name: '确认关闭' });
|
|
|
|
expect(
|
|
within(dialog).getByText('当前修改尚未保存,确认关闭吗?'),
|
|
).toBeTruthy();
|
|
|
|
fireEvent.click(within(dialog).getByRole('button', { name: '继续编辑' }));
|
|
expect(onClose).toHaveBeenCalledTimes(1);
|
|
|
|
fireEvent.click(within(dialog).getByRole('button', { name: '确认关闭' }));
|
|
expect(onConfirm).toHaveBeenCalledTimes(1);
|
|
});
|
|
|
|
test('supports pixel variant with custom confirm label', () => {
|
|
render(
|
|
<PlatformUnsavedLeaveConfirmDialog
|
|
open
|
|
title="确认退出"
|
|
confirmLabel="仍然退出"
|
|
variant="pixel"
|
|
onClose={() => {}}
|
|
onConfirm={() => {}}
|
|
>
|
|
当前生成画面还未保存。
|
|
</PlatformUnsavedLeaveConfirmDialog>,
|
|
);
|
|
|
|
const dialog = screen.getByRole('dialog', { name: '确认退出' });
|
|
|
|
expect(dialog.className).toContain('pixel-modal-shell');
|
|
expect(within(dialog).getByRole('button', { name: '仍然退出' })).toBeTruthy();
|
|
expect(within(dialog).getByRole('button', { name: '继续编辑' })).toBeTruthy();
|
|
});
|