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_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";
describe('Filter', ()=>{
    it('Filter & Action', 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__.waitFor)(async ()=>{
            await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/open/i));
        });
        const tooltip = __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByRole('tooltip');
        expect(tooltip).toBeInTheDocument();
        expect((0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.within)(tooltip).getByText(/name/i)).toBeInTheDocument();
        expect((0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.within)(tooltip).getByText(/ne/i)).toBeInTheDocument();
        expect((0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.within)(tooltip).getByText(/tags \/ title/i)).toBeInTheDocument();
        expect((0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.within)(tooltip).getByText(/eq/i)).toBeInTheDocument();
        expect((0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.within)(tooltip).getByText(/^Add condition$/i)).toBeInTheDocument();
        expect((0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.within)(tooltip).getByText(/^Add condition group$/i)).toBeInTheDocument();
        const inputs = tooltip.querySelectorAll('.ant-input');
        expect(inputs).toHaveLength(2);
        expect(inputs[0]).toHaveValue('aa');
        expect(inputs[1]).toHaveValue('aaa');
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/any/i));
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/all/i));
        expect(tooltip).toBeInTheDocument();
    });
    it('default value', ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__demos_demo2_mjs__["default"], {}));
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/name/i)).toBeInTheDocument();
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/ne/i)).toBeInTheDocument();
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/tags \/ title/i)).toBeInTheDocument();
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/eq/i)).toBeInTheDocument();
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/^Add condition$/i)).toBeInTheDocument();
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/^Add condition group$/i)).toBeInTheDocument();
        const inputs = document.querySelectorAll('.ant-input');
        expect(inputs).toHaveLength(2);
        expect(inputs[0]).toHaveValue('');
        expect(inputs[1]).toHaveValue('aaa');
    });
    it('custom dynamic component', 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"], {}));
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/name/i)).toBeInTheDocument();
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/ne/i)).toBeInTheDocument();
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/tags \/ title/i)).toBeInTheDocument();
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/eq/i)).toBeInTheDocument();
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/^Add condition$/i)).toBeInTheDocument();
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/^Add condition group$/i)).toBeInTheDocument();
        const selects = __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getAllByText('默认');
        expect(selects[0]).toBeInTheDocument();
        expect(selects[1]).toBeInTheDocument();
        const inputs = document.querySelectorAll('.ant-input');
        expect(inputs).toHaveLength(2);
        expect(inputs[0]).toHaveValue('aaa');
        expect(inputs[1]).toHaveValue('bbb');
    });
    it('FilterAction', 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"], {}));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/filter/i)));
        const tooltip = __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByRole('tooltip');
        expect(tooltip).toBeInTheDocument();
        expect((0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.within)(tooltip).getByText(/name/i)).toBeInTheDocument();
        expect((0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.within)(tooltip).getByText(/ne/i)).toBeInTheDocument();
        expect((0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.within)(tooltip).getByText(/tags \/ title/i)).toBeInTheDocument();
        expect((0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.within)(tooltip).getByText(/eq/i)).toBeInTheDocument();
        expect((0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.within)(tooltip).getByText(/^Add condition$/i)).toBeInTheDocument();
        expect((0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.within)(tooltip).getByText(/^Add condition group$/i)).toBeInTheDocument();
        const inputs = tooltip.querySelectorAll('.ant-input');
        expect(inputs).toHaveLength(2);
        expect(inputs[0]).toHaveValue('');
        expect(inputs[1]).toHaveValue('aaa');
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/any/i));
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/all/i));
        expect(tooltip).toBeInTheDocument();
    });
    it('dynamic options', 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__.waitFor)(()=>{
            expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/test1/i)).toBeInTheDocument();
        });
        const addBtn = __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/^Add condition$/i);
        const addGroupBtn = __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/^Add condition group$/i);
        expect(addBtn).toBeInTheDocument();
        expect(addGroupBtn).toBeInTheDocument();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(addBtn));
        const item = document.querySelector('.nc-filter-item');
        const selector = item.querySelector('.ant-select-selector');
        expect(item).toBeInTheDocument();
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(selector);
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/title1/i));
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/title1/i, {
            selector: '.ant-select-selection-item'
        })).toBeInTheDocument();
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/contains/i, {
            selector: '.ant-select-selection-item'
        })).toBeInTheDocument();
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/test1/i));
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/test2/i, {
            selector: '.ant-select-item-option-content'
        }));
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(selector);
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.click(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/title2/i));
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/title2/i, {
            selector: '.ant-select-selection-item'
        })).toBeInTheDocument();
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/contains/i, {
            selector: '.ant-select-selection-item'
        })).toBeInTheDocument();
    });
});
