import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
import "react";
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__ from "@tachybase/test/client";
import * as __WEBPACK_EXTERNAL_MODULE__demos_demo1_mjs__ from "../demos/demo1.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__demos_demo2_mjs__ from "../demos/demo2.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__demos_demo3_mjs__ from "../demos/demo3.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__demos_demo4_mjs__ from "../demos/demo4.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__demos_demo5_mjs__ from "../demos/demo5.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__demos_demo6_mjs__ from "../demos/demo6.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__demos_demo7_mjs__ from "../demos/demo7.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__demos_demo8_mjs__ from "../demos/demo8.mjs";
describe('Form', ()=>{
    it('basic', async ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__demos_demo2_mjs__["default"], {}));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.sleep)();
        const submit = __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('Submit');
        const input = document.querySelector('.ant-input');
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>{
            expect(submit).toBeInTheDocument();
            expect(input).toBeInTheDocument();
            expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.queryByText(/form title/i)).toBeInTheDocument();
            expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.queryByText('T1')).toBeInTheDocument();
            expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.queryByText(/\{\}/i)).toBeInTheDocument();
        });
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.type(input, '123'));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>{
            expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.queryByText(/\{ "field1": "123" \}/i)).toBeInTheDocument();
        });
    });
    it('decorator', async ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__demos_demo6_mjs__["default"], {}));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.sleep)();
        const submit = __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('Submit');
        const input = document.querySelector('.ant-input');
        expect(submit).toBeInTheDocument();
        expect(input).toBeInTheDocument();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>{
            expect(input).toHaveValue('aaa');
            expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('T1')).toBeInTheDocument();
            expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/\{ "field1": "aaa" \}/i)).toBeInTheDocument();
        });
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.type(input, '123');
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>{
            expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.queryByText(/\{ "field1": "aaa123" \}/i)).toBeInTheDocument();
        });
    });
    it('Form & Drawer', async ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__demos_demo1_mjs__["default"], {}));
        const openBtn = __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('Open');
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(openBtn);
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/drawer title/i)).toBeInTheDocument();
    });
    it('initialValue', async ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__demos_demo3_mjs__["default"], {}));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.sleep)();
        const submit = __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('Submit');
        const input = document.querySelector('.ant-input');
        expect(submit).toBeInTheDocument();
        expect(input).toBeInTheDocument();
        expect(input).toHaveValue('aaa');
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/\{ "field1": "aaa" \}/i)).toBeInTheDocument();
    });
    it('initialValue of decorator', async ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__demos_demo4_mjs__["default"], {}));
        const openBtn = __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('Open');
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(openBtn);
        const input = document.querySelector('.ant-input');
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/drawer title/i)).toBeInTheDocument();
        expect(input).toBeInTheDocument();
        expect(input).toHaveValue('aaa');
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/\{ "field1": "aaa" \}/i)).toBeInTheDocument();
    });
    it('remote data', async ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__demos_demo5_mjs__["default"], {}));
        const loading = document.querySelector('.ant-spin');
        const t1Input = document.querySelector('.t1 .ant-input');
        const t2Input = document.querySelector('.t2 .ant-input');
        const submit = __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('Submit');
        const refresh = __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('Refresh');
        expect(submit).toBeInTheDocument();
        expect(refresh).toBeInTheDocument();
        expect(t1Input).toBeInTheDocument();
        expect(t1Input).toHaveValue('');
        expect(t2Input).toBeInTheDocument();
        expect(t2Input).toHaveValue('default value');
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/\{ "field2": "default value" \}/i)).toBeInTheDocument();
        expect(loading).toBeInTheDocument();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.sleep)(600);
        expect(t1Input).toHaveValue('uid');
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/\{ "field2": "default value", "field1": "uid" \}/i)).toBeInTheDocument();
    });
    it('useValues', async ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__demos_demo7_mjs__["default"], {}));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.sleep)();
        const submit = __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('Submit');
        const input = document.querySelector('.ant-input');
        expect(submit).toBeInTheDocument();
        expect(input).toBeInTheDocument();
        expect(input).toHaveValue('aabb');
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/\{ "field1": "aabb" \}/i)).toBeInTheDocument();
    });
    it('DrawerForm & async data', async ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__demos_demo8_mjs__["default"], {}));
        const editBtn = __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('Edit');
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(editBtn);
        const input = document.querySelector('.ant-input');
        const closeBtn = __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('Close');
        expect(input).toBeInTheDocument();
        expect(input).toHaveValue('hello tachybase');
        expect(closeBtn).toBeInTheDocument();
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/drawer title/i)).toBeInTheDocument();
    });
});
