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

<body>
  {{> test_table}}
</body>

<template name="test_table">
  {{#if running}}
  <div class="header in-progress">Testing in progress ...</div>
  {{else}}
    {{#if passed}}
      <div class="header pass">All tests pass!
        <span class="time">{{total_test_time}} ms</span>
      </div>
    {{else}}
      <div class="header fail">There are failures.
        <span class="time">{{total_test_time}} ms</span>
      </div>
    {{/if}}
  {{/if}}

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

<template name="test_group">
  <div class="group">
    <div class="groupname">{{name}}</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}}
          &mdash; {{this}}
        {{/if}}
      {{/with}}
      {{#if is_debuggable}}
        <span class="debug">[Debug]</span>
      {{/if}}
      </span>
    </div>
  </div>
</template>
