// Version: 1.0.0
import {jestState} from '../form.spec';
import {__runLogin} from './login.test';
import {test} from '@jest/globals';
/**
 * Run top info tests.
 * @return {Promise<void>}
 * @private
 */
async function __topInfoElementsExist() {
    await jestState.page.goto(
        jestState.envData.root + '/wp-admin/options-general.php?page=spbc&spbc_tab=settings_general',
        {waitUntil: 'load'},
    );
    const topInfoElementsClasses = [
        '.spbc_page_header_info_left_column',
        '.spbc_page_header_info_right_column',
        '.spbc_page_header_info__state_block',
        '.spbc_page_header_info__block_label',
        '.spbc_page_header_info__block_body',
        '.spbc_page_header_info__block_row',
        '#spbc_page_header_about_block',
        //'.spbc_page_header_info__error_block', //Situational check, you need to have an error block in the header

    ];
    for (let i = 0; i < topInfoElementsClasses.length; i++) {
        await jestState.page.$eval(topInfoElementsClasses[i], (el) => el.innerText);
    }
}

/**
 * Run navigation bar tests.
 * This test is a wrapper for group of tests.
 * @param {boolean} doLogin
 * @return {void}
 */
export function groupTopInfo(doLogin = true) {
    if (doLogin) {
        test('LOGIN', async () => {
            await __runLogin();
        }, jestState.globals.globalTimeout);
    }
    test('TOP INFO ELEMENTS EXISTS', async () => {
        await __topInfoElementsExist();
    }, jestState.globals.globalTimeout);
    // more test there
}


