fix: bound formatter memory and improve operations workflows

This commit is contained in:
hectorzhao
2026-09-08 12:46:15 +08:00
parent 50ae37242b
commit 2c228a94e1
27 changed files with 4013 additions and 1230 deletions
+29
View File
@@ -0,0 +1,29 @@
import { fireEvent, render, screen } from '@testing-library/react';
import { describe, expect, it, vi } from 'vitest';
import { Modal } from './Modal';
describe('Modal close policy', () => {
it('keeps an explicitly locked form open on mask and Escape but permits the close button', () => {
const close = vi.fn();
render(
<Modal open title="创建通道" closeOnBackdrop={false} closeOnEscape={false} onClose={close}>
</Modal>,
);
fireEvent.mouseDown(document.querySelector('.ui-modal__mask')!);
fireEvent.keyDown(document, { key: 'Escape' });
expect(close).not.toHaveBeenCalled();
fireEvent.click(screen.getByRole('button', { name: '关闭' }));
expect(close).toHaveBeenCalledOnce();
});
it('preserves mask closing by default for existing consumers', () => {
const close = vi.fn();
render(
<Modal open title="普通弹窗" onClose={close}>
</Modal>,
);
fireEvent.mouseDown(document.querySelector('.ui-modal__mask')!);
expect(close).toHaveBeenCalledOnce();
});
});