"use strict";
var __webpack_exports__ = {};
const e2e_namespaceObject = require("@tachybase/test/e2e");
e2e_namespaceObject.test.describe('group page menus schema settings', ()=>{
    (0, e2e_namespaceObject.test)('edit', async (param)=>{
        let { page, mockPage } = param;
        await mockPage({
            type: 'group',
            name: 'group page'
        }).goto();
        await showSettings(page, 'group page');
        await page.getByRole('menuitem', {
            name: 'Edit'
        }).click();
        await page.mouse.move(300, 0);
        await page.getByRole('textbox').click();
        await page.getByRole('textbox').fill('new group page');
        await page.getByRole('button', {
            name: 'Select icon'
        }).click();
        await page.getByRole('tooltip').getByLabel('account-book').locator('svg').click();
        await page.getByRole('button', {
            name: 'OK',
            exact: true
        }).click();
        await page.reload();
        await (0, e2e_namespaceObject.expect)(page.getByLabel('new group page')).toBeVisible();
        await (0, e2e_namespaceObject.expect)(page.getByLabel('new group page').getByLabel('account-book').locator('svg')).toBeVisible();
    });
    (0, e2e_namespaceObject.test)('move to', async (param)=>{
        let { page, mockPage } = param;
        await mockPage({
            type: 'group',
            name: 'anchor page'
        }).waitForInit();
        await mockPage({
            type: 'group',
            name: 'a other group page'
        }).waitForInit();
        await mockPage({
            type: 'group',
            name: 'group page'
        }).goto();
        await (0, e2e_namespaceObject.expect)(page.getByText('anchor pagea other group pagegroup page')).toBeVisible();
        await showSettings(page, 'group page');
        await page.getByRole('menuitem', {
            name: 'Move to'
        }).click();
        await page.mouse.move(300, 0);
        await page.getByLabel('block-item-TreeSelect-Target').locator('.ant-select').click();
        await page.locator('.ant-select-dropdown').getByText('anchor page').click();
        await page.getByLabel('Before').click();
        await page.getByRole('button', {
            name: 'OK',
            exact: true
        }).click();
        await (0, e2e_namespaceObject.expect)(page.getByText('group pageanchor pagea other group page')).toBeVisible();
        await showSettings(page, 'group page');
        await page.getByRole('menuitem', {
            name: 'Move to'
        }).click();
        await page.mouse.move(300, 0);
        await page.getByLabel('block-item-TreeSelect-Target').locator('.ant-select').click();
        await page.locator('.ant-select-dropdown').getByText('anchor page').click();
        await page.getByLabel('After').click();
        await page.getByRole('button', {
            name: 'OK',
            exact: true
        }).click();
        await (0, e2e_namespaceObject.expect)(page.getByText('anchor pagegroup pagea other group page')).toBeVisible();
        await showSettings(page, 'group page');
        await page.getByRole('menuitem', {
            name: 'Move to'
        }).click();
        await page.mouse.move(300, 0);
        await page.getByLabel('block-item-TreeSelect-Target').locator('.ant-select').click();
        await page.locator('.ant-select-dropdown').getByText('anchor page').click();
        await page.getByLabel('Inner').click();
        await page.getByRole('button', {
            name: 'OK',
            exact: true
        }).click();
        await (0, e2e_namespaceObject.expect)(page.getByLabel('group page', {
            exact: true
        })).not.toBeVisible();
        await page.getByLabel('anchor page').click();
        await (0, e2e_namespaceObject.expect)(page.locator('.ant-layout-sider').getByLabel('group page')).toBeVisible();
        await showSettings(page, 'a other group page');
        await page.getByRole('menuitem', {
            name: 'Move to'
        }).click();
        await page.mouse.move(300, 0);
        await page.getByLabel('block-item-TreeSelect-Target').locator('.ant-select').click();
        await page.getByLabel('caret-down').locator('svg').click();
        await page.locator('.ant-select-dropdown').getByText('group page', {
            exact: true
        }).click();
        await page.getByLabel('Before').click();
        await page.getByRole('button', {
            name: 'OK',
            exact: true
        }).click();
        await (0, e2e_namespaceObject.expect)(page.locator('.ant-layout-sider').getByText('a other group pagegroup page')).toBeVisible();
    });
    (0, e2e_namespaceObject.test)('insert before', async (param)=>{
        let { page, mockPage, deletePage } = param;
        await mockPage({
            name: 'single page'
        }).goto();
        await showSettings(page, 'single page');
        await page.getByRole('menuitem', {
            name: 'Insert before'
        }).hover();
        await page.getByRole('menuitem', {
            name: 'Group',
            exact: true
        }).click();
        await page.getByLabel('block-item-Input-Menu item title').getByRole('textbox').click();
        await page.getByLabel('block-item-Input-Menu item title').getByRole('textbox').fill('group page');
        await page.getByRole('button', {
            name: 'OK',
            exact: true
        }).click();
        await (0, e2e_namespaceObject.expect)(page.locator('.ant-layout-header').getByText('group pagesingle page')).toBeVisible();
        await deletePage('group page');
    });
    (0, e2e_namespaceObject.test)('insert after', async (param)=>{
        let { page, mockPage, deletePage } = param;
        await mockPage({
            name: 'single page'
        }).goto();
        await showSettings(page, 'single page');
        await page.getByRole('menuitem', {
            name: 'Insert after'
        }).hover();
        await page.getByRole('menuitem', {
            name: 'Group',
            exact: true
        }).click();
        await page.getByLabel('block-item-Input-Menu item title').getByRole('textbox').click();
        await page.getByLabel('block-item-Input-Menu item title').getByRole('textbox').fill('group page');
        await page.getByRole('button', {
            name: 'OK',
            exact: true
        }).click();
        await (0, e2e_namespaceObject.expect)(page.locator('.ant-layout-header').getByText('single pagegroup page')).toBeVisible();
        await deletePage('group page');
    });
    (0, e2e_namespaceObject.test)('insert inner', async (param)=>{
        let { page, mockPage } = param;
        await mockPage({
            type: 'group',
            name: 'group page'
        }).goto();
        await showSettings(page, 'group page');
        await page.getByRole('menuitem', {
            name: 'Insert inner'
        }).hover();
        await page.getByRole('menuitem', {
            name: 'Page',
            exact: true
        }).click();
        await page.getByLabel('block-item-Input-Menu item title').getByRole('textbox').click();
        await page.getByLabel('block-item-Input-Menu item title').getByRole('textbox').fill('single page');
        await page.getByRole('button', {
            name: 'OK',
            exact: true
        }).click();
        await (0, e2e_namespaceObject.expect)(page.locator('.ant-layout-sider').getByText('single page')).toBeVisible();
    });
    (0, e2e_namespaceObject.test)('delete', async (param)=>{
        let { page, mockPage } = param;
        await mockPage({
            type: 'group',
            name: 'group page'
        }).goto();
        await (0, e2e_namespaceObject.expect)(page.getByLabel('group page')).toBeVisible();
        await showSettings(page, 'group page');
        await page.getByRole('menuitem', {
            name: 'Delete'
        }).click();
        await page.getByRole('button', {
            name: 'OK',
            exact: true
        }).click();
        await page.reload();
        await (0, e2e_namespaceObject.expect)(page.getByLabel('group page')).not.toBeVisible();
    });
});
e2e_namespaceObject.test.describe('group page side menus schema settings', ()=>{
    (0, e2e_namespaceObject.test)('group page', async (param)=>{
        let { page, mockPage } = param;
        await mockPage({
            type: 'group',
            name: 'group page'
        }).goto();
        await createSubPage({
            page,
            type: 'group',
            name: 'group page in side'
        });
        await (0, e2e_namespaceObject.expectSettingsMenu)({
            page,
            showMenu: ()=>showSettingsInSide(page, 'group page in side'),
            supportedOptions: [
                'Edit',
                'Move to',
                'Insert before',
                'Insert after',
                'Insert inner',
                'Delete'
            ]
        });
    });
    (0, e2e_namespaceObject.test)('link page', async (param)=>{
        let { page, mockPage } = param;
        await mockPage({
            type: 'group',
            name: 'group page'
        }).goto();
        await createSubPage({
            page,
            type: 'link',
            name: 'link page in side'
        });
        await (0, e2e_namespaceObject.expectSettingsMenu)({
            page,
            showMenu: ()=>showSettingsInSide(page, 'link page in side'),
            supportedOptions: [
                'Edit',
                'Move to',
                'Insert before',
                'Insert after',
                'Delete'
            ]
        });
    });
    (0, e2e_namespaceObject.test)('single page', async (param)=>{
        let { page, mockPage } = param;
        await mockPage({
            type: 'group',
            name: 'group page'
        }).goto();
        await createSubPage({
            page,
            type: 'page',
            name: 'single page in side'
        });
        await (0, e2e_namespaceObject.expectSettingsMenu)({
            page,
            showMenu: ()=>showSettingsInSide(page, 'single page in side'),
            supportedOptions: [
                'Edit',
                'Move to',
                'Insert before',
                'Insert after',
                'Delete'
            ]
        });
    });
});
e2e_namespaceObject.test.describe('link page menu schema settings', ()=>{
    (0, e2e_namespaceObject.test)('supported options', async (param)=>{
        let { page, mockPage } = param;
        await mockPage({
            type: 'link',
            name: 'link page'
        }).goto();
        await (0, e2e_namespaceObject.expectSettingsMenu)({
            page,
            showMenu: async ()=>{
                await page.locator('.ant-layout-header').getByText('link page', {
                    exact: true
                }).hover();
                await page.getByRole('button', {
                    name: 'designer-schema-settings-'
                }).hover();
            },
            supportedOptions: [
                'Edit',
                'Move to',
                'Insert before',
                'Insert after',
                'Delete'
            ]
        });
    });
});
e2e_namespaceObject.test.describe('single page menu schema settings', ()=>{
    (0, e2e_namespaceObject.test)('supported options', async (param)=>{
        let { page, mockPage } = param;
        await mockPage({
            name: 'single page'
        }).goto();
        await (0, e2e_namespaceObject.expectSettingsMenu)({
            page,
            showMenu: async ()=>{
                await page.locator('.ant-layout-header').getByText('single page', {
                    exact: true
                }).hover();
                await page.getByRole('button', {
                    name: 'designer-schema-settings-'
                }).hover();
            },
            supportedOptions: [
                'Edit',
                'Move to',
                'Insert before',
                'Insert after',
                'Delete'
            ]
        });
    });
});
async function showSettingsInSide(page, pageName) {
    await page.locator('.ant-layout-sider').getByText(pageName, {
        exact: true
    }).hover();
    await page.getByRole('button', {
        name: 'designer-schema-settings-'
    }).hover();
}
async function showSettings(page, pageName) {
    await page.locator('.ant-layout-header').getByText(pageName, {
        exact: true
    }).hover();
    await page.getByRole('button', {
        name: 'designer-schema-settings-'
    }).hover();
}
async function createSubPage(param) {
    let { page, name, type } = param;
    const typeToOptionName = {
        group: 'Group',
        page: 'Page',
        link: 'Link'
    };
    await page.getByTestId('schema-initializer-Menu-side').hover();
    await page.getByRole('menuitem', {
        name: typeToOptionName[type],
        exact: true
    }).click();
    await page.getByLabel('block-item-Input-Menu item title').getByRole('textbox').click();
    await page.getByLabel('block-item-Input-Menu item title').getByRole('textbox').fill(name);
    await page.getByRole('button', {
        name: 'OK',
        exact: true
    }).click();
}
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
});
