<!DOCTYPE html>
<html>
    <head>
        <title>{{project}} Storyboard</title>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
        <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>
        <style>
            img {
            vertical-align: text-top;
            width: 200px;
            border: 2px solid #ddd
            }
            h2 {
            page-break-before: always;
            }
            .nav-link {
            padding: 0
            }
        </style>
    </head>
    <body style="margin: 20px;">
        <h1 class="h4">Results for {{project}} Scenarios</h1>
        <nav class="nav flex-column">
            {% for header in headers %}
                <a class="nav-link" href="#{{header.link}}">
                    Test #{{loop.index}} - {{header.description}}
                    {% if header.is_failed %}
                        <span class="text-danger">FAILED</span>
                    {% endif %}
                </a>
            {% endfor %}
        </nav>

        <p>Generated {{ date }}</p>

        {% for result in results %}
            {% set index = loop.index %}
            <h2 class="h5">
                <a name="{{result.link}}">Test #{{index}}</a>: 
                {{ result.doc or result.nodeid }}
            </h2>
            {% if result.doc %}
                <h3 class="h6">{{result.nodeid}}</h3>
            {% endif %}
            {% if result.failure %}
            <div class="alert alert-danger">
                <p><strong>The following action failed:</strong> {{ result.failure.message }}</p>
                {% if result.failure.url %}
                    <p><strong>Current url:</strong> {{result.failure.url}}</p>
                    <p><strong>Browser logs:</strong>
                    {% for logline in result.failure.loglines %}
                        {{logline}}<br>
                    {% endfor %}
                    </p>
                {% endif %}
            </div>
            {% endif %}
            {% for sequence, png in zip(lettergen(), result.pngs) %}
                <figure class="figure">
                    <figcaption class="figure-caption text-right">#{{index}}{{sequence}}</figcaption>
                    <img src="data:image/png;base64,{{png}}" class="figure-img img-fluid">
                </figure>
            {% endfor %}
        {% endfor %}
    </body>
</html>