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 to open a popup and what can be added to it', ()=>{
    (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test)('add new', async (param)=>{
        let { page, mockPage } = param;
        await mockPage(__WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.oneEmptyTableBlockWithActions).goto();
        await page.getByLabel('action-Action-Add new-create-general-table').click();
        await page.getByLabel('schema-initializer-Tabs-TabPaneInitializersForCreateFormBlock-general').click();
        await page.getByRole('textbox').click();
        await page.getByRole('textbox').fill('test123');
        await page.getByLabel('action-Action-Submit-general-table').click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByText('test123')).toBeVisible();
        await page.getByLabel('schema-initializer-Grid-popup:addNew:addBlock-general').hover();
        await page.getByText('Form').click();
        await page.getByText('Markdown').click();
        await page.mouse.move(300, 0);
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CardItem-general-form')).toBeVisible();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-Markdown.Void-general-markdown')).toBeVisible();
    });
    (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test)('add record', async (param)=>{
        let { page, mockPage } = param;
        await mockPage(__WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.oneEmptyTableBlockWithActions).goto();
        await page.getByLabel('action-Action-Add record-customize:create-general-table').click();
        await page.getByLabel('schema-initializer-Tabs-TabPaneInitializersForCreateFormBlock-general').click();
        await page.getByRole('textbox').click();
        await page.getByRole('textbox').fill('test7');
        await page.getByLabel('action-Action-Submit-general-table').click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByText('test7')).toBeVisible();
        await page.getByLabel('schema-initializer-Grid-popup:addRecord:addBlock-general').hover();
        await page.getByText('Form').hover();
        await page.getByRole('menuitem', {
            name: 'Users'
        }).click();
        await page.getByLabel('schema-initializer-Grid-popup:addRecord:addBlock-general').hover();
        await page.getByRole('menuitem', {
            name: 'Markdown'
        }).click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CardItem-users-form')).toBeVisible();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-Markdown.Void-general-markdown')).toBeVisible();
    });
    (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test)('view', async (param)=>{
        let { page, mockPage, mockRecord } = param;
        const nocoPage = await mockPage(__WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.oneEmptyTableBlockWithActions).waitForInit();
        await mockRecord('general');
        await nocoPage.goto();
        await page.getByLabel('action-Action.Link-View-view-general-table-0').click();
        await page.getByLabel('schema-initializer-Tabs-TabPaneInitializers-general').click();
        await page.getByRole('textbox').click();
        await page.getByRole('textbox').fill('test8');
        await page.getByLabel('action-Action-Submit-general-table-0').click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByText('test8')).toBeVisible();
        await addBlock([
            'table Details right',
            'Current record'
        ]);
        await addBlock([
            'form Form (Edit)'
        ]);
        await addBlock([
            'Markdown'
        ]);
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByText('GeneralConfigure actionsConfigure fields')).toBeVisible();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByText('GeneralConfigure fieldsConfigure actions')).toBeVisible();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-Markdown.Void-general-markdown')).toBeVisible();
        await page.getByText('GeneralConfigure actionsConfigure fields').hover();
        await page.getByLabel('designer-schema-settings-CardItem-blockSettings:details-general').hover();
        await page.getByRole('menuitem', {
            name: 'Delete'
        }).click();
        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-blockSettings:editForm-general').hover();
        await page.getByRole('menuitem', {
            name: 'Delete'
        }).click();
        await page.getByRole('button', {
            name: 'OK',
            exact: true
        }).click();
        await page.getByLabel('block-item-Markdown.Void-general-markdown').hover();
        await page.getByRole('button', {
            name: 'designer-schema-settings-Markdown.Void-blockSettings:markdown-general'
        }).hover();
        await page.getByRole('menuitem', {
            name: 'Delete'
        }).click();
        await page.getByRole('button', {
            name: 'OK',
            exact: true
        }).click();
        await addBlock([
            'table Details right',
            'Associated records',
            'Many to one'
        ]);
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CardItem-users-')).toBeVisible();
        await addBlock([
            'table Table right',
            'Associated records',
            'One to many'
        ]);
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CardItem-users-table')).toBeVisible();
        async function addBlock(names) {
            await page.getByLabel('schema-initializer-Grid-popup').hover();
            for(let i = 0; i < names.length - 1; i++){
                const name = names[i];
                await page.getByRole('menuitem', {
                    name
                }).hover();
            }
            await page.getByRole('menuitem', {
                name: names[names.length - 1]
            }).click();
            await page.mouse.move(300, 0);
        }
    });
    (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test)('bulk edit', async (param)=>{
        let { page, mockPage } = param;
        await mockPage(__WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.oneEmptyTableBlockWithCustomizeActions).goto();
        await page.getByLabel('action-Action-Bulk edit-customize:bulkEdit-general-table').click();
        await page.getByLabel('schema-initializer-Tabs-TabPaneInitializersForBulkEditFormBlock-general').click();
        await page.getByRole('textbox').click();
        await page.getByRole('textbox').fill('test1');
        await page.getByLabel('action-Action-Submit-general-table').click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByText('test1')).toBeVisible();
        await page.getByLabel('schema-initializer-Grid-popup:bulkEdit:addBlock-general').hover();
        await page.getByText('Form').click();
        await page.getByRole('menuitem', {
            name: 'Markdown'
        }).click();
        await page.mouse.move(300, 0);
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CardItem-general-form')).toBeVisible();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-Markdown.Void-general-markdown')).toBeVisible();
    });
    (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test)('association link', async (param)=>{
        let { page, mockPage, mockRecord } = param;
        const nocoPage = await mockPage(__WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.oneDetailBlockWithM2oFieldToGeneral).waitForInit();
        const record = await mockRecord('targetToGeneral');
        await nocoPage.goto();
        await page.getByLabel('block-item-CollectionField-targetToGeneral-details-targetToGeneral.toGeneral-toGeneral').getByText(record.id, {
            exact: true
        }).click();
        await page.getByLabel('schema-initializer-Tabs-TabPaneInitializers-general').click();
        await page.getByRole('textbox').click();
        await page.getByRole('textbox').fill('test8');
        await page.getByLabel('action-Action-Submit-general-details').click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByText('test8')).toBeVisible();
        await page.getByLabel('schema-initializer-Grid-popup:common:addBlock-general').hover();
        await page.getByRole('menuitem', {
            name: 'Details'
        }).hover();
        await page.getByRole('menuitem', {
            name: 'Current record'
        }).click();
        await page.getByLabel('schema-initializer-Grid-popup:common:addBlock-general').hover();
        await page.getByRole('menuitem', {
            name: 'form Form (Edit)'
        }).first().click();
        await page.getByLabel('schema-initializer-Grid-popup:common:addBlock-general').hover();
        await page.getByRole('menuitem', {
            name: 'Markdown'
        }).click();
        await page.mouse.move(300, 0);
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByText('GeneralConfigure actionsConfigure fields')).toBeVisible();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByText('GeneralConfigure fieldsConfigure actions')).toBeVisible();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-Markdown.Void-general-markdown')).toBeVisible();
        await page.getByLabel('schema-initializer-Grid-popup:common:addBlock-general').hover();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByRole('menuitem', {
            name: 'table Details right'
        })).toBeVisible();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByRole('menuitem', {
            name: 'form Form (Edit)'
        })).toBeVisible();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByRole('menuitem', {
            name: 'form Form (Add new) right'
        })).toBeVisible();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByRole('menuitem', {
            name: 'form Form (Add new) right'
        })).toBeVisible();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByRole('menuitem', {
            name: 'table Table right'
        })).toBeVisible();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByRole('menuitem', {
            name: 'ordered-list List right'
        })).toBeVisible();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByRole('menuitem', {
            name: 'ordered-list Grid Card right'
        })).toBeVisible();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByRole('menuitem', {
            name: 'Calendar'
        })).toBeVisible();
        await page.getByLabel('schema-initializer-Grid-popup:common:addBlock-general').hover();
        await page.getByRole('menuitem', {
            name: 'Details'
        }).hover();
        await page.getByRole('menuitem', {
            name: 'Associated records'
        }).hover();
        await page.getByRole('menuitem', {
            name: 'Many to one'
        }).click();
        await page.mouse.move(300, 0);
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CardItem-users-')).toBeVisible();
        await page.getByLabel('schema-initializer-Grid-popup:common:addBlock-general').hover();
        await page.getByRole('menuitem', {
            name: 'table Table right'
        }).hover();
        await page.getByRole('menuitem', {
            name: 'Associated records'
        }).hover();
        await page.getByRole('menuitem', {
            name: 'One to many'
        }).click();
        await page.mouse.move(300, 0);
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CardItem-users-table')).toBeVisible();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.locator('.ant-notification-notice').first()).toBeHidden({
            timeout: 1000
        });
    });
    (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test)('data picker', async (param)=>{
        let { page, mockPage } = param;
        await mockPage(__WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.oneFormBlockWithRolesFieldBasedUsers).goto();
        await page.getByTestId('select-data-picker').click();
        await addBlock('form Table');
        await addBlock('form Form');
        await addBlock('Collapse');
        await addBlock('Add text');
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CardItem-roles-table-selector')).toBeVisible();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CardItem-roles-filter-form')).toBeVisible();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CardItem-roles-filter-collapse')).toBeVisible();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-Markdown.Void-roles-form')).toBeVisible();
        async function addBlock(name) {
            await page.getByLabel('schema-initializer-Grid-popup:tableSelector:addBlock-roles').hover();
            await page.getByRole('menuitem', {
                name
            }).click();
            await page.mouse.move(300, 0);
        }
    });
});
__WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test.describe('add blocks to the popup', ()=>{
    (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test)('no inheritance, no views, no association fields', async (param)=>{
        let { page, mockPage } = param;
        await mockPage(__WEBPACK_EXTERNAL_MODULE__templatesOfBug_mjs__.tableWithRoles).goto();
        await page.getByLabel('action-Action.Link-View-view-roles-table-root').click();
        await page.getByLabel('schema-initializer-Grid-popup').hover();
        await page.getByRole('menuitem', {
            name: 'table Details'
        }).click();
        await page.getByLabel('schema-initializer-Grid-details:configureFields-roles').hover();
        await page.getByRole('menuitem', {
            name: 'Role UID'
        }).click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-Role').getByText('root')).toBeVisible();
        await page.mouse.move(300, 0);
        await page.getByLabel('schema-initializer-Grid-popup').hover();
        await page.getByRole('menuitem', {
            name: 'form Form (Edit)'
        }).click();
        await page.getByLabel('schema-initializer-Grid-form:').hover();
        await page.getByRole('menuitem', {
            name: 'Role UID'
        }).click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-roles-form-roles.name-Role UID').getByRole('textbox')).toHaveValue('root');
    });
    (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test)('no inheritance, no views, with association fields', async (param)=>{
        let { page, mockPage } = param;
        await mockPage(__WEBPACK_EXTERNAL_MODULE__templatesOfBug_mjs__.tableWithUsers).goto();
        await page.getByLabel('action-Action.Link-View-view-').click();
        await page.getByLabel('schema-initializer-Grid-popup').hover();
        await page.getByRole('menuitem', {
            name: 'table Details right'
        }).hover();
        await page.getByRole('menuitem', {
            name: 'Current record'
        }).click();
        await page.getByLabel('schema-initializer-Grid-details:configureFields-users').hover();
        await page.getByRole('menuitem', {
            name: 'Nickname'
        }).click();
        await page.mouse.move(300, 0);
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-users').getByText('Super Admin')).toBeVisible();
        await page.getByLabel('schema-initializer-Grid-popup').hover();
        await page.getByRole('menuitem', {
            name: 'table Details right'
        }).hover();
        await page.getByRole('menuitem', {
            name: 'Associated records'
        }).hover();
        await page.getByRole('menuitem', {
            name: 'Roles'
        }).click();
        await page.getByLabel('schema-initializer-Grid-details:configureFields-roles').hover();
        await page.getByRole('menuitem', {
            name: 'Role UID'
        }).click();
        await page.mouse.move(300, 0);
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-roles').getByText('admin')).toBeVisible();
    });
    (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test)('with inheritance, with association fields', async (param)=>{
        let { page, mockPage, mockRecord } = param;
        const nocoPage = await mockPage(__WEBPACK_EXTERNAL_MODULE__templatesOfBug_mjs__.tableWithInherit).waitForInit();
        const fatherRecord = await mockRecord('father');
        await nocoPage.goto();
        await page.getByLabel('action-Action.Link-View-view-father-table-0').click();
        await page.getByLabel('schema-initializer-Grid-popup').hover();
        await page.getByRole('menuitem', {
            name: 'table Details right'
        }).hover();
        await page.getByRole('menuitem', {
            name: 'Current record right'
        }).hover();
        await page.getByRole('menuitem', {
            name: 'father'
        }).click();
        await page.mouse.move(-300, 0);
        await page.getByLabel('schema-initializer-Grid-details:configureFields-father').hover();
        await page.getByRole('menuitem', {
            name: 'singleLineText'
        }).click();
        await page.mouse.move(300, 0);
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-father').getByText(fatherRecord.singleLineText)).toBeVisible();
        await page.getByLabel('schema-initializer-Grid-popup').hover();
        await page.getByRole('menuitem', {
            name: 'table Table right'
        }).hover();
        await page.getByRole('menuitem', {
            name: 'Associated records'
        }).hover();
        await page.getByRole('menuitem', {
            name: 'manyToMany'
        }).click();
        await page.mouse.move(-300, 0);
        await page.getByTestId('drawer-Action.Container-father-View record').getByLabel('schema-initializer-TableV2-').hover();
        await page.getByRole('menuitem', {
            name: 'singleLineText'
        }).click();
        await page.mouse.move(300, 0);
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByTestId('drawer-Action.Container-father-View record').getByLabel('block-item-CardItem-').getByRole('row').getByText(fatherRecord.manyToMany[0].singleLineText)).toBeVisible();
    });
    (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test)('with inheritance, no association fields', async (param)=>{
        let { page, mockPage, mockRecord } = param;
        const nocoPage = await mockPage(__WEBPACK_EXTERNAL_MODULE__templatesOfBug_mjs__.tableWithInheritWithoutAssociation).waitForInit();
        const fatherRecord = await mockRecord('father');
        await nocoPage.goto();
        await page.getByLabel('action-Action.Link-View-view-father-table-0').click();
        await page.getByLabel('schema-initializer-Grid-popup').hover();
        await page.getByRole('menuitem', {
            name: 'table Details right'
        }).hover();
        await page.getByRole('menuitem', {
            name: 'Current record right'
        }).hover();
        await page.getByRole('menuitem', {
            name: 'father'
        }).click();
        await page.getByLabel('schema-initializer-Grid-details:configureFields-father').hover();
        await page.getByRole('menuitem', {
            name: 'singleLineText'
        }).click();
        await page.mouse.move(300, 0);
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-father').getByText(fatherRecord.singleLineText)).toBeVisible();
    });
    (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test)('only support association fields', async (param)=>{
        let { page, mockPage } = param;
        await mockPage(__WEBPACK_EXTERNAL_MODULE__templatesOfBug_mjs__.tableWithUsers).goto();
        await page.getByLabel('action-Action.Link-View-view-').click();
        await page.getByLabel('schema-initializer-Grid-popup').hover();
        await page.getByRole('menuitem', {
            name: 'table Table right'
        }).hover();
        await page.getByRole('menuitem', {
            name: 'Associated records'
        }).hover();
        await page.getByRole('menuitem', {
            name: 'Roles'
        }).click();
        await page.getByTestId('drawer-Action.Container-users-View record').getByLabel('schema-initializer-TableV2-').hover();
        await page.getByRole('menuitem', {
            name: 'Role UID'
        }).click();
        await page.mouse.move(300, 0);
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CardItem-roles-').getByRole('row').getByText('root')).toBeVisible();
    });
});
