import * as __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__ from "@tachybase/test/e2e";
const clickOption = async (page, optionName)=>{
    await page.getByLabel('block-item-CardItem-general-form').hover();
    await page.getByLabel('designer-schema-settings-CardItem-FormV2.Designer-general').hover();
    await page.getByRole('menuitem', {
        name: optionName
    }).click();
};
__WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test.describe('edit form block schema settings', ()=>{
    (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test)('Edit block title', async (param)=>{
        let { page, mockPage, mockRecord } = param;
        const nocoPage = await mockPage(__WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.oneTableBlockWithActionsAndFormBlocks).waitForInit();
        await mockRecord('general');
        await nocoPage.goto();
        await page.getByText('Edit', {
            exact: true
        }).click();
        await clickOption(page, 'Edit block title');
        await page.getByRole('textbox').click();
        await page.getByRole('textbox').fill('Block title 123');
        await page.getByRole('button', {
            name: 'OK',
            exact: true
        }).click();
        const runExpect = async ()=>{
            await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CardItem-general-form').getByText('Block title 123', {
                exact: true
            })).toBeVisible();
            await clickOption(page, 'Edit block title');
            await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByRole('textbox')).toHaveValue('Block title 123');
        };
        await runExpect();
        await page.reload();
        await page.getByText('Edit', {
            exact: true
        }).click();
        await runExpect();
    });
    (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test)('Linkage rules', async (param)=>{
        let { page, mockPage, mockRecord } = param;
        const nocoPage = await mockPage(__WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.oneTableBlockWithActionsAndFormBlocks).waitForInit();
        await mockRecord('general');
        await nocoPage.goto();
        await page.getByText('Edit', {
            exact: true
        }).click();
        await clickOption(page, 'Linkage rules');
        await page.getByRole('button', {
            name: 'Add linkage rule'
        }).click();
        await page.getByText('Add property').click();
        await page.getByTestId('select-linkage-property-field').click();
        await page.getByText('singleLineText', {
            exact: true
        }).click();
        await page.getByTestId('select-linkage-action-field').click();
        await page.getByRole('option', {
            name: 'Visible'
        }).click();
        await page.getByRole('button', {
            name: 'OK',
            exact: true
        }).click();
        const runExpect = async ()=>{
            await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByTestId('select-linkage-property-field').getByText('singleLineText')).toBeVisible();
            await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByTestId('select-linkage-action-field').getByText('Visible')).toBeVisible();
        };
        await clickOption(page, 'Linkage rules');
        await runExpect();
        await page.reload();
        await page.getByText('Edit', {
            exact: true
        }).click();
        await clickOption(page, 'Linkage rules');
        await runExpect();
    });
    (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test)('Convert reference to duplicate & Save as block template', async (param)=>{
        let { page, mockPage, mockRecord } = param;
        const nocoPage = await mockPage(__WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.oneTableBlockWithActionsAndFormBlocks).waitForInit();
        await mockRecord('general');
        await nocoPage.goto();
        await page.getByText('Edit', {
            exact: true
        }).click();
        await clickOption(page, 'Save as block template');
        await page.getByRole('button', {
            name: 'OK',
            exact: true
        }).click();
        await page.getByLabel('block-item-CardItem-general-form').hover();
        await page.getByLabel('designer-schema-settings-CardItem-FormV2.Designer-general').hover();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByRole('menuitem', {
            name: 'Save as block template'
        })).not.toBeVisible();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByRole('menuitem', {
            name: 'Convert reference to duplicate'
        })).toBeVisible();
        await page.reload();
        await page.getByText('Edit', {
            exact: true
        }).click();
        await page.getByLabel('block-item-CardItem-general-form').hover();
        await page.getByLabel('designer-schema-settings-CardItem-FormV2.Designer-general').hover();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByRole('menuitem', {
            name: 'Save as block template'
        })).not.toBeVisible();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByRole('menuitem', {
            name: 'Convert reference to duplicate'
        })).toBeVisible();
        await clickOption(page, 'Convert reference to duplicate');
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByRole('menuitem', {
            name: 'Save as block template'
        })).toBeVisible();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByRole('menuitem', {
            name: 'Convert reference to duplicate'
        })).not.toBeVisible();
        await page.reload();
        await page.getByText('Edit', {
            exact: true
        }).click();
        await page.getByLabel('block-item-CardItem-general-form').hover();
        await page.getByLabel('designer-schema-settings-CardItem-FormV2.Designer-general').hover();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByRole('menuitem', {
            name: 'Save as block template'
        })).toBeVisible();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByRole('menuitem', {
            name: 'Convert reference to duplicate'
        })).not.toBeVisible();
        await page.goto('/admin/settings/ui-schema-storage');
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByRole('row', {
            name: 'General_Form'
        }).first()).toBeVisible();
        await page.getByLabel('Select all').check();
        await page.getByLabel('action-Action-Delete-destroy-').click();
        await page.getByRole('button', {
            name: 'OK',
            exact: true
        }).click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByRole('row', {
            name: 'General_Form'
        }).first()).toBeHidden();
    });
    (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test)('Delete', async (param)=>{
        let { page, mockPage, mockRecord } = param;
        const nocoPage = await mockPage(__WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.oneTableBlockWithActionsAndFormBlocks).waitForInit();
        await mockRecord('general');
        await nocoPage.goto();
        await page.getByText('Edit', {
            exact: true
        }).click();
        await page.getByLabel('block-item-CardItem-general-form').hover();
        await page.getByLabel('designer-schema-settings-CardItem-FormV2.Designer-general').hover();
        await page.getByRole('menuitem', {
            name: 'Delete'
        }).click();
        await page.getByRole('button', {
            name: 'OK',
            exact: true
        }).click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CardItem-general-form')).not.toBeVisible();
        await page.reload();
        await page.getByText('Edit', {
            exact: true
        }).click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CardItem-general-form')).not.toBeVisible();
    });
});
__WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test.describe('actions schema settings', ()=>{
    (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test)('submit', async (param)=>{
        let { page, mockPage } = param;
        await mockPage(__WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.oneEmptyFormWithActions).goto();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expectSettingsMenu)({
            page,
            showMenu: async ()=>{
                await page.getByRole('button', {
                    name: 'Submit'
                }).hover();
                await page.getByRole('button', {
                    name: 'designer-schema-settings-Action-Action.Designer-users'
                }).hover();
            },
            supportedOptions: [
                'Edit button',
                'Bind workflows',
                'Delete'
            ]
        });
    });
    (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__.oneEmptyFormWithActions).goto();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expectSettingsMenu)({
            page,
            showMenu: async ()=>{
                await page.getByRole('button', {
                    name: 'Save record'
                }).hover();
                await page.getByRole('button', {
                    name: 'designer-schema-settings-Action-Action.Designer-users'
                }).hover();
            },
            supportedOptions: [
                'Edit button',
                'Assign field values',
                'Skip required validation',
                'After successful submission',
                'Bind workflows',
                'Delete'
            ]
        });
    });
});
