"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("@testing-library/react");
require("@testing-library/jest-dom");
const FilePreview_1 = __importDefault(require("./FilePreview"));
const Chatbot_1 = require("../Chatbot");
const react_core_1 = require("@patternfly/react-core");
describe('FilePreview', () => {
    const defaultProps = {
        isModalOpen: true,
        handleModalToggle: jest.fn(),
        fileName: 'test-file.txt',
        children: 'File content preview'
    };
    beforeEach(() => {
        jest.clearAllMocks();
    });
    it('should render with basic props', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(FilePreview_1.default, Object.assign({}, defaultProps)));
        expect(react_1.screen.getByText('File preview')).toBeInTheDocument();
        expect(react_1.screen.getByText('test-file.txt')).toBeInTheDocument();
    });
    it('should render with custom title', () => {
        const customTitle = 'Custom file preview title';
        (0, react_1.render)((0, jsx_runtime_1.jsx)(FilePreview_1.default, Object.assign({}, defaultProps, { title: customTitle })));
        expect(react_1.screen.getByRole('heading', { name: customTitle })).toBeTruthy();
    });
    it('should handle modal toggle when closed', () => {
        const mockToggle = jest.fn();
        (0, react_1.render)((0, jsx_runtime_1.jsx)(FilePreview_1.default, Object.assign({}, defaultProps, { isModalOpen: false, handleModalToggle: mockToggle })));
        expect(react_1.screen.queryByRole('dialog')).not.toBeInTheDocument();
    });
    it('should apply default display mode class', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(FilePreview_1.default, Object.assign({}, defaultProps)));
        const modal = react_1.screen.getByRole('dialog');
        expect(modal).toHaveClass('pf-chatbot__file-preview-modal--default');
    });
    it('should apply custom display mode class', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(FilePreview_1.default, Object.assign({}, defaultProps, { displayMode: Chatbot_1.ChatbotDisplayMode.fullscreen })));
        const modal = react_1.screen.getByRole('dialog');
        expect(modal).toHaveClass('pf-chatbot__file-preview-modal--fullscreen');
    });
    it('should apply compact styling when isCompact is true', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(FilePreview_1.default, Object.assign({}, defaultProps, { isCompact: true })));
        const modal = react_1.screen.getByRole('dialog');
        expect(modal).toHaveClass('pf-m-compact');
    });
    it('should not apply compact styling when isCompact is false', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(FilePreview_1.default, Object.assign({}, defaultProps, { isCompact: false })));
        const modal = react_1.screen.getByRole('dialog');
        expect(modal).not.toHaveClass('pf-m-compact');
    });
    it('should apply custom className', () => {
        const customClass = 'custom-file-preview';
        (0, react_1.render)((0, jsx_runtime_1.jsx)(FilePreview_1.default, Object.assign({}, defaultProps, { className: customClass })));
        const modal = react_1.screen.getByRole('dialog');
        expect(modal).toHaveClass(customClass);
    });
    it('should pass through additional props to ChatbotModal', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(FilePreview_1.default, Object.assign({}, defaultProps, { "data-testid": "file-preview-modal" })));
        const modal = react_1.screen.getByTestId('file-preview-modal');
        expect(modal).toBeInTheDocument();
    });
    it('should pass modalHeaderProps to ModalHeader', () => {
        const modalHeaderProps = {
            'data-testid': 'custom-header'
        };
        (0, react_1.render)((0, jsx_runtime_1.jsx)(FilePreview_1.default, Object.assign({}, defaultProps, { modalHeaderProps: modalHeaderProps })));
        const header = react_1.screen.getByTestId('custom-header');
        expect(header).toBeInTheDocument();
    });
    it('should pass modalBodyProps to ModalBody', () => {
        const modalBodyProps = {
            'data-testid': 'custom-body'
        };
        (0, react_1.render)((0, jsx_runtime_1.jsx)(FilePreview_1.default, Object.assign({}, defaultProps, { modalBodyProps: modalBodyProps })));
        const body = react_1.screen.getByTestId('custom-body');
        expect(body).toBeInTheDocument();
    });
    it('should pass ouiaId to ChatbotModal', () => {
        const ouiaId = 'file-preview-ouia-id';
        (0, react_1.render)((0, jsx_runtime_1.jsx)(FilePreview_1.default, Object.assign({}, defaultProps, { ouiaId: ouiaId })));
        const modal = react_1.screen.getByRole('dialog');
        expect(modal).toHaveAttribute('data-ouia-component-id', ouiaId);
    });
    it('should handle complex children', () => {
        const complexChildren = ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h3", { children: "File details" }), (0, jsx_runtime_1.jsx)("p", { children: "Size: 1.2 MB" }), (0, jsx_runtime_1.jsx)(react_core_1.Button, { children: "Download" })] }));
        (0, react_1.render)((0, jsx_runtime_1.jsx)(FilePreview_1.default, Object.assign({}, defaultProps, { children: complexChildren })));
        expect(react_1.screen.getByRole('heading', { name: /File details/i })).toBeTruthy();
        expect(react_1.screen.getByText('Size: 1.2 MB')).toBeTruthy();
        expect(react_1.screen.getByRole('button', { name: /Download/i })).toBeTruthy();
    });
});
