import * as __WEBPACK_EXTERNAL_MODULE__chakra_ui_react__ from "@chakra-ui/react";
import * as __WEBPACK_EXTERNAL_MODULE__testing_library_react__ from "@testing-library/react";
import * as __WEBPACK_EXTERNAL_MODULE_react_dom_test_utils__ from "react-dom/test-utils";
import * as __WEBPACK_EXTERNAL_MODULE__FormField_mjs__ from "./FormField.mjs";
describe('FormField', ()=>{
    test('should render field with a label', ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__FormField_mjs__["default"], {
            label: "Text input"
        }, /*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Input, {
            "data-testid": "input",
            name: "text",
            type: "text",
            placeholder: "Enter text"
        })));
        const label = __WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByText('Text input');
        const input = __WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('input');
        expect(label).toBeVisible();
        expect(input).toBeVisible();
    });
    test('should render field with a ReactNode (JSX) label', ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__FormField_mjs__["default"], {
            label: /*#__PURE__*/ React.createElement("span", {
                "data-testid": "jsx-label"
            }, "Text ", /*#__PURE__*/ React.createElement("em", null, "input"), " with ", /*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Link, {
                href: "#"
            }, "link"))
        }, /*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Input, {
            "data-testid": "input",
            name: "text",
            type: "text",
            placeholder: "Enter text"
        })));
        const label = __WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('jsx-label');
        const link = __WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByRole('link', {
            name: /link/i
        });
        const input = __WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('input');
        expect(label).toBeVisible();
        expect(link).toBeInTheDocument();
        expect(input).toBeVisible();
    });
    test('should show helpText if prop is present', ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__FormField_mjs__["default"], {
            label: "Text input",
            helpText: "Help text"
        }, /*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Input, {
            "data-testid": "input",
            name: "text",
            type: "text",
            placeholder: "Enter text"
        })));
        expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByText('Help text')).toBeVisible();
    });
    test('should show errorText if isInvalid=true', ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__FormField_mjs__["default"], {
            label: "Text input",
            helpText: "Help text",
            isInvalid: true,
            errorText: "Error message"
        }, /*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Input, {
            "data-testid": "input",
            name: "text",
            type: "text",
            placeholder: "Enter text"
        })));
        expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByText('Error message')).toBeVisible();
    });
    test('should prevent focus and onClick when isDisabled=true', ()=>{
        const mockOnClick = jest.fn();
        (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__FormField_mjs__["default"], {
            label: "Text input",
            helpText: "Help text",
            isDisabled: true
        }, /*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Input, {
            "data-testid": "input",
            name: "text",
            type: "text",
            placeholder: "Enter text",
            onClick: mockOnClick
        })));
        const input = __WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('input');
        // Try to focus
        (0, __WEBPACK_EXTERNAL_MODULE_react_dom_test_utils__.act)(()=>input.focus());
        expect(input).not.toHaveFocus();
        // Try to change the value
        __WEBPACK_EXTERNAL_MODULE__testing_library_react__.fireEvent.input(input, {
            target: {
                value: 'text'
            }
        });
        expect(mockOnClick).not.toHaveBeenCalled();
    });
});
