"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 association_table_list_and_parent_record_js_namespaceObject = require("./data-block-demos/association-table-list-and-parent-record.js");
var association_table_list_and_parent_record_js_default = /*#__PURE__*/ __webpack_require__.n(association_table_list_and_parent_record_js_namespaceObject);
const association_table_list_and_source_id_js_namespaceObject = require("./data-block-demos/association-table-list-and-source-id.js");
var association_table_list_and_source_id_js_default = /*#__PURE__*/ __webpack_require__.n(association_table_list_and_source_id_js_namespaceObject);
const collection_form_create_js_namespaceObject = require("./data-block-demos/collection-form-create.js");
var collection_form_create_js_default = /*#__PURE__*/ __webpack_require__.n(collection_form_create_js_namespaceObject);
const collection_form_get_and_update_js_namespaceObject = require("./data-block-demos/collection-form-get-and-update.js");
var collection_form_get_and_update_js_default = /*#__PURE__*/ __webpack_require__.n(collection_form_get_and_update_js_namespaceObject);
const collection_form_record_and_update_js_namespaceObject = require("./data-block-demos/collection-form-record-and-update.js");
var collection_form_record_and_update_js_default = /*#__PURE__*/ __webpack_require__.n(collection_form_record_and_update_js_namespaceObject);
const collection_table_list_js_namespaceObject = require("./data-block-demos/collection-table-list.js");
var collection_table_list_js_default = /*#__PURE__*/ __webpack_require__.n(collection_table_list_js_namespaceObject);
describe('CollectionDataSourceProvider', ()=>{
    describe('collection', ()=>{
        test('Table list', async ()=>{
            const { getByText, getByRole } = (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(collection_table_list_js_default(), {}));
            await (0, client_namespaceObject.waitFor)(()=>{
                expect(getByRole('table')).toBeInTheDocument();
            });
            expect(getByText('UserName')).toBeInTheDocument();
            expect(getByText('NickName')).toBeInTheDocument();
            expect(getByText('Email')).toBeInTheDocument();
            await (0, client_namespaceObject.waitFor)(()=>{
                const columns = client_namespaceObject.screen.getByRole('table').querySelectorAll('tbody tr');
                expect(columns.length).toBe(3);
            });
            expect(getByText('jack')).toBeInTheDocument();
            expect(getByText('Jack Ma')).toBeInTheDocument();
            expect(getByText('test@gmail.com')).toBeInTheDocument();
        });
        test('Form get & update', async ()=>{
            (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(collection_form_get_and_update_js_default(), {}));
            await (0, client_namespaceObject.waitFor)(()=>{
                expect(client_namespaceObject.screen.getByText('Username')).toBeInTheDocument();
                expect(client_namespaceObject.screen.getByText('Age')).toBeInTheDocument();
            });
            await (0, client_namespaceObject.waitFor)(()=>{
                expect(document.getElementById('username')).toHaveValue('Bamboo');
                expect(document.getElementById('age')).toHaveValue('18');
            });
            client_namespaceObject.fireEvent.click(document.querySelector('button'));
            await (0, client_namespaceObject.waitFor)(()=>{
                expect(client_namespaceObject.screen.getByText('Save successfully!')).toBeInTheDocument();
            });
        });
        test('Form create', async ()=>{
            (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(collection_form_create_js_default(), {}));
            await (0, client_namespaceObject.waitFor)(()=>{
                expect(client_namespaceObject.screen.getByText('Username')).toBeInTheDocument();
                expect(client_namespaceObject.screen.getByText('Age')).toBeInTheDocument();
            });
            client_namespaceObject.fireEvent.change(document.getElementById('username'), {
                target: {
                    value: 'Bamboo'
                }
            });
            client_namespaceObject.fireEvent.change(document.getElementById('age'), {
                target: {
                    value: '18'
                }
            });
            client_namespaceObject.fireEvent.click(document.querySelector('button'));
            await (0, client_namespaceObject.waitFor)(()=>{
                expect(client_namespaceObject.screen.getByText('Save successfully!')).toBeInTheDocument();
            });
        });
        test('Form record & update', async ()=>{
            (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(collection_form_record_and_update_js_default(), {}));
            await (0, client_namespaceObject.waitFor)(()=>{
                expect(client_namespaceObject.screen.getByText('Username')).toBeInTheDocument();
                expect(client_namespaceObject.screen.getByText('Age')).toBeInTheDocument();
            });
            await (0, client_namespaceObject.waitFor)(()=>{
                expect(document.getElementById('username')).toHaveValue('Bamboo');
                expect(document.getElementById('age')).toHaveValue('18');
            });
            client_namespaceObject.fireEvent.click(document.querySelector('button'));
            await (0, client_namespaceObject.waitFor)(()=>{
                expect(client_namespaceObject.screen.getByText('Save successfully!')).toBeInTheDocument();
            });
        });
    });
    describe('association', ()=>{
        test('Table list & sourceId', async ()=>{
            const { getByText, getByRole } = (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(association_table_list_and_source_id_js_default(), {}));
            await (0, client_namespaceObject.waitFor)(()=>{
                expect(getByRole('table')).toBeInTheDocument();
            });
            expect(getByText('Name')).toBeInTheDocument();
            expect(getByText('Title')).toBeInTheDocument();
            expect(getByText('Description')).toBeInTheDocument();
            await (0, client_namespaceObject.waitFor)(()=>{
                const columns = client_namespaceObject.screen.getByRole('table').querySelectorAll('tbody tr');
                expect(columns.length).toBe(2);
            });
            expect(getByText('admin')).toBeInTheDocument();
            expect(getByText('Admin')).toBeInTheDocument();
            expect(getByText('Admin description')).toBeInTheDocument();
        });
        test('Table list & parentRecord', async ()=>{
            const { getByText, getByRole } = (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(association_table_list_and_parent_record_js_default(), {}));
            await (0, client_namespaceObject.waitFor)(()=>{
                expect(getByRole('table')).toBeInTheDocument();
            });
            expect(getByText('Name')).toBeInTheDocument();
            expect(getByText('Title')).toBeInTheDocument();
            expect(getByText('Description')).toBeInTheDocument();
            await (0, client_namespaceObject.waitFor)(()=>{
                const columns = client_namespaceObject.screen.getByRole('table').querySelectorAll('tbody tr');
                expect(columns.length).toBe(2);
            });
            expect(getByText('admin')).toBeInTheDocument();
            expect(getByText('Admin')).toBeInTheDocument();
            expect(getByText('Admin description')).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
});
