import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// @vitest-environment happy-dom
import { describe, expect, it, vi } from 'vitest';
import { render, screen } from '@testing-library/react';
import { InspectorPane, InspectorPaneBody, InspectorPaneFooter, InspectorPaneHeader, InspectorPaneSection, SplitPaneLayout, SplitPaneList, } from '../../components/ui/InspectorPane.js';
function Pane({ open }) {
    return (_jsxs(SplitPaneLayout, { children: [_jsx(SplitPaneList, { children: _jsx("table", { "aria-label": "Rows" }) }), _jsxs(InspectorPane, { open: open, width: 420, "aria-label": "Row editor", children: [_jsx(InspectorPaneHeader, { onClose: () => { }, children: _jsx("span", { children: "Editing" }) }), _jsx(InspectorPaneBody, { children: _jsx(InspectorPaneSection, { title: "Details", children: "content" }) }), _jsx(InspectorPaneFooter, { children: _jsx("button", { type: "button", children: "Save" }) })] })] }));
}
describe('InspectorPane', () => {
    it('renders pane content with a labelled region when open', () => {
        render(_jsx(Pane, { open: true }));
        expect(screen.getByRole('region', { name: 'Row editor' })).toBeTruthy();
        expect(screen.getByText('Editing')).toBeTruthy();
        expect(screen.getByText('Details')).toBeTruthy();
        expect(screen.getByRole('button', { name: 'Save' })).toBeTruthy();
    });
    it('collapses to zero width and hides content when closed', () => {
        const { container } = render(_jsx(Pane, { open: false }));
        const shell = container.querySelector('[aria-hidden="true"]');
        expect(shell).toBeTruthy();
        expect(shell.style.width).toBe('0px');
        expect(screen.queryByText('Editing')).toBeNull();
    });
    it('close button in the header fires onClose with an accessible label', () => {
        const onClose = vi.fn();
        render(_jsx(InspectorPane, { open: true, width: 400, "aria-label": "Detail", children: _jsx(InspectorPaneHeader, { onClose: onClose, closeLabel: "Close detail", children: _jsx("span", { children: "Title" }) }) }));
        screen.getByRole('button', { name: 'Close detail' }).click();
        expect(onClose).toHaveBeenCalledTimes(1);
    });
});
//# sourceMappingURL=inspector-pane.test.js.map