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('display association fields', ()=>{
    (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test)('form: should display correctly', async (param)=>{
        let { page, mockPage, mockRecord } = param;
        const nocoPage = await mockPage(__WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.oneFormWithMultiLevelAssociationFields).waitForInit();
        await mockRecord('general');
        await nocoPage.goto();
        await page.getByLabel('block-item-CollectionField-general-form-general.m2oField0-m2oField0').getByTestId('select-object-single').click();
        await page.getByRole('option', {
            name: '1',
            exact: true
        }).click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-general-form-general.m2oField0.id')).toHaveText('ID:1');
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-general-form-general.m2oField0.m2oField1')).toHaveText('m2oField1:1');
    });
    (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test)('subform: should display correctly', async (param)=>{
        let { page, mockPage, mockRecord } = param;
        const nocoPage = await mockPage(__WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.oneSubformWithMultiLevelAssociationFields).waitForInit();
        await mockRecord('general');
        await nocoPage.goto();
        await page.getByLabel('block-item-CollectionField-m2oField1-form-m2oField1.m2oField1-m2oField1').getByTestId('select-object-single').click();
        await page.getByRole('option', {
            name: '1',
            exact: true
        }).click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-m2oField1-form-m2oField1.m2oField1.id')).toHaveText('ID:1');
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-m2oField1-form-m2oField1.m2oField1.m2oField2')).toHaveText('m2oField2:1');
    });
    (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test)('should load association data', async (param)=>{
        let { page, mockPage, mockRecord } = param;
        const nocoPage = await mockPage(__WEBPACK_EXTERNAL_MODULE__templatesOfBug_mjs__.T2615).waitForInit();
        await mockRecord('T2615');
        await nocoPage.goto();
        await page.getByRole('button', {
            name: 'Add new'
        }).click();
        await page.getByLabel('block-item-CollectionField-T2615-form-T2615.m2o-m2o').getByTestId('select-object-single').click();
        await page.getByRole('option', {
            name: '1'
        }).click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-T2615-form-T2615.m2o.m2oOfTarget1')).toHaveText("m2oOfTarget1:1");
        await page.getByLabel('drawer-Action.Container-T2615-Add record-mask').click();
        await page.getByRole('button', {
            name: 'OK',
            exact: true
        }).click();
        await page.getByLabel('action-Action.Link-Edit record-update-T2615-table-0').click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-T2615-form-T2615.m2o-m2o')).toHaveText("m2o:1");
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-T2615-form-T2615.m2o.m2oOfTarget1')).toHaveText("m2oOfTarget1:1");
        await page.getByLabel('drawer-Action.Container-T2615-Edit record-mask').click();
        await page.getByLabel('action-Action.Link-View record-view-T2615-table-0').click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-T2615-form-T2615.m2o-m2o')).toHaveText("m2o:1");
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-T2615-form-T2615.m2o.m2oOfTarget1')).toHaveText("m2oOfTarget1:1");
    });
    (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test)('should load association data of subform', async (param)=>{
        let { page, mockPage, mockRecord } = param;
        const nocoPage = await mockPage(__WEBPACK_EXTERNAL_MODULE__templatesOfBug_mjs__.T2845).waitForInit();
        const record = await mockRecord('T2615');
        await nocoPage.goto();
        await page.getByRole('button', {
            name: 'Add new'
        }).click();
        await page.getByLabel('block-item-CollectionField-T2615-form-T2615.m2o-m2o').getByTestId('select-object-single').click();
        await page.getByRole('option', {
            name: String(record.m2o.id)
        }).click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-T2615Target2-form-T2615Target2.id-ID')).toHaveText("ID:".concat(record.m2o.m2oOfTarget1.id));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-T2615Target2-form-T2615Target2.m2oOfTarget2-')).toHaveText("m2oOfTarget2:".concat(record.m2o.m2oOfTarget1.m2oOfTarget2.id));
        await page.getByLabel('drawer-Action.Container-T2615-Add record-mask').click();
        await page.getByRole('button', {
            name: 'OK',
            exact: true
        }).click();
        await page.getByLabel("action-Action.Link-Edit record-update-T2615-table-".concat(record.id - 1)).click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-T2615Target2-form-T2615Target2.id-ID')).toHaveText("ID:".concat(record.m2o.m2oOfTarget1.id));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-T2615Target2-form-T2615Target2.m2oOfTarget2-')).toHaveText("m2oOfTarget2:".concat(record.m2o.m2oOfTarget1.m2oOfTarget2.id));
        await page.getByLabel('drawer-Action.Container-T2615-Edit record-mask').click();
        await page.getByLabel("action-Action.Link-View record-view-T2615-table-".concat(record.id - 1)).click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-T2615-form-T2615.m2o-m2o')).toHaveText("m2o:".concat(record.m2o.id));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-T2615Target2-form-T2615Target2.id-ID')).toHaveText("ID:".concat(record.m2o.m2oOfTarget1.id));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-T2615Target2-form-T2615Target2.m2oOfTarget2-')).toHaveText("m2oOfTarget2:".concat(record.m2o.m2oOfTarget1.m2oOfTarget2.id));
    });
    (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test)('should load association data in subform', async (param)=>{
        let { page, mockPage, mockRecord } = param;
        const nocoPage = await mockPage(__WEBPACK_EXTERNAL_MODULE__templatesOfBug_mjs__.T2614).waitForInit();
        await mockRecord('T2614');
        await nocoPage.goto();
        await page.getByLabel('action-Action.Link-View record-view-T2614-table-0').click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-T2614Target1-form-T2614Target1.m2oOfTarget1-m2oOfTarget1')).toHaveText("m2oOfTarget1:1");
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-T2614Target1-form-T2614Target1.m2oOfTarget1.id')).toHaveText("ID:1");
        await page.getByLabel('drawer-Action.Container-T2614-View record-mask').click();
        await page.getByLabel('action-Action.Link-Edit record-update-T2614-table-0').click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-T2614Target1-form-T2614Target1.m2oOfTarget1-m2oOfTarget1')).toHaveText("m2oOfTarget1:1");
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-T2614Target1-form-T2614Target1.m2oOfTarget1.id')).toHaveText("ID:1");
    });
    (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test)('should load association data of sub details', async (param)=>{
        let { page, mockPage, mockRecord } = param;
        const nocoPage = await mockPage(__WEBPACK_EXTERNAL_MODULE__templatesOfBug_mjs__.T2993).waitForInit();
        const record = await mockRecord('T2993');
        await nocoPage.goto();
        await page.getByLabel('action-Action-Add new-create-').click();
        await page.getByLabel('block-item-CollectionField-T2993Target1-form-T2993Target1.m2oOfTarget1-').getByTestId('select-object-single').click();
        await page.getByRole('option', {
            name: '1'
        }).click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-users-form-users.nickname-Nickname')).toHaveText(new RegExp(record.m2o.m2oOfTarget1.m2oOfTarget2.nickname));
    });
});
__WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test.describe('association fields', ()=>{
    (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test)('subform: load association fields', async (param)=>{
        let { page, mockPage, mockRecord } = param;
        const nocoPage = await mockPage(__WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.oneTableSubformWithMultiLevelAssociationFields).waitForInit();
        const record = await mockRecord('general');
        await nocoPage.goto();
        await page.getByLabel('action-Action.Link-View record-view-general-table-0').click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-general-form-general.id-ID')).toHaveText("ID:".concat(record.id));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-m2oField1-form-m2oField1.id-ID')).toHaveText("ID:".concat(record.m2oField0.id));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-m2oField2-form-m2oField2.id-ID')).toHaveText("ID:".concat(record.m2oField0.m2oField1.id));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-m2oField3-form-m2oField3.id-ID')).toHaveText("ID:".concat(record.m2oField0.m2oField1.m2oField2.id));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-m2oField3-form-m2oField3.m2oField3-m2oField3')).toHaveText("m2oField3:".concat(record.m2oField0.m2oField1.m2oField2.m2oField3.id));
        await page.getByLabel('drawer-Action.Container-general-View record-mask').click();
        await page.getByLabel('action-Action.Link-Edit record-update-general-table-0').click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-general-form-general.id-ID')).toHaveText("ID:".concat(record.id));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-m2oField1-form-m2oField1.id-ID')).toHaveText("ID:".concat(record.m2oField0.id));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-m2oField2-form-m2oField2.id-ID')).toHaveText("ID:".concat(record.m2oField0.m2oField1.id));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-m2oField3-form-m2oField3.id-ID')).toHaveText("ID:".concat(record.m2oField0.m2oField1.m2oField2.id));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-m2oField3-form-m2oField3.m2oField3-m2oField3')).toHaveText("m2oField3:".concat(record.m2oField0.m2oField1.m2oField2.m2oField3.id));
    });
    (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test)('subtable: load association fields', async (param)=>{
        let { page, mockPage, mockRecord } = param;
        const nocoPage = await mockPage(__WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.oneTableSubtableWithMultiLevelAssociationFields).waitForInit();
        const record = await mockRecord('general');
        await nocoPage.goto();
        await page.getByLabel('action-Action.Link-View record-view-general-table-0').click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-general-form-general.id-ID')).toHaveText("ID:".concat(record.id));
        for(let index = 0; index < record.m2mField0.length; index++)await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-general-form-general.m2mField0-m2mField0').getByLabel('block-item-CollectionField-m2mField1-form-m2mField1.m2mField1-m2mField1').nth(index)).toHaveText(new RegExp(record.m2mField0[index].m2mField1.map((item)=>item.id).join(',')));
        await page.getByLabel('drawer-Action.Container-general-View record-mask').click();
        await page.getByLabel('action-Action.Link-Edit record-update-general-table-0').click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-general-form-general.id-ID')).toHaveText("ID:".concat(record.id));
        for(let index = 0; index < record.m2mField0.length; index++)await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('block-item-CollectionField-general-form-general.m2mField0-m2mField0').getByLabel('block-item-CollectionField-m2mField1-form-m2mField1.m2mField1-m2mField1').nth(index)).toHaveText(new RegExp(record.m2mField0[index].m2mField1.map((item)=>item.id).join('')));
    });
    (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test)('should be possible to change the value of the association field normally', async (param)=>{
        let { page, mockPage } = param;
        await mockPage(__WEBPACK_EXTERNAL_MODULE__templatesOfBug_mjs__.T2200).goto();
        await page.getByLabel('action-Action.Link-Edit-update-users-table-0').click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('Admin')).toBeVisible();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('Member')).toBeVisible();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('Root')).toBeVisible();
        await page.getByTestId('select-object-multiple').click();
        await page.getByRole('option', {
            name: 'Member'
        }).click();
        await page.getByTestId('select-object-multiple').click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('Admin')).toBeVisible();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('Member')).toBeHidden();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('Root')).toBeVisible();
        await page.getByLabel('schema-initializer-Grid-form:configureFields-users').hover();
        await page.getByRole('menuitem', {
            name: 'Nickname'
        }).click();
        await page.mouse.move(200, 0);
        await page.waitForTimeout(200);
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('Admin')).toBeVisible();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('Member')).toBeHidden();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('Root')).toBeVisible();
    });
});
