// Path: src/main/java/com/frameworkium/core/common/reporting/allure/AllureLogger.java
// public class AllureLogger {
// 
//   private static final Logger logger = LogManager.getLogger();
//   private static final ThreadLocal<Deque<String>> STEP_UUID_STACK =
//       ThreadLocal.withInitial(ArrayDeque::new);
// 
//   private AllureLogger() {
//     // hide default constructor for this util class
//   }
// 
//   /**
//    * Uses the @Step annotation to log the given log message to Allure.
//    *
//    * @param message the message to log to the allure report
//    */
//   @Step("{message}")
//   public static void logToAllure(String message) {
//     logger.debug("Logged to allure: " + message);
//   }
// 
//   public static void stepStart(String stepName) {
//     StepResult result = new StepResult().setName(stepName);
//     String uuid = UUID.randomUUID().toString();
//     getLifecycle().startStep(uuid, result);
//     STEP_UUID_STACK.get().addFirst(uuid);
//   }
// 
//   public static void stepFinish() {
//     getLifecycle().stopStep(STEP_UUID_STACK.get().removeFirst());
//   }
// }


import com.frameworkium.core.common.reporting.allure.AllureLogger;
import com.frameworkium.core.ui.annotations.Visible;
import com.frameworkium.core.ui.pages.BasePage;
import io.qameta.allure.Step;
import io.restassured.RestAssured;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import java.util.List;
import java.util.stream.Collectors;
            "dispatchEvent(a,n,s)},createEvent:function(t){var a=document." +
            "createEvent(\"CustomEvent\");return a.initCustomEvent(t,!0,!0,null)," +
            "a.dataTransfer={data:{},setData:function(t,a){this.data[t]=a}," +
            "getData:function(t){return this.data[t]}},a},dispatchEvent:" +
            "function(t,a,e){t.dispatchEvent?t.dispatchEvent(e):t.fireEvent&&t.fireEvent(\"on\"+a,e)}})}(jQuery);";

    /**
     * Fetches Javascript from the Internet used to be able to simulate Drag and Drop.
     *
     * @return a String containing the Javascript for JQuery (if not already present on the page)
     *         and code for simulating drag and drop.
     */
    private String scriptToSimulateDragDrop() {
        if (jQueryJS.isEmpty()) {
            Boolean isJQueryAvailable = (Boolean) executeJS("return !!window.jQuery;");
            if (!isJQueryAvailable) {
                jQueryJS = RestAssured.get(JQUERY_JS_URI).asString();
            }
        }

        return jQueryJS + dragDropHelperJS;
    }

    /**
     * @param from the jQuery selector for the element to initially click and then drag
     * @param to   the jQuery selector for the target element where the from element will be dropped
     */
    private void simulateDragAndDrop(String from, String to) {
        executeJS(scriptToSimulateDragDrop());
        // TODO: move AllureLogger steps to dedicated test
// Path: src/main/java/com/frameworkium/core/common/reporting/allure/AllureLogger.java
// public class AllureLogger {
// 
//   private static final Logger logger = LogManager.getLogger();
//   private static final ThreadLocal<Deque<String>> STEP_UUID_STACK =
//       ThreadLocal.withInitial(ArrayDeque::new);
// 
//   private AllureLogger() {
//     // hide default constructor for this util class
//   }
// 
//   /**
//    * Uses the @Step annotation to log the given log message to Allure.
//    *
//    * @param message the message to log to the allure report
//    */
//   @Step("{message}")
//   public static void logToAllure(String message) {
//     logger.debug("Logged to allure: " + message);
//   }
// 
//   public static void stepStart(String stepName) {
//     StepResult result = new StepResult().setName(stepName);
//     String uuid = UUID.randomUUID().toString();
//     getLifecycle().startStep(uuid, result);
//     STEP_UUID_STACK.get().addFirst(uuid);
//   }
// 
//   public static void stepFinish() {
//     getLifecycle().stopStep(STEP_UUID_STACK.get().removeFirst());
//   }
// }


// Path: src/test/java/com/frameworkium/integration/theinternet/pages/DragAndDropPage.java
import com.frameworkium.core.common.reporting.allure.AllureLogger;
import com.frameworkium.core.ui.annotations.Visible;
import com.frameworkium.core.ui.pages.BasePage;
import io.qameta.allure.Step;
import io.restassured.RestAssured;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import java.util.List;
import java.util.stream.Collectors;

            "dispatchEvent(a,n,s)},createEvent:function(t){var a=document." +
            "createEvent(\"CustomEvent\");return a.initCustomEvent(t,!0,!0,null)," +
            "a.dataTransfer={data:{},setData:function(t,a){this.data[t]=a}," +
            "getData:function(t){return this.data[t]}},a},dispatchEvent:" +
            "function(t,a,e){t.dispatchEvent?t.dispatchEvent(e):t.fireEvent&&t.fireEvent(\"on\"+a,e)}})}(jQuery);";

    /**
     * Fetches Javascript from the Internet used to be able to simulate Drag and Drop.
     *
     * @return a String containing the Javascript for JQuery (if not already present on the page)
     *         and code for simulating drag and drop.
     */
    private String scriptToSimulateDragDrop() {
        if (jQueryJS.isEmpty()) {
            Boolean isJQueryAvailable = (Boolean) executeJS("return !!window.jQuery;");
            if (!isJQueryAvailable) {
                jQueryJS = RestAssured.get(JQUERY_JS_URI).asString();
            }
        }

        return jQueryJS + dragDropHelperJS;
    }

    /**
     * @param from the jQuery selector for the element to initially click and then drag
     * @param to   the jQuery selector for the target element where the from element will be dropped
     */
    private void simulateDragAndDrop(String from, String to) {
        executeJS(scriptToSimulateDragDrop());
        // TODO: move AllureLogger steps to dedicated test
        AllureLogger.stepStart("testing step start");