<head>
  <title>Tests</title>
</head>

<body>
  <div class="container-fluid">
  {{> test_table}}
  </div>
</body>

<template name="test_table">
  <div class="navbar navbar-fixed-top navbar-inverse">
    <div class="navbar-inner">
      <div class="row-fluid">
        <div class="span3"><a class="brand" href="#">
          &nbsp;
          {{#if running}}
            Testing in progress...
          {{else}}
            {{#if passed}}
              All tests pass!
            {{else}}
              There are failures.
            {{/if}}
          {{/if}}
        </a></div>
        <div class="span2">
          {{#unless running}}
            <p class="navbar-text">{{total_test_time}} ms</p>
          {{/unless}}
        </div>
        <div class="span6">
          {{> progressBar}}
        </div>
        <div class="span1"></div>
      </div>
    </div>
  </div>
  {{> groupNav}}
  <div class="row-fluid"><div class="span12">
  <ul class="failedTests">
    {{#each failedTests}}
      <li>{{this}}</li>
    {{/each}}
  </ul>

  <div class="test_table">
    {{#each data}}
      {{> test_group this}}
    {{/each}}
  </div>
  </div></div>
</template>

<template name="progressBar">
  <div id="testProgressBar" class="progress {{#if running}}progress-striped{{/if}}">
    <div class="bar bar-danger" style="width: {{percentFail}}%;"></div>
    <div class="bar {{#if anyFail}}bar-warning{{else}}bar-success{{/if}}" style="width: {{percentPass}}%;"></div>
  </div>
</template>

<template name="groupNav">
  <div class="navbar navbar-fixed-bottom navbar-inverse">
    <div class="navbar-inner">
      <ul class="nav">
      {{#each groupPaths}}
        <li class="navbar-text">&nbsp;-&nbsp;</li>
        <li><a class="group" href="#">{{name}}</a></li>
      {{/each}}
      </ul>
      <form class="navbar-form pull-right">
        <a class="btn rerun">
          {{#if rerunScheduled}}
          <i class="icon-time"></i>
          Rerun scheduled...
          {{else}}
          <i class="icon-repeat"></i>
          Rerun
          {{/if}}
        </a>
      </form>
      &nbsp;
    </div>
  </div>
</template>

<template name="test_group">
  <div class="group">
    <div class="groupname"><a>{{name}}</a></div>
    {{#each tests}}
      {{> test}}
    {{/each}}
    {{#each groups}}
      {{> test_group}}
    {{/each}}
  </div>
</template>

<template name="test">
  <div class="test {{test_class}}">
    <div class="testrow">
      <div class="testname">
        {{#if server}}S:{{else}}C:{{/if}}
        {{name}}
      </div>
      <div class="teststatus">
        {{test_status_display}}
      </div>
      <div class="testtime">
        {{test_time_display}}
      </div>
    </div>
    {{#if expanded}}
      {{#each eventsArray}}
        {{> event}}
      {{else}}
        <div class="event"><div class="nodata">(no data)</div></div>
      {{/each}}
    {{/if}}
  </div>
</template>

<template name="event">
  <div class="event">
    <div class="{{type}}">
      <span>
      - {{type}}
      {{#if times}}
        <span class="xtimes">({{times}} times)</span>
      {{/if}}
      {{#with get_details}}
        {{#if this}}
          {{!
            `type` can be any of the following or a
            custom assertion type

            * assert_equal
            * instanceOf
            * throws
            * true
            * null
            * undefined
            * NaN
            * include
            * length
          }}
          {{#if type}}&mdash; {{type}}{{/if}}
          {{#each details}}
            - <span class="failkey">{{key}}</span> {{val}}
          {{/each}}
        {{/if}}
        {{#if stack}}<pre>{{stack}}</pre>{{/if}}
      {{/with}}
      {{#if is_debuggable}}
        <span class="debug">[Debug]</span>
      {{/if}}
      </span>
    </div>
  </div>
</template>
