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__data_block_demos_association_table_list_and_parent_record_mjs__ from "./data-block-demos/association-table-list-and-parent-record.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__data_block_demos_association_table_list_and_source_id_mjs__ from "./data-block-demos/association-table-list-and-source-id.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__data_block_demos_collection_form_create_mjs__ from "./data-block-demos/collection-form-create.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__data_block_demos_collection_form_get_and_update_mjs__ from "./data-block-demos/collection-form-get-and-update.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__data_block_demos_collection_form_record_and_update_mjs__ from "./data-block-demos/collection-form-record-and-update.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__data_block_demos_collection_table_list_mjs__ from "./data-block-demos/collection-table-list.mjs";
describe('CollectionDataSourceProvider', ()=>{
    describe('collection', ()=>{
        test('Table list', async ()=>{
            const { getByText, getByRole } = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__data_block_demos_collection_table_list_mjs__["default"], {}));
            await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>{
                expect(getByRole('table')).toBeInTheDocument();
            });
            expect(getByText('UserName')).toBeInTheDocument();
            expect(getByText('NickName')).toBeInTheDocument();
            expect(getByText('Email')).toBeInTheDocument();
            await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>{
                const columns = __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.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, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__data_block_demos_collection_form_get_and_update_mjs__["default"], {}));
            await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>{
                expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('Username')).toBeInTheDocument();
                expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('Age')).toBeInTheDocument();
            });
            await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>{
                expect(document.getElementById('username')).toHaveValue('Bamboo');
                expect(document.getElementById('age')).toHaveValue('18');
            });
            __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.fireEvent.click(document.querySelector('button'));
            await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>{
                expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('Save successfully!')).toBeInTheDocument();
            });
        });
        test('Form create', async ()=>{
            (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__data_block_demos_collection_form_create_mjs__["default"], {}));
            await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>{
                expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('Username')).toBeInTheDocument();
                expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('Age')).toBeInTheDocument();
            });
            __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.fireEvent.change(document.getElementById('username'), {
                target: {
                    value: 'Bamboo'
                }
            });
            __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.fireEvent.change(document.getElementById('age'), {
                target: {
                    value: '18'
                }
            });
            __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.fireEvent.click(document.querySelector('button'));
            await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>{
                expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('Save successfully!')).toBeInTheDocument();
            });
        });
        test('Form record & update', async ()=>{
            (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__data_block_demos_collection_form_record_and_update_mjs__["default"], {}));
            await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>{
                expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('Username')).toBeInTheDocument();
                expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('Age')).toBeInTheDocument();
            });
            await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>{
                expect(document.getElementById('username')).toHaveValue('Bamboo');
                expect(document.getElementById('age')).toHaveValue('18');
            });
            __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.fireEvent.click(document.querySelector('button'));
            await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>{
                expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('Save successfully!')).toBeInTheDocument();
            });
        });
    });
    describe('association', ()=>{
        test('Table list & sourceId', async ()=>{
            const { getByText, getByRole } = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__data_block_demos_association_table_list_and_source_id_mjs__["default"], {}));
            await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>{
                expect(getByRole('table')).toBeInTheDocument();
            });
            expect(getByText('Name')).toBeInTheDocument();
            expect(getByText('Title')).toBeInTheDocument();
            expect(getByText('Description')).toBeInTheDocument();
            await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>{
                const columns = __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.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, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__data_block_demos_association_table_list_and_parent_record_mjs__["default"], {}));
            await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>{
                expect(getByRole('table')).toBeInTheDocument();
            });
            expect(getByText('Name')).toBeInTheDocument();
            expect(getByText('Title')).toBeInTheDocument();
            expect(getByText('Description')).toBeInTheDocument();
            await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>{
                const columns = __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByRole('table').querySelectorAll('tbody tr');
                expect(columns.length).toBe(2);
            });
            expect(getByText('admin')).toBeInTheDocument();
            expect(getByText('Admin')).toBeInTheDocument();
            expect(getByText('Admin description')).toBeInTheDocument();
        });
    });
});
