import * as __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__ from "@tachybase/test/e2e";
async function waitForModalToBeHidden(page) {
    await page.waitForFunction(()=>{
        const modal = document.querySelector('.ant-modal');
        if (modal) {
            const computedStyle = window.getComputedStyle(modal);
            return 'none' === computedStyle.display || 'hidden' === computedStyle.visibility;
        }
        return true;
    });
}
__WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test.describe.skip('add plugin in front', ()=>{
    __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test.slow();
    (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test)('add plugin from npm registry, then remove plugin', async (param)=>{
        let { page, mockPage } = param;
        await mockPage().goto();
        await page.getByTestId('plugin-manager-button').click();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('sample-custom-collection-template')).not.toBeVisible();
        await page.getByRole('button', {
            name: 'Add new'
        }).click();
        await page.getByLabel('block-item-Input-Npm package name').getByRole('textbox').fill('@tachybase/plugin-sample-custom-collection-template');
        await page.getByLabel('Submit').click();
        await page.waitForFunction(()=>{
            const modal = document.querySelector('.ant-modal');
            if (modal) {
                const computedStyle = window.getComputedStyle(modal);
                return 'none' === computedStyle.display || 'hidden' === computedStyle.visibility;
            }
            return true;
        });
        await page.waitForLoadState('load');
        await page.getByPlaceholder('Search plugin').fill('sample-custom-collection-template');
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('sample-custom-collection-template')).toBeVisible();
        await page.getByLabel('sample-custom-collection-template').getByText('Remove').click();
        await page.getByRole('button', {
            name: 'Yes'
        }).click();
        await page.waitForTimeout(300);
        await waitForModalToBeHidden(page);
        await page.waitForLoadState('load');
        await page.getByPlaceholder('Search plugin').fill('sample-custom-collection-template');
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('sample-custom-collection-template')).not.toBeVisible();
    });
    __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test.skip('add plugin from local upload', async (param)=>{
        let { page, mockPage } = param;
    });
    __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test.skip('add plugin from file URL', async (param)=>{
        let { page, mockPage } = param;
    });
});
__WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test.describe.skip('remove plugin', ()=>{
    __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test.slow();
    (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test)('remove plugin, then add plugin', async (param)=>{
        let { page, mockPage } = param;
        await mockPage().goto();
        await page.getByTestId('plugin-manager-button').click();
        await page.getByPlaceholder('Search plugin').fill('Hello');
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('Hello')).toBeVisible();
        const isActive = await page.getByLabel('Hello').getByLabel('enable').isChecked();
        (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(isActive).toBe(false);
        await page.getByLabel('Hello').getByText('Remove').click();
        await page.getByRole('button', {
            name: 'Yes'
        }).click();
        await waitForModalToBeHidden(page);
        await page.waitForLoadState('load');
        await page.getByPlaceholder('Search plugin').fill('hello');
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('Hello')).not.toBeVisible();
        await page.getByRole('button', {
            name: 'Add new'
        }).click();
        await page.getByLabel('block-item-Input-Npm package name').getByRole('textbox').fill('@tachybase/plugin-sample-hello');
        await page.getByLabel('Submit').click();
        await page.waitForFunction(()=>{
            const modal = document.querySelector('.ant-modal');
            if (modal) {
                const computedStyle = window.getComputedStyle(modal);
                return 'none' === computedStyle.display || 'hidden' === computedStyle.visibility;
            }
            return true;
        });
        await page.waitForLoadState('load');
        await page.getByPlaceholder('Search plugin').fill('hello');
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('Hello')).toBeVisible();
        await page.getByPlaceholder('Search plugin').fill('ACL');
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('ACL')).toBeVisible();
        const isAclActive = await page.getByLabel('ACL').getByLabel('enable').isChecked();
        (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(isAclActive).toBe(true);
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('ACL').getByText('Remove')).not.toBeVisible();
    });
});
__WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test.describe.skip('enable & disable plugin', ()=>{
    __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test.slow();
    (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.test)('enable plugin', async (param)=>{
        let { page, mockPage } = param;
        await mockPage().goto();
        await page.getByTestId('plugin-manager-button').click();
        await page.getByPlaceholder('Search plugin').fill('hello');
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('Hello')).toBeVisible();
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('Hello').getByLabel('enable')).not.toBeChecked();
        await page.getByLabel('Hello').getByLabel('enable').click();
        await page.waitForTimeout(1000);
        await waitForModalToBeHidden(page);
        await page.waitForLoadState('load');
        await page.getByPlaceholder('Search plugin').fill('hello');
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('Hello').getByLabel('enable')).toBeChecked();
        await page.getByLabel('Hello').getByLabel('enable').click();
        await waitForModalToBeHidden(page);
        await page.waitForLoadState('load');
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_e2e__.expect)(page.getByLabel('Hello').getByLabel('enable')).not.toBeChecked();
    });
});
