// Version: 1.0.0
import {jestState} from '../form.spec';
import {__runLogin} from './login.test';
import {test} from '@jest/globals';
/**
 * Run Critical Updates elements exist tests.
 * @return {Promise<void>}
 * @private
 */
async function __criticalUpdatesElementsExist() {
    await jestState.page.goto(
        jestState.envData.root + '/wp-admin/options-general.php?page=spbc&spbc_tab=critical_updates',
        {waitUntil: 'load'},
    );
    await jestState.page.waitForSelector('[id=spbc_tab-critical_updates]');
    const criticalUpdatesElementsClasses = [
        '.spbc_tab-critical_updates',
        '.spbc_critical_updates-legend',
    ];
    for (let i = 0; i < criticalUpdatesElementsClasses.length; i++) {
        await jestState.page.$eval(criticalUpdatesElementsClasses[i], (el) => el.innerText);
    }
}

/**
 * Run Critical Updates tests.
 * This test is a wrapper for group of tests.
 * @param {boolean} doLogin
 * @return {void}
 */
export function groupCriticalUpdatesInfo(doLogin = true) {
    if (doLogin) {
        test('LOGIN', async () => {
            await __runLogin();
        }, jestState.globals.globalTimeout);
    }
    test('CRITICAL UPDATES ELEMENTS EXISTS', async () => {
        await __criticalUpdatesElementsExist();
    }, jestState.globals.globalTimeout);
    // more test there
}
