"use strict";
var __webpack_exports__ = {};
const e2e_namespaceObject = require("@tachybase/test/e2e");
const external_templatesOfBug_js_namespaceObject = require("./templatesOfBug.js");
const external_utils_js_namespaceObject = require("./utils.js");
e2e_namespaceObject.test.describe('table data selector schema settings', ()=>{
    (0, e2e_namespaceObject.test)('supported options', async (param)=>{
        let { page, mockPage } = param;
        await (0, external_utils_js_namespaceObject.createTable)({
            page,
            mockPage,
            fieldName: 'manyToOne'
        });
        await (0, e2e_namespaceObject.expectSettingsMenu)({
            page,
            showMenu: ()=>showSettingsMenu(page),
            supportedOptions: [
                'Set the data scope',
                'Set default sorting rules',
                'Records per page',
                'Delete'
            ]
        });
    });
    (0, e2e_namespaceObject.test)('should have a current form variable', async (param)=>{
        let { page, mockPage, mockRecord } = param;
        const nocoPage = await mockPage(external_templatesOfBug_js_namespaceObject.tableSelectorDataScopeVariable).waitForInit();
        const record = await mockRecord('table-selector-data-scope-variable');
        await nocoPage.goto();
        await page.getByLabel('action-Action.Link-View-view-table-selector-data-scope-variable-table-0').click();
        await page.getByTestId('select-data-picker').click();
        await page.getByTestId('drawer-AssociationField.Selector-table-selector-data-scope-variable-Select record').getByLabel('block-item-CardItem-table-').hover();
        await page.getByLabel('designer-schema-settings-CardItem-blockSettings:tableSelector-table-selector-').hover();
        await page.getByRole('menuitem', {
            name: 'Set the data scope'
        }).click();
        await page.getByText('Add condition', {
            exact: true
        }).click();
        await page.getByTestId('select-filter-field').click();
        await page.getByRole('menuitemcheckbox', {
            name: 'singleLineText'
        }).click();
        await page.getByTestId('select-filter-operator').click();
        await page.getByRole('option', {
            name: 'is',
            exact: true
        }).click();
        await page.getByLabel('variable-button').click();
        await page.getByRole('menuitemcheckbox', {
            name: 'Current form right'
        }).click();
        await page.getByRole('menuitemcheckbox', {
            name: 'singleLineText'
        }).click();
        await page.getByRole('button', {
            name: 'OK',
            exact: true
        }).click();
        await (0, e2e_namespaceObject.expect)(page.getByTestId('drawer-AssociationField.Selector-table-selector-data-scope-variable-Select record').getByLabel('block-item-CardItem-table-').getByRole('row')).toHaveCount(2);
        await (0, e2e_namespaceObject.expect)(page.getByTestId('drawer-AssociationField.Selector-table-selector-data-scope-variable-Select record').getByLabel('block-item-CardItem-table-').getByText(record['singleLineText'])).toBeVisible();
    });
    (0, e2e_namespaceObject.test)('should have a current object variable', async (param)=>{
        let { page, mockPage, mockRecord } = param;
        const nocoPage = await mockPage(external_templatesOfBug_js_namespaceObject.tableSelectorDataScopeVariable).waitForInit();
        const record = await mockRecord('table-selector-data-scope-variable');
        await nocoPage.goto();
        await page.getByLabel('action-Action.Link-View-view-table-selector-data-scope-variable-table-0').click();
        await page.getByLabel('block-item-CollectionField-table-selector-data-scope-variable-form-table-selector-data-scope-variable.manyToMany-manyToMany', {
            exact: true
        }).hover();
        await page.getByLabel('designer-schema-settings-CollectionField-fieldSettings:FormItem-table-selector-data-scope-variable-table-selector-data-scope-variable.manyToMany', {
            exact: true
        }).hover();
        await page.getByText('Field componentRecord picker').click();
        await page.getByRole('option', {
            name: 'Sub-form',
            exact: true
        }).click();
        await page.getByRole('menuitem', {
            name: 'Delete'
        }).hover();
        await page.mouse.move(-300, 0);
        await page.getByLabel('schema-initializer-Grid-form:').first().hover();
        await page.getByRole('menuitem', {
            name: 'manyToMany'
        }).click();
        await page.getByRole('menuitem', {
            name: 'singleLineText'
        }).click();
        await page.getByLabel('block-item-CollectionField-').nth(1).hover();
        await page.getByLabel('designer-schema-settings-CollectionField-fieldSettings:FormItem-table-selector-').nth(1).hover();
        await page.getByRole('menuitem', {
            name: 'Field component Select'
        }).click();
        await page.getByRole('option', {
            name: 'Record picker'
        }).click();
        await page.getByRole('menuitem', {
            name: 'Delete'
        }).hover();
        await page.mouse.move(-300, 0);
        await page.getByLabel('block-item-CollectionField-').nth(1).click();
        await page.getByLabel('schema-initializer-Grid-popup').hover();
        await page.getByRole('menuitem', {
            name: 'form Table'
        }).click();
        await page.getByLabel('block-item-CardItem-table-selector-data-scope-variable-table-selector').hover();
        await page.getByLabel('designer-schema-settings-CardItem-blockSettings:tableSelector-table-selector-').hover();
        await page.getByRole('menuitem', {
            name: 'Set the data scope'
        }).click();
        await page.getByText('Add condition', {
            exact: true
        }).click();
        await page.getByTestId('select-filter-field').click();
        await page.getByRole('menuitemcheckbox', {
            name: 'singleLineText'
        }).click();
        await page.getByTestId('select-filter-operator').click();
        await page.getByRole('option', {
            name: 'is',
            exact: true
        }).click();
        await page.getByLabel('variable-button').click();
        await page.getByRole('menuitemcheckbox', {
            name: 'Current object right'
        }).click();
        await page.getByRole('menuitemcheckbox', {
            name: 'singleLineText'
        }).click();
        await page.getByRole('button', {
            name: 'OK',
            exact: true
        }).click();
        await page.getByLabel('schema-initializer-TableV2.').hover();
        await page.getByRole('menuitem', {
            name: 'singleLineText'
        }).click();
        await page.mouse.move(300, 0);
        await (0, e2e_namespaceObject.expect)(page.getByLabel('block-item-CardItem-table-selector-data-scope-variable-table-selector').getByRole('row')).toHaveCount(2);
        await (0, e2e_namespaceObject.expect)(page.getByLabel('block-item-CardItem-table-selector-data-scope-variable-table-selector').getByRole('row').getByText(record['manyToMany'][0]['singleLineText'])).toBeVisible();
    });
});
async function showSettingsMenu(page) {
    await page.getByLabel('block-item-CardItem-users-table-selector').hover();
    await page.getByLabel('designer-schema-settings-CardItem-blockSettings:tableSelector-users').hover();
}
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
});
