import {browser, $, $$, expect} from '@wdio/globals'

/**
 * @param  action - only accepts 'accept' or 'dismiss'
 * @param  accept -> to accept the alert
 * @param  dismiss -> to dismiss the alert
 */

export default async function (action: string) {
    if (action.toLowerCase().trim() !== 'accept')
        throw new Error(`Invalid selection for "handleModal" function. Valid selection is "accept"`);
    let command = `${action}Alert`;
    // Alert can not be dismissed
    await browser[command]();
}
