package com.adven.concordion.extensions.exam.ui;

import com.adven.concordion.extensions.exam.html.Html;
import com.codeborne.selenide.ex.UIAssertionError;
import org.concordion.api.listener.*;

import static com.adven.concordion.extensions.exam.html.Html.imageOverlay;
import static com.codeborne.selenide.Selenide.screenshot;

public class UiResultRenderer implements AssertEqualsListener, AssertTrueListener, AssertFalseListener {

    public void failureReported(AssertFailureEvent event) {
        Html s = new Html(event.getElement());
        Html el = s.parent();
        UIAssertionError error = (UIAssertionError) event.getActual();
        el.remove(s);
        el.childs(
                imageOverlay(error.getScreenshot(), 360, event.getExpected(), error.getMessage(), "rest-failure")
        );
    }

    public void successReported(AssertSuccessEvent event) {
        Html s = new Html(event.getElement());
        Html el = s.parent();
        String name = s.attr("name");
        el.remove(s);
        el.childs(
                imageOverlay(screenshot(name), 360, name, "Step desc", "rest-success")
        );
    }
}
@@ -188,16 +188,38 @@
 ner.*;%0A%0A
+import java.io.File;%0A%0A
 import s
@@ -285,16 +285,16 @@
 verlay;%0A
-
 import s
@@ -728,16 +728,24 @@
 Overlay(
+getPath(
 error.ge
@@ -757,16 +757,17 @@
 enshot()
+)
 , 360, e
@@ -1085,16 +1085,24 @@
 Overlay(
+getPath(
 screensh
@@ -1109,16 +1109,17 @@
 ot(name)
+)
 , 360, n
@@ -1168,10 +1168,112 @@
 );%0A    %7D
+%0A%0A    private String getPath(String screenshot) %7B%0A        return new File(screenshot).getName();%0A    %7D
 %0A%7D

fix screenshot path