"use strict";
var __webpack_exports__ = {};
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
require("react");
const client_namespaceObject = require("@tachybase/client");
const test_client_namespaceObject = require("@tachybase/test/client");
var collections_namespaceObject = JSON.parse('[{"key":"h7b9i8khc3q","name":"users","inherit":false,"hidden":false,"description":null,"category":[],"namespace":"users.users","duplicator":{"dumpable":"optional","with":"rolesUsers"},"sortable":"sort","model":"UserModel","createdBy":true,"updatedBy":true,"logging":true,"from":"db2cm","title":"{{t(\\"Users\\")}}","rawTitle":"{{t(\\"Users\\")}}","fields":[{"uiSchema":{"type":"number","title":"{{t(\\"ID\\")}}","x-component":"InputNumber","x-read-pretty":true,"rawTitle":"{{t(\\"ID\\")}}"},"key":"ffp1f2sula0","name":"id","type":"bigInt","interface":"id","description":null,"collectionName":"users","parentKey":null,"reverseKey":null,"autoIncrement":true,"primaryKey":true,"allowNull":false},{"uiSchema":{"type":"string","title":"{{t(\\"Nickname\\")}}","x-component":"Input","rawTitle":"{{t(\\"Nickname\\")}}"},"key":"vrv7yjue90g","name":"nickname","type":"string","interface":"input","description":null,"collectionName":"users","parentKey":null,"reverseKey":null},{"uiSchema":{"type":"string","title":"{{t(\\"Username\\")}}","x-component":"Input","x-validator":{"username":true},"required":true,"rawTitle":"{{t(\\"Username\\")}}"},"key":"2ccs6evyrub","name":"username","type":"string","interface":"input","description":null,"collectionName":"users","parentKey":null,"reverseKey":null,"unique":true},{"uiSchema":{"type":"string","title":"{{t(\\"Email\\")}}","x-component":"Input","x-validator":"email","required":true,"rawTitle":"{{t(\\"Email\\")}}"},"key":"rrskwjl5wt1","name":"email","type":"string","interface":"email","description":null,"collectionName":"users","parentKey":null,"reverseKey":null,"unique":true},{"key":"t09bauwm0wb","name":"roles","type":"belongsToMany","interface":"m2m","description":null,"collectionName":"users","parentKey":null,"reverseKey":null,"target":"roles","foreignKey":"userId","otherKey":"roleName","onDelete":"CASCADE","sourceKey":"id","targetKey":"name","through":"rolesUsers","uiSchema":{"type":"array","title":"{{t(\\"Roles\\")}}","x-component":"AssociationField","x-component-props":{"multiple":true,"fieldNames":{"label":"title","value":"name"}}}},{"key":"1pz0art9mt7","name":"f_n2fu6hvprct","type":"string","interface":"select","description":null,"collectionName":"t_vwpds9fs4xs","parentKey":null,"reverseKey":null,"uiSchema":{"enum":[{"value":"test1","label":"test1"},{"value":"test2","label":"test2"}],"type":"string","x-component":"Select","title":"test"}}]}]');
function renderApp(fieldName) {
    const noUiSchema = {
        key: 'no-ui-schema',
        name: 'no-ui-schema',
        type: 'string',
        interface: 'select',
        description: null,
        collectionName: 't_vwpds9fs4xs',
        parentKey: null,
        reverseKey: null
    };
    const usersCollection = collections_namespaceObject["0"];
    usersCollection.fields.push(noUiSchema);
    const app = new client_namespaceObject.Application({
        dataSourceManager: {
            collections: [
                usersCollection
            ]
        }
    });
    const schema = {
        name: 'root',
        type: 'object',
        properties: {
            [fieldName]: {
                'x-component': 'CollectionField',
                'x-decorator': 'FormItem'
            }
        }
    };
    return (0, test_client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
        "data-testid": "app",
        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(client_namespaceObject.SchemaComponentProvider, {
            designable: true,
            children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(client_namespaceObject.DataSourceApplicationProvider, {
                dataSourceManager: app.dataSourceManager,
                children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(client_namespaceObject.CollectionProvider, {
                    name: "users",
                    children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(client_namespaceObject.SchemaComponent, {
                        schema: schema,
                        components: {
                            CollectionField: client_namespaceObject.CollectionField,
                            FormItem: client_namespaceObject.FormItem,
                            Input: client_namespaceObject.Input
                        }
                    })
                })
            })
        })
    }));
}
describe('CollectionField', ()=>{
    it('works', ()=>{
        renderApp('nickname');
        expect(test_client_namespaceObject.screen.getByText('Nickname')).toBeInTheDocument();
        expect(test_client_namespaceObject.screen.getByRole('textbox')).toHaveClass('ant-input');
    });
    it('no schema', ()=>{
        renderApp('no-ui-schema');
        expect(document.querySelector('.ant-formily-item-control-content-component')).toHaveTextContent('');
    });
});
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
});
