// > Something to load files with a specified format declareJS, HTML...
// > Mapper to convert HTML into JSON
// > Mapper to convert JSON to test instructions based on syntax of Qunit
// > Something to load multiple files with promises
// > A sequence loader which handles promises without pausing
// > The possibility to make snapshots and store them somewhere
// > The possibility to generate a documentation with the texts of test
//   modules and asyncTests, so every test module will have a corresponding
//   bullet on a slide with a screenshot...
// > convert the whole thing to a HTML presentation = view presentation
// > view = PDF
// > an easy to enter HTML generator in the proto UI, which allows to build
//   test tables same as in ERP5 currently.
// > the whole thing probably needs to be stored in JIO... so we can stor
//   in local and in ERP5 storage
// > view ... XML?
// > view ... default = QUNIT runner
// > Also we need to parse HTML old and new, old having <section> and <test>
// > new I would prefer just having tests. For old, how do we get screenshots?






(function( $ ) {

  $.testToolBox = {
    
  };

})(jQuery);





(function (document, window, RSVP, undefined) {
  "use strict";

  // thx - jQuery parseHTML - http://api.jquery.com/jquery.parsehtml/
  var rhtml = /<|&#?\w+;/;
  var rtagName = /<([\w:]+)/;
  var rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi;
  var wrapMap = {
    "option": [ 1, "<select multiple='multiple'>", "</select>" ],
    "thead": [ 1, "<table>", "</table>" ],
    "col": [ 2, "<table><colgroup>", "</colgroup></table>" ],
    "tr": [ 2, "<table><tbody>", "</tbody></table>" ],
    "td": [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
    "_default": [ 0, "", "" ]
  };
  // Support: IE 9
  wrapMap.optgroup = wrapMap.option;
  wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  wrapMap.th = wrapMap.td;

  function buildFragment = function (elems) {
    var fragment, node_list, i, j, l, elem, tag, tmp, wrap, merge, testContain;

    fragment = document.createDocumentFragment();
    node_list = [];
    l = elems.length;

    merge = function( first, second ) {
      var len, j, i;

      len = +second.length,
        i = first.length;

      for (j = 0; j < len; j += 1 ) {
        first[ i += 1 ] = second[ j ];
      }
      first.length = i;
      return first;
    };



    for (i = 0; i < l; i += 0 {
      elem = elems[i];

      if (elem && rhtml.test(elem)) {
        tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();

        switch (tag) {
          case "section":
          case "test":
            // Deserialize a standard representation
            tmp = tmp || fragment.appendChild( document.createElement("div") );
            wrap = wrapMap[ tag ] || wrapMap._default;
            tmp.innerHTML = wrap[ 1 ] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[ 2 ];
        };
      }
    }

    // Descend through wrappers to the right content
    j = wrap[ 0 ];
    while ( j-- ) {
      tmp = tmp.lastChild;
    }

    // Support: QtWebKit
    // merge because push.apply(_, arraylike) throws
    merge(node_list, tmp.childNodes);

    // Remember the top-level container
    tmp = fragment.firstChild;

    // Support: Webkit, IE
    tmp.textContent = "";

    // Remove wrapper from fragment
    fragment.textContent = "";

    i = 0;

    while ((elem = nodes[ i += 1 ])) {
      contains = jQuery.contains( elem.ownerDocument, elem );

      // Append to fragment
      tmp = getAll( fragment.appendChild( elem ), "script" );
    }

    return fragment;

  };

  // thx - jQuery parseHTML - http://api.jquery.com/jquery.parsehtml/
  function parseHTML = function(data) {
    var element_list = [], parsed, rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/);

    if (!data || typeof data !== "string") {
      return null;
    }

    // Single tag
    parsed = rsingleTag.exec( data );
    if ( parsed ) {
      return [ context.createElement( parsed[1] ) ];
    }

    
    parsed = jQuery.buildFragment( [ data ], context, scripts );



    return jQuery.merge( [], parsed.childNodes );
  };

  function cleanString = function (str) {
    
  };

}(document, window, RSVP, Channel));









    <table cellspacing="1" cellpadding="1" border="1" name="SELENIUM-TEST">
      <thead>
        <tr class="title">
          <td colspan="3">SlapOS UI Basic Interaction</td>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>store</td>
          <td><urltool portal_url="" at=""></urltool></td>
          <td>base_url</td>
        </tr>
        <tr>
          <td>store</td>
          <!-- ERP5TypeTestCase is the default for any UnitTest -->
          <td></td>
          <td>base_user</td>
         </tr>
        <tr>
          <td>store</td>
          <td></td>
          <td>base_password</td>
         </tr>
        <tr>
          <td>openAndWait</td>
          <td>${base_url}</td>
          <td></td>
        </tr>
        <tr>
          <td>waitForPageToLoad</td>
          <td><br></td>
          <td></td>
        </tr>
        <tr>
          <td>waitForElementPresent</td>
          <td>//div[@id="global-panel"]</td>
          <td></td>
        </tr>
        <tr>
          <td>click</td>
          <td>//a[.='Menu']</td>
          <td></td>
        </tr>
        <tr>
          <td>click</td>
          <td>//h1[.='Networks']</td>
          <td></td>
        </tr>
        <tr>
          <td>waitForElementPresent</td>
          <td>//a[.='Add network']</td>
          <td></td>
        </tr>
        <tr>
          <td>click</td>
          <td>//a[.='Add network']</td>
          <td></td>
        </tr>
        <tr>
          <td>waitForElementPresent</td>
          <td>//input[@id="network_new_title"]</td>
          <td></td>
        </tr>
        <tr>
          <td>type</td>
          <td>id=network_new_title</td>
          <td>Bazbam</td>
        </tr>
        <tr>
          <td>pause</td>
          <td>5000</td>
          <td></td>
        </tr>
        <tr>
          <td>click</td>
          <td>//input[@type="submit"]</td>
          <td></td>
        </tr>
        <tr>
          <td>pause</td>
          <td>10000</td>
          <td></td>
        </tr>
        <tr>
          <td>click</td>
          <td>//a[@href="#networks"]</td>
          <td></td>
        </tr>
        <tr>
          <td>pause</td>
          <td>5000</td>
          <td></td>
        </tr>
        <tr>
          <td>click</td>
          <td>//a[.="Bazbam"]</td>
          <td></td>
        </tr>
        <tr>
          <td>pause</td>
          <td>5000</td>
          <td></td>
        </tr>
        <tr>
          <td>click</td>
          <td>//a[.="Delete"]</td>
          <td></td>
        </tr>
        <tr>
          <td>pause</td>
          <td>5000</td>
          <td></td>
        </tr>
        <tr>
          <td>verifyText</td>
          <td>//div[@class="info"]</td>
          <td>1-3/3 Records</td>
        </tr>
      <tr>
          <td>openAndWait</td>
          <td>${base_url}</td>
          <td></td>
        </tr>
        <tr>
          <td>waitForPageToLoad</td>
          <td><br></td>
          <td></td>
        </tr>
        <tr>
          <td>waitForElementPresent</td>
          <td>//div[@id="global-panel"]</td>
          <td></td>
        </tr>
        <tr>
          <td>click</td>
          <td>//a[.='Menu']</td>
          <td></td>
        </tr>
        <tr>
          <td>click</td>
          <td>//h1[.='Person']</td>
          <td></td>
        </tr>
        <tr>
          <td>waitForElementPresent</td>
          <td>//input[@id="user_sample_password"]</td>
          <td></td>
        </tr>
        <tr>
          <td>type</td>
          <td>id=user_sample_password</td>
          <td>topsecret</td>
        </tr>
        <tr>
          <td>type</td>
          <td>id=user_sample_default_fax_text</td>
          <td>Foo</td>
        </tr>
        <tr>
          <td>pause</td>
          <td>5000</td>
          <td></td>
        </tr>
        <tr>
          <td>click</td>
          <td>//input[@type="submit"]</td>
          <td></td>
        </tr>
        <tr>
          <td>pause</td>
          <td>5000</td>
          <td></td>
        </tr>
        <tr>
          <td>click</td>
          <td>//a[.='Home']</td>
          <td></td>
        </tr>
        <tr>
          <td>pause</td>
          <td>2000</td>
          <td></td>
        </tr>
        <tr>
          <td>click</td>
          <td>//a[.='Menu']</td>
          <td></td>
        </tr>
        <tr>
          <td>click</td>
          <td>//h1[.='Person']</td>
          <td></td>
        </tr>
        <tr>
          <td>waitForElementPresent</td>
          <td>//input[@id="user_sample_password"]</td>
          <td></td>
        </tr>
        <tr>
          <td>verifyAttribute</td>
          <td>//input[@id="user_sample_default_fax_text"]@value</td>
          <td>Foo</td>
        </tr>
      <tr>
          <td>openAndWait</td>
          <td>${base_url}</td>
          <td></td>
        </tr>
        <tr>
          <td>waitForPageToLoad</td>
          <td><br></td>
          <td></td>
        </tr>
        <tr>
          <td>waitForElementPresent</td>
          <td>//div[@id="global-panel"]</td>
          <td></td>
        </tr>
        <tr>
          <td>click</td>
          <td>//a[.='Menu']</td>
          <td></td>
        </tr>
        <tr>
          <td>click</td>
          <td>//h1[.='Invoices']</td>
          <td></td>
        </tr>
        <tr>
          <td>waitForElementPresent</td>
          <td>//a[.="Download"]</td>
          <td></td>
        </tr>
      <tr>
          <td>openAndWait</td>
          <td>${base_url}</td>
          <td></td>
        </tr>
        <tr>
          <td>waitForPageToLoad</td>
          <td><br></td>
          <td></td>
        </tr>
        <tr>
          <td>waitForElementPresent</td>
          <td>//div[@id="global-panel"]</td>
          <td></td>
        </tr>
        <tr>
          <td>click</td>
          <td>//a[.='Menu']</td>
          <td></td>
        </tr>
        <tr>
          <td>click</td>
          <td>//h1[.='Services']</td>
          <td></td>
        </tr>
        <tr>
          <td>waitForElementPresent</td>
          <td>//a[.="Zabbix Agent"]</td>
          <td></td>
        </tr>
        <tr>
          <td>click</td>
          <td>//a[.="Zabbix Agent"]</td>
          <td></td>
        </tr>
        <tr>
          <td>waitForElementPresent</td>
          <td>//textarea[@id="service_instance_overview_xml_recipe"]</td>
          <td></td>
        </tr>
        <tr>
          <td>type</td>
          <td>id=service_instance_overview_xml_recipe</td>
          <td>Bar</td>
        </tr>
          <tr>
          <td>pause</td>
          <td>5000</td>
          <td></td>
        </tr>
        <tr>
          <td>click</td>
          <td>//input[@type="submit"]</td>
          <td></td>
        </tr>
        <tr>
          <td>pause</td>
          <td>5000</td>
          <td></td>
        </tr>
        <tr>
          <td>click</td>
          <td>//a[.="Destroy"]</td>
          <td></td>
        </tr>
        <tr>
          <td>waitForElementPresent</td>
          <td>//a[.="Install new service"]</td>
          <td></td>
        </tr>
        <tr>
          <td>verifyText</td>
          <td>//div[@class="info"]</td>
          <td>1-3/3 Records</td>
        </tr>
      <tr>
          <td>openAndWait</td>
          <td>${base_url}</td>
          <td></td>
        </tr>
        <tr>
          <td>waitForPageToLoad</td>
          <td><br></td>
          <td></td>
        </tr>
        <tr>
          <td>waitForElementPresent</td>
          <td>//div[@id="global-panel"]</td>
          <td></td>
        </tr>
        <tr>
          <td>click</td>
          <td>//a[.='Menu']</td>
          <td></td>
        </tr>
        <tr>
          <td>click</td>
          <td>//h1[.='Services']</td>
          <td></td>
        </tr>
        <tr>
          <td>pause</td>
          <td>5000</td>
          <td></td>
        </tr>
        <tr>
          <td>click</td>
          <td>//a[.="Install new service"]</td>
          <td></td>
        </tr>
        <tr>
          <td>pause</td>
          <td>5000</td>
          <td></td>
        </tr>
        <tr>
          <td>type</td>
          <td>id=search_software_list</td>
          <td>Zabbix</td>
        </tr>
        <tr>
          <td>pause</td>
          <td>5000</td>
          <td></td>
        </tr>
        <tr>
          <td>click</td>
          <td>link=[EXPERIMENTAL] Zabbix Agent</td>
          <td></td></tr>
        <tr>
          <td>pause</td>
          <td>5000</td>
          <td></td>
        </tr>
        <tr>
          <td>click</td>
          <td>link=slapos-0.5</td>
          <td></td>
        </tr>
        <tr>
          <td>pause</td>
          <td>5000</td>
          <td></td>
        </tr>
        <tr>
          <td>select</td>
          <td>id=install_release_reference_computer</td>
          <td>label=Cortana</td>
        </tr>
        <tr>
          <td>pause</td>
          <td>5000</td>
          <td></td>
        </tr>
        <tr>
          <td>click</td>
          <td>//input[@value='Request']</td>
          <td></td>
        </tr>
        <tr>
          <td>pause</td>
          <td>5000</td>
          <td></td>
        </tr>
        <tr>
          <td>click</td>
          <td>//a[.="Menu"]</td>
          <td></td>
        </tr>
        <tr>
          <td>click</td>
          <td>//h1[.='Services']</td>
          <td></td>
        </tr>
        <tr>
          <td>pause</td>
          <td>5000</td>
          <td></td>
        </tr>
        <tr>
          <td>verifyText</td>
          <td>//div[@class="info"]</td>
          <td>1-5/5 Records</td>
        </tr>
      <tr>
          <td>openAndWait</td>
          <td>${base_url}</td>
          <td></td>
        </tr>
        <tr>
          <td>waitForPageToLoad</td>
          <td><br></td>
          <td></td>
        </tr>
        <tr>
          <td>waitForElementPresent</td>
          <td>//div[@id="global-panel"]</td>
          <td></td>
        </tr>
        <tr>
          <td>click</td>
          <td>//a[.='Menu']</td>
          <td></td>
        </tr>
        <tr>
          <td>click</td>
          <td>//h1[.='Servers']</td>
          <td></td>
        </tr>
        <tr>
          <td>pause</td>
          <td>10000</td>
          <td></td>
        </tr>
        <tr>
          <td>type</td>
          <td>id=search_server_list</td>
          <td>Cortana</td>
        </tr>
        <tr>
          <td>pause</td>
          <td>2000</td>
          <td></td>
        </tr>
        <tr>
          <td>click</td>
          <td>link=Cortana</td>
          <td></td>
        </tr>
        <tr>
          <td>waitForElementPresent</td>
          <td>//a[.="Set Configuration"]</td>
          <td></td>
        </tr>
        <tr>
          <td>click</td>
          <td>//a[.="Set Configuration"]</td>
          <td></td>
        </tr>
        <tr>
          <td>pause</td>
          <td>2000</td>
          <td></td>
        </tr>
        <tr>
          <td>type</td>
          <td>id=computer_sample_reference</td>
          <td>Foo-123</td>
        </tr>
        <tr>
          <td>type</td>
          <td>id=computer_sample_translated_validation_state_title</td>
          <td>Dead</td>
        </tr>
        <tr>
          <td>pause</td>
          <td>5000</td>
          <td></td>
        </tr>
        <tr>
          <td>click</td>
          <td>//input[@type="submit"]</td>
          <td></td>
        </tr>
        <tr>
          <td>pause</td>
          <td>5000</td>
          <td></td>
        </tr>
        <tr>
          <td>goBack</td>
          <td></td>
          <td></td>
        </tr>
        <tr>
          <td>pause</td>
          <td>5000</td>
          <td></td>
        </tr>
        <tr>
          <td>verifyAttribute</td>
          <td>//input[@id="computer_status_reference"]@value</td>
          <td>Foo-123</td>
        </tr>
        <tr>
          <td>click</td>
          <td>link=servers</td>
          <td></td>
        </tr>
        <tr>
          <td>pause</td>
          <td>5000</td>
          <td></td>
        </tr>
        <tr>
          <td>type</td>
          <td>id=search_server_list</td>
          <td>Cortana</td>
        </tr>
        <tr>
          <td>pause</td>
          <td>2000</td>
          <td></td>
        </tr>
        <tr>
          <td>click</td>
          <td>link=Dead</td>
          <td></td>
        </tr>
        <tr>
          <td>pause</td>
          <td>5000</td>
          <td></td>
        </tr>
        <tr>
          <td>click</td>
          <td>//a[.="Delete"]</td>
          <td></td>
        </tr>
        <tr>
          <td>pause</td>
          <td>5000</td>
          <td></td>
        </tr>
        <tr>
          <td>verifyText</td>
          <td>//div[@class="info"]</td>
          <td>1-8/73 Records</td>
        </tr>
          <tr>
            <td>openAndWait</td>
            <td>${base_url}</td>
            <td></td>
          </tr>
          <tr>
            <td>waitForPageToLoad</td>
            <td><br></td>
            <td></td>
          </tr>
          <tr>
            <td>waitForElementPresent</td>
            <td>//div[@id="global-panel"]</td>
            <td></td>
          </tr>
          <tr>
            <td>click</td>
            <td>//a[.='Menu']</td>
            <td></td>
          </tr>
          <tr>
            <td>click</td>
            <td>//h1[.='Servers']</td>
            <td></td>
          </tr>
          <tr>
            <td>pause</td>
            <td>10000</td>
            <td></td>
          </tr>
          <tr>
            <td>click</td>
            <td>//a[.="Add Server"]</td>
            <td></td>
          </tr>
          <tr>
            <td>pause</td>
            <td>5000</td>
            <td></td>
          </tr>
          <tr>
            <td>type</td>
            <td>id=computer_new_title</td>
            <td>Quantum</td>
          </tr>
          <tr>
            <td>type</td>
            <td>id=computer_new_description</td>
            <td>I'm the fastest</td>
          </tr>
          <tr>
            <td>pause</td>
            <td>5000</td>
            <td></td>
          </tr>
          <tr>
            <td>click</td>
            <td>//input[@type="submit"]</td>
            <td></td>
          </tr>
          <tr>
            <td>pause</td>
            <td>5000</td>
            <td></td>
          </tr>
          <tr>
            <td>click</td>
            <td>//a[.="Delete"]</td>
            <td></td>
          </tr>
          <tr>
            <td>pause</td>
            <td>5000</td>
            <td></td>
          </tr>
          <tr>
            <td>verifyText</td>
            <td>//div[@class="info"]</td>
            <td>1-8/74 Records</td>
          </tr>
      </tbody>
    </table>
