补强 UI 预览测试清理
为预览测试统一注册 afterEach cleanup,避免测试间残留 DOM。 保留原有 UI 选择与拖拽交互行为。
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// @vitest-environment jsdom
|
||||
|
||||
import { fireEvent, render, screen } from '@testing-library/react';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { cleanup, fireEvent, render, screen } from '@testing-library/react';
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import type { Node as UiNode } from '../src/features/ui-editor/types/Node';
|
||||
import type { UITree } from '../src/features/ui-editor/types/UITree';
|
||||
@@ -9,6 +9,10 @@ import { ExclusiveChildrenTabs } from '../src/view/ui-editor/components/preview/
|
||||
import { UiTreeRenderer } from '../src/view/ui-editor/components/preview/UiTreeRenderer';
|
||||
import { UiNodeContextMenu } from '../src/view/ui-editor/components/UiNodeContextMenu';
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
});
|
||||
|
||||
function node(id: string, children: UiNode[] = []): UiNode {
|
||||
return {
|
||||
id,
|
||||
@@ -286,7 +290,7 @@ describe('UI tree preview visibility', () => {
|
||||
it('uses a highlighted tab bar for exclusive child switching', () => {
|
||||
const parent = exclusiveNode('parent', [node('child-a'), node('child-b')]);
|
||||
const onSelectChild = vi.fn();
|
||||
const rendered = render(
|
||||
render(
|
||||
<ExclusiveChildrenTabs
|
||||
parent={parent}
|
||||
isChildVisible={(nodeId) => nodeId === 'child-a'}
|
||||
@@ -306,7 +310,6 @@ describe('UI tree preview visibility', () => {
|
||||
).toBe('false');
|
||||
fireEvent.click(screen.getByRole('tab', { name: 'child-b' }));
|
||||
expect(onSelectChild).toHaveBeenCalledWith('child-b');
|
||||
rendered.unmount();
|
||||
});
|
||||
|
||||
it('keeps exclusive tab pointer gestures out of the parent node', () => {
|
||||
|
||||
Reference in New Issue
Block a user