import * as __WEBPACK_EXTERNAL_MODULE__tachybase_schema__ from "@tachybase/schema";
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__ from "@tachybase/test/e2e";
import * as __WEBPACK_EXTERNAL_MODULE__templatesOfBug_mjs__ from "./templatesOfBug.mjs";
__WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test.describe('where creation form block can be added', ()=>{
    (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test)('page', async (param)=>{
        let { page, mockPage } = param;
        await mockPage().goto();
        await page.getByLabel('schema-initializer-Grid-page:addBlock').hover();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.createBlockInPage)(page, 'Form');
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CardItem-users-form')).toBeVisible();
    });
});
__WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test.describe('configure fields', ()=>{
    (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test)('display collection fields & display association fields & add text', async (param)=>{
        let { page, mockPage } = param;
        await mockPage(__WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.oneEmptyForm).goto();
        await page.getByLabel('schema-initializer-Grid-form:configureFields-general').hover();
        await page.getByRole('menuitem', {
            name: 'ID',
            exact: true
        }).click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByRole('menuitem', {
            name: 'ID',
            exact: true
        }).getByRole('switch')).toBeChecked();
        await page.getByRole('menuitem', {
            name: 'Many to one'
        }).nth(1).hover();
        await page.getByRole('menuitem', {
            name: 'Nickname'
        }).click();
        await page.getByRole('menuitem', {
            name: 'Many to one'
        }).nth(1).hover();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByRole('menuitem', {
            name: 'Nickname'
        }).getByRole('switch')).toBeChecked();
        await page.mouse.move(300, 0);
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-general-form-general.id-ID')).toBeVisible();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-general-form-general.manyToOne.nickname')).toBeVisible();
        await page.getByLabel('schema-initializer-Grid-form:configureFields-general').hover();
        await page.getByRole('menuitem', {
            name: 'ID',
            exact: true
        }).click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByRole('menuitem', {
            name: 'ID',
            exact: true
        }).getByRole('switch')).not.toBeChecked();
        await page.getByRole('menuitem', {
            name: 'Many to one'
        }).nth(1).hover();
        await page.getByRole('menuitem', {
            name: 'Nickname'
        }).click();
        await page.getByRole('menuitem', {
            name: 'Many to one'
        }).nth(1).hover();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByRole('menuitem', {
            name: 'Nickname'
        }).getByRole('switch')).not.toBeChecked();
        await page.mouse.move(300, 0);
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-general-form-general.id-ID')).not.toBeVisible();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-general-form-general.manyToOne.nickname')).not.toBeVisible();
        await page.getByLabel('schema-initializer-Grid-form:configureFields-general').hover();
        await page.getByRole('menuitem', {
            name: 'Text'
        }).click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-Markdown.Void-general-form')).toBeVisible();
    });
    __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test.pgOnly('display inherit fields', async (param)=>{
        let { page, mockPage } = param;
    });
});
__WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test.describe('configure actions', ()=>{
    (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test)('submit', async (param)=>{
        let { page, mockPage } = param;
        await mockPage(__WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.oneEmptyForm).goto();
        await page.getByLabel('schema-initializer-ActionBar-createForm:configureActions-general').hover();
        await page.getByRole('menuitem', {
            name: 'Submit'
        }).click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByRole('menuitem', {
            name: 'Submit'
        }).getByRole('switch')).toBeChecked();
        await page.mouse.move(300, 0);
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByRole('button', {
            name: 'Submit'
        })).toBeVisible();
        await page.getByLabel('schema-initializer-ActionBar-createForm:configureActions-general').hover();
        await page.getByRole('menuitem', {
            name: 'Submit'
        }).click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByRole('menuitem', {
            name: 'Submit'
        }).getByRole('switch')).not.toBeChecked();
        await page.mouse.move(300, 0);
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByRole('button', {
            name: 'Submit'
        })).not.toBeVisible();
    });
    (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test)('subTable: should clear form value after submit', async (param)=>{
        let { page, mockPage } = param;
        await mockPage(__WEBPACK_EXTERNAL_MODULE__templatesOfBug_mjs__.T3106).goto();
        await page.getByRole('button', {
            name: 'Add new'
        }).click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-users-form-users.nickname-Nickname').getByRole('textbox')).toHaveValue('test name');
        await page.getByLabel('action-Action-Submit-submit-').click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-users-form-users.nickname-Nickname').getByRole('textbox')).toBeHidden();
        await page.getByRole('button', {
            name: 'Add new'
        }).click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-users-form-users.nickname-Nickname').getByRole('textbox')).toHaveValue('test name');
    });
    (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test)('default values for fields should not be cleared after submission', async (param)=>{
        let { page, mockPage } = param;
        await mockPage(__WEBPACK_EXTERNAL_MODULE__templatesOfBug_mjs__.T3469).goto();
        const username = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.uid)();
        await page.getByLabel('block-item-CollectionField-users-form-users.username-Username').getByRole('textbox').fill(username);
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-users-form-users.nickname-Nickname').getByRole('textbox')).toHaveValue('Should be cleared after submission');
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-users-form-users.username-Username').getByRole('textbox')).toHaveValue(username);
        await page.getByLabel('action-Action-Submit-submit-').click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-users-form-users.nickname-Nickname').getByRole('textbox')).toHaveValue('Should be cleared after submission');
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-users-form-users.username-Username').getByRole('textbox')).toHaveValue('');
    });
    (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test)('customize: save record', async (param)=>{
        let { page, mockPage } = param;
        await mockPage(__WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.oneEmptyForm).goto();
        await page.getByLabel('schema-initializer-ActionBar-createForm:configureActions-general').hover();
        await page.getByRole('menuitem', {
            name: 'Customize'
        }).hover();
        await page.getByRole('menuitem', {
            name: 'Save record'
        }).click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByRole('button', {
            name: 'Save record'
        })).toBeVisible();
    });
});
