"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.n = function(module) {
        var getter = module && module.__esModule ? function() {
            return module['default'];
        } : function() {
            return module;
        };
        __webpack_require__.d(getter, {
            a: getter
        });
        return getter;
    };
})();
(()=>{
    __webpack_require__.d = function(exports1, definition) {
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = function(obj, prop) {
        return Object.prototype.hasOwnProperty.call(obj, prop);
    };
})();
var __webpack_exports__ = {};
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
require("react");
const client_namespaceObject = require("@tachybase/test/client");
const demo1_js_namespaceObject = require("../demos/demo1.js");
var demo1_js_default = /*#__PURE__*/ __webpack_require__.n(demo1_js_namespaceObject);
const demo2_js_namespaceObject = require("../demos/demo2.js");
var demo2_js_default = /*#__PURE__*/ __webpack_require__.n(demo2_js_namespaceObject);
const demo3_js_namespaceObject = require("../demos/demo3.js");
var demo3_js_default = /*#__PURE__*/ __webpack_require__.n(demo3_js_namespaceObject);
const demo4_js_namespaceObject = require("../demos/demo4.js");
var demo4_js_default = /*#__PURE__*/ __webpack_require__.n(demo4_js_namespaceObject);
const demo5_js_namespaceObject = require("../demos/demo5.js");
var demo5_js_default = /*#__PURE__*/ __webpack_require__.n(demo5_js_namespaceObject);
const demo6_js_namespaceObject = require("../demos/demo6.js");
var demo6_js_default = /*#__PURE__*/ __webpack_require__.n(demo6_js_namespaceObject);
const demo7_js_namespaceObject = require("../demos/demo7.js");
var demo7_js_default = /*#__PURE__*/ __webpack_require__.n(demo7_js_namespaceObject);
const demo8_js_namespaceObject = require("../demos/demo8.js");
var demo8_js_default = /*#__PURE__*/ __webpack_require__.n(demo8_js_namespaceObject);
describe('Form', ()=>{
    it('basic', async ()=>{
        (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(demo2_js_default(), {}));
        await (0, client_namespaceObject.sleep)();
        const submit = client_namespaceObject.screen.getByText('Submit');
        const input = document.querySelector('.ant-input');
        await (0, client_namespaceObject.waitFor)(()=>{
            expect(submit).toBeInTheDocument();
            expect(input).toBeInTheDocument();
            expect(client_namespaceObject.screen.queryByText(/form title/i)).toBeInTheDocument();
            expect(client_namespaceObject.screen.queryByText('T1')).toBeInTheDocument();
            expect(client_namespaceObject.screen.queryByText(/\{\}/i)).toBeInTheDocument();
        });
        await (0, client_namespaceObject.waitFor)(()=>client_namespaceObject.userEvent.type(input, '123'));
        await (0, client_namespaceObject.waitFor)(()=>{
            expect(client_namespaceObject.screen.queryByText(/\{ "field1": "123" \}/i)).toBeInTheDocument();
        });
    });
    it('decorator', async ()=>{
        (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(demo6_js_default(), {}));
        await (0, client_namespaceObject.sleep)();
        const submit = client_namespaceObject.screen.getByText('Submit');
        const input = document.querySelector('.ant-input');
        expect(submit).toBeInTheDocument();
        expect(input).toBeInTheDocument();
        await (0, client_namespaceObject.waitFor)(()=>{
            expect(input).toHaveValue('aaa');
            expect(client_namespaceObject.screen.getByText('T1')).toBeInTheDocument();
            expect(client_namespaceObject.screen.getByText(/\{ "field1": "aaa" \}/i)).toBeInTheDocument();
        });
        await client_namespaceObject.userEvent.type(input, '123');
        await (0, client_namespaceObject.waitFor)(()=>{
            expect(client_namespaceObject.screen.queryByText(/\{ "field1": "aaa123" \}/i)).toBeInTheDocument();
        });
    });
    it('Form & Drawer', async ()=>{
        (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(demo1_js_default(), {}));
        const openBtn = client_namespaceObject.screen.getByText('Open');
        await client_namespaceObject.userEvent.click(openBtn);
        expect(client_namespaceObject.screen.getByText(/drawer title/i)).toBeInTheDocument();
    });
    it('initialValue', async ()=>{
        (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(demo3_js_default(), {}));
        await (0, client_namespaceObject.sleep)();
        const submit = client_namespaceObject.screen.getByText('Submit');
        const input = document.querySelector('.ant-input');
        expect(submit).toBeInTheDocument();
        expect(input).toBeInTheDocument();
        expect(input).toHaveValue('aaa');
        expect(client_namespaceObject.screen.getByText(/\{ "field1": "aaa" \}/i)).toBeInTheDocument();
    });
    it('initialValue of decorator', async ()=>{
        (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(demo4_js_default(), {}));
        const openBtn = client_namespaceObject.screen.getByText('Open');
        await client_namespaceObject.userEvent.click(openBtn);
        const input = document.querySelector('.ant-input');
        expect(client_namespaceObject.screen.getByText(/drawer title/i)).toBeInTheDocument();
        expect(input).toBeInTheDocument();
        expect(input).toHaveValue('aaa');
        expect(client_namespaceObject.screen.getByText(/\{ "field1": "aaa" \}/i)).toBeInTheDocument();
    });
    it('remote data', async ()=>{
        (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(demo5_js_default(), {}));
        const loading = document.querySelector('.ant-spin');
        const t1Input = document.querySelector('.t1 .ant-input');
        const t2Input = document.querySelector('.t2 .ant-input');
        const submit = client_namespaceObject.screen.getByText('Submit');
        const refresh = client_namespaceObject.screen.getByText('Refresh');
        expect(submit).toBeInTheDocument();
        expect(refresh).toBeInTheDocument();
        expect(t1Input).toBeInTheDocument();
        expect(t1Input).toHaveValue('');
        expect(t2Input).toBeInTheDocument();
        expect(t2Input).toHaveValue('default value');
        expect(client_namespaceObject.screen.getByText(/\{ "field2": "default value" \}/i)).toBeInTheDocument();
        expect(loading).toBeInTheDocument();
        await (0, client_namespaceObject.sleep)(600);
        expect(t1Input).toHaveValue('uid');
        expect(client_namespaceObject.screen.getByText(/\{ "field2": "default value", "field1": "uid" \}/i)).toBeInTheDocument();
    });
    it('useValues', async ()=>{
        (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(demo7_js_default(), {}));
        await (0, client_namespaceObject.sleep)();
        const submit = client_namespaceObject.screen.getByText('Submit');
        const input = document.querySelector('.ant-input');
        expect(submit).toBeInTheDocument();
        expect(input).toBeInTheDocument();
        expect(input).toHaveValue('aabb');
        expect(client_namespaceObject.screen.getByText(/\{ "field1": "aabb" \}/i)).toBeInTheDocument();
    });
    it('DrawerForm & async data', async ()=>{
        (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(demo8_js_default(), {}));
        const editBtn = client_namespaceObject.screen.getByText('Edit');
        await client_namespaceObject.userEvent.click(editBtn);
        const input = document.querySelector('.ant-input');
        const closeBtn = client_namespaceObject.screen.getByText('Close');
        expect(input).toBeInTheDocument();
        expect(input).toHaveValue('hello tachybase');
        expect(closeBtn).toBeInTheDocument();
        expect(client_namespaceObject.screen.getByText(/drawer title/i)).toBeInTheDocument();
    });
});
var __webpack_export_target__ = exports;
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
    value: true
});
