"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 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);
describe('Filter', ()=>{
    it('Filter & Action', async ()=>{
        (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(demo3_js_default(), {}));
        await (0, client_namespaceObject.waitFor)(async ()=>{
            await client_namespaceObject.userEvent.click(client_namespaceObject.screen.getByText(/open/i));
        });
        const tooltip = client_namespaceObject.screen.getByRole('tooltip');
        expect(tooltip).toBeInTheDocument();
        expect((0, client_namespaceObject.within)(tooltip).getByText(/name/i)).toBeInTheDocument();
        expect((0, client_namespaceObject.within)(tooltip).getByText(/ne/i)).toBeInTheDocument();
        expect((0, client_namespaceObject.within)(tooltip).getByText(/tags \/ title/i)).toBeInTheDocument();
        expect((0, client_namespaceObject.within)(tooltip).getByText(/eq/i)).toBeInTheDocument();
        expect((0, client_namespaceObject.within)(tooltip).getByText(/^Add condition$/i)).toBeInTheDocument();
        expect((0, client_namespaceObject.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 client_namespaceObject.userEvent.click(client_namespaceObject.screen.getByText(/any/i));
        await client_namespaceObject.userEvent.click(client_namespaceObject.screen.getByText(/all/i));
        expect(tooltip).toBeInTheDocument();
    });
    it('default value', ()=>{
        (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(demo2_js_default(), {}));
        expect(client_namespaceObject.screen.getByText(/name/i)).toBeInTheDocument();
        expect(client_namespaceObject.screen.getByText(/ne/i)).toBeInTheDocument();
        expect(client_namespaceObject.screen.getByText(/tags \/ title/i)).toBeInTheDocument();
        expect(client_namespaceObject.screen.getByText(/eq/i)).toBeInTheDocument();
        expect(client_namespaceObject.screen.getByText(/^Add condition$/i)).toBeInTheDocument();
        expect(client_namespaceObject.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, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(demo4_js_default(), {}));
        expect(client_namespaceObject.screen.getByText(/name/i)).toBeInTheDocument();
        expect(client_namespaceObject.screen.getByText(/ne/i)).toBeInTheDocument();
        expect(client_namespaceObject.screen.getByText(/tags \/ title/i)).toBeInTheDocument();
        expect(client_namespaceObject.screen.getByText(/eq/i)).toBeInTheDocument();
        expect(client_namespaceObject.screen.getByText(/^Add condition$/i)).toBeInTheDocument();
        expect(client_namespaceObject.screen.getByText(/^Add condition group$/i)).toBeInTheDocument();
        const selects = client_namespaceObject.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, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(demo5_js_default(), {}));
        await (0, client_namespaceObject.waitFor)(()=>client_namespaceObject.userEvent.click(client_namespaceObject.screen.getByText(/filter/i)));
        const tooltip = client_namespaceObject.screen.getByRole('tooltip');
        expect(tooltip).toBeInTheDocument();
        expect((0, client_namespaceObject.within)(tooltip).getByText(/name/i)).toBeInTheDocument();
        expect((0, client_namespaceObject.within)(tooltip).getByText(/ne/i)).toBeInTheDocument();
        expect((0, client_namespaceObject.within)(tooltip).getByText(/tags \/ title/i)).toBeInTheDocument();
        expect((0, client_namespaceObject.within)(tooltip).getByText(/eq/i)).toBeInTheDocument();
        expect((0, client_namespaceObject.within)(tooltip).getByText(/^Add condition$/i)).toBeInTheDocument();
        expect((0, client_namespaceObject.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 client_namespaceObject.userEvent.click(client_namespaceObject.screen.getByText(/any/i));
        await client_namespaceObject.userEvent.click(client_namespaceObject.screen.getByText(/all/i));
        expect(tooltip).toBeInTheDocument();
    });
    it('dynamic options', async ()=>{
        (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(demo6_js_default(), {}));
        await (0, client_namespaceObject.waitFor)(()=>{
            expect(client_namespaceObject.screen.getByText(/test1/i)).toBeInTheDocument();
        });
        const addBtn = client_namespaceObject.screen.getByText(/^Add condition$/i);
        const addGroupBtn = client_namespaceObject.screen.getByText(/^Add condition group$/i);
        expect(addBtn).toBeInTheDocument();
        expect(addGroupBtn).toBeInTheDocument();
        await (0, client_namespaceObject.waitFor)(()=>client_namespaceObject.userEvent.click(addBtn));
        const item = document.querySelector('.nc-filter-item');
        const selector = item.querySelector('.ant-select-selector');
        expect(item).toBeInTheDocument();
        await client_namespaceObject.userEvent.click(selector);
        await client_namespaceObject.userEvent.click(client_namespaceObject.screen.getByText(/title1/i));
        expect(client_namespaceObject.screen.getByText(/title1/i, {
            selector: '.ant-select-selection-item'
        })).toBeInTheDocument();
        expect(client_namespaceObject.screen.getByText(/contains/i, {
            selector: '.ant-select-selection-item'
        })).toBeInTheDocument();
        await client_namespaceObject.userEvent.click(client_namespaceObject.screen.getByText(/test1/i));
        await client_namespaceObject.userEvent.click(client_namespaceObject.screen.getByText(/test2/i, {
            selector: '.ant-select-item-option-content'
        }));
        await client_namespaceObject.userEvent.click(selector);
        await client_namespaceObject.userEvent.click(client_namespaceObject.screen.getByText(/title2/i));
        expect(client_namespaceObject.screen.getByText(/title2/i, {
            selector: '.ant-select-selection-item'
        })).toBeInTheDocument();
        expect(client_namespaceObject.screen.getByText(/contains/i, {
            selector: '.ant-select-selection-item'
        })).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
});
