MisterDevo/TFTFT

View on GitHub
public/report/test-spec.html

Summary

Maintainability
Test Coverage
    <section class="suite">
      <h1>TFTFT End To End tests</h1>
      <dl>
        <section class="suite">
          <h1>Welcome page</h1>
          <dl>
            <dt>should have the right title</dt>
            <dd><pre><code>client.get(options.baseUrl);
client.wait(client.getTitle(), 10000)
  .then(function(title){
      assert.equal(title, 'TFTFT - Test First Test First Test');
  });</code></pre></dd>
            <dt>should wait for loading first angular view</dt>
            <dd><pre><code>client.wait(webdriver.until.elementLocated(webdriver.By.id('welcome-view')), 10000)
.getAttribute('class')
.then(function(attr){
    assert.equal(attr, 'txtstyle ng-scope');
});</code></pre></dd>
          </dl>
        </section>
        <section class="suite">
          <h1>Mocha menu</h1>
          <dl>
            <dt>should slide with ng-click condition</dt>
            <dd><pre><code>client.findElement(webdriver.By.id('mocha-link'))
  .getAttribute('ng-click')
  .then(function(attr){
      assert(attr.length);
  });</code></pre></dd>
            <dt>should display submenu on click after toggle if necessary (small device)</dt>
            <dd><pre><code>client.findElement(webdriver.By.className('navbar-toggle'))
  .isDisplayed()
  .then(function(displayed){
      if(displayed){
        client.findElement(webdriver.By.className('navbar-toggle')).click();
      }
  });
client.findElement(webdriver.By.id('mocha-link')).click();
client.findElement(webdriver.By.className('nav-second-level'))
  .isDisplayed()
  .then(function(displayed){
      assert(displayed);
  });</code></pre></dd>
            <section class="suite">
              <h1>Unit Test menu</h1>
              <dl>
                <dt>should display correct mocha-unit link</dt>
                <dd><pre><code>client.findElement(webdriver.By.id('mocha-unit-link'))
  .getAttribute('href')
  .then(function(attr){
      assert.equal(attr,  options.baseUrl + '/#mocha-unit');
  });</code></pre></dd>
                <dt>should wait for loading mocha-unit view</dt>
                <dd><pre><code>client.wait(webdriver.until.elementLocated(webdriver.By.id('mocha-unit-link')), 10000)
  .click()
  .then( function() {
    repTestedElem = client.wait(webdriver.until.elementLocated(webdriver.By.css('section')), 10000);
    repTestedElem
      .getAttribute('class')
      .then(function(attr){
          assert.equal(attr, 'suite ng-scope');
      });
  });</code></pre></dd>
              </dl>
            </section>
            <section class="suite">
              <h1>Route Test menu</h1>
              <dl>
                <dt>should display correct mocha-route link</dt>
                <dd><pre><code>var btn = client.findElement(webdriver.By.id('mocha-route-link'));
btn.getAttribute('href')
  .then(function(attr){
      assert.equal(attr,  options.baseUrl + '/#mocha-route');
      btn.click();
  });</code></pre></dd>
                <dt>should wait for loading mocha-route view</dt>
                <dd><pre><code>/*
    must find a solution to pass saucelabs android test
    stalenessOf is not use
*/
if(options.desiredCapabilities.browserName === 'android') {
    client.findElement(webdriver.By.css('section'))
      .getAttribute('class')
      .then(function(attr){
          assert.equal(attr, 'suite ng-scope');
      });
} else {
    client.wait(webdriver.until.stalenessOf(repTestedElem), 10000)
        .then(function(el){
          repTestedElem = client.findElement(webdriver.By.css('section'));
          repTestedElem
            .getAttribute('class')
            .then(function(attr){
                assert.equal(attr, 'suite ng-scope');
            });
        });
}</code></pre></dd>
              </dl>
            </section>
            <section class="suite">
              <h1>End to End Test menu</h1>
              <dl>
                <dt>should display correct mocha-spec link</dt>
                <dd><pre><code>var btn = client.findElement(webdriver.By.id('mocha-spec-link'));
btn.getAttribute('href')
  .then(function(attr){
      assert.equal(attr,  options.baseUrl + '/#mocha-spec');
      btn.click();
  });</code></pre></dd>
                <dt>should wait for loading mocha-spec view</dt>
                <dd><pre><code>/*
    must find a solution to pass saucelabs android test
    stalenessOf is not use
*/
if(options.desiredCapabilities.browserName === 'android') {
    client.findElement(webdriver.By.css('section'))
      .getAttribute('class')
      .then(function(attr){
          assert.equal(attr, 'suite ng-scope');
      });
} else {
    client.wait(webdriver.until.stalenessOf(repTestedElem), 10000)
        .then(function(el){
          client.findElement(webdriver.By.css('section'))
            .getAttribute('class')
            .then(function(attr){
                assert.equal(attr, 'suite ng-scope');
            });
        });
}</code></pre></dd>
              </dl>
            </section>
          </dl>
        </section>
        <section class="suite">
          <h1>Istanbul menu</h1>
          <dl>
            <dt>should display correct coverage link</dt>
            <dd><pre><code>client.findElement(webdriver.By.id('coverage-link'))
  .getAttribute('href')
  .then(function(attr){
      assert.equal(attr,  options.baseUrl + '/#coverage');
  });</code></pre></dd>
            <dt>should display correct url in the view</dt>
            <dd><pre><code>client.findElement(webdriver.By.id('coverage-link')).click();
client.wait(webdriver.until.elementLocated(webdriver.By.id('frame-coverage')), 10000)
  .getAttribute('src')
  .then(function(attr){
      assert.equal(attr,  options.baseUrl + '/cov/lcov-report/index.html');
  });</code></pre></dd>
            <dt>should be correct page loaded</dt>
            <dd><pre><code>client.switchTo().frame(client.findElement(webdriver.By.id('frame-coverage')));
client.findElement(webdriver.By.className('footer'))
    .getInnerHtml()
    .then(function(html){
        assert.equal(html.split('\n  ')[1], 'Code coverage');
    });</code></pre></dd>
          </dl>
        </section>
        <section class="suite">
          <h1>Saucelabs dropdown and popup</h1>
          <dl>
            <dt>should popup saucelabs matrix when mouse hover sl-logo if present (large device)</dt>
            <dd><pre><code>client.findElement(webdriver.By.className('navbar-toggle'))
            .isDisplayed()
            .then(function(displayed){
                if(displayed){
                  assert(true);
                } else {
                  /*
                      must find a solution to pass saucelabs internet explorer and safari test
                      Exception on mouseMove : replace by click on logo (not necessary in this test)
                  */
                  if(options.desiredCapabilities.browserName === 'internet explorer'
                                  || options.desiredCapabilities.browserName === 'safari' ) {
                      client.findElement(webdriver.By.css('#sl-logo[popover-placement]'))
                        .click()
                        .then(function(){
                          client.wait(webdriver.until.elementLocated(webdriver.By.id('sl-mat-pp')), 3000)
                            .getAttribute('src')
                            .then(function(attr){
                                assert.equal(attr,  options.baseUrl + '/images/misterdevo.svg');
                            });
                        });
                  } else {
                      new webdriver.ActionSequence(client)
                        .mouseMove(client.findElement(webdriver.By.css('#sl-logo[popover-placement]')))
                        .perform()
                        .then(function(){
                          client.wait(webdriver.until.elementLocated(webdriver.By.id('sl-mat-pp')), 3000)
                            .getAttribute('src')
                            .then(function(attr){
                                assert.equal(attr,  options.baseUrl + '/images/misterdevo.svg');
                            });
                        });
                  }
                }
            });</code></pre></dd>
            <dt>should display saucelabs matrix when click on sl-link present only in mocha-spec view</dt>
            <dd><pre><code>client.findElement(webdriver.By.id('mocha-spec-link')).click();
client.findElement(webdriver.By.id('sl-link')).click();
client.wait(webdriver.until.elementLocated(webdriver.By.id('sl-mat-dd')), 3000)
  .getAttribute('src')
  .then(function(attr){
      assert.equal(attr,  options.baseUrl +  '/images/misterdevo.svg');
  });</code></pre></dd>
          </dl>
        </section>
        <section class="suite">
          <h1>Mail Me feature</h1>
          <dl>
            <dt>should display mailme directive when click on mailme-link</dt>
            <dd><pre><code>client.findElement(webdriver.By.id('mailme-link')).click();
client.findElement(webdriver.By.css('mailme'))
  .isDisplayed()
  .then(function(displayed){
      mailmeForm = client.findElement(webdriver.By.css('mailme'))
                             .findElement(webdriver.By.css('form'));
      assert(displayed);
  });</code></pre></dd>
            <dt>should return response if message is send</dt>
            <dd><pre><code>//  var mailmeForm = client.findElement(webdriver.By.css('mailme'))
//                           .findElement(webdriver.By.css('form'));
 mailmeForm.findElement(webdriver.By.css('textarea'))
              .sendKeys(&quot;hello from selenium test&quot;);
 mailmeForm.findElement(webdriver.By.css('input[type=submit]'))
              .click();
 client.wait(webdriver.until.elementTextContains(mailmeForm.findElement(webdriver.By.className('txtstyle')),' '), 3000)
         .getInnerHtml()
         .then(function(html){
             assert(html.length);
         });</code></pre></dd>
            <dt>should return error if empty message is send</dt>
            <dd><pre><code>// var mailmeForm = client.findElement(webdriver.By.css('mailme'))
//                           .findElement(webdriver.By.css('form'));
mailmeForm.findElement(webdriver.By.css('input[type=submit]'))
          .click();
client.wait(webdriver.until.elementTextContains(mailmeForm.findElement(webdriver.By.className('txtstyle')),' '), 3000)
     .getInnerHtml()
     .then(function(html){
         assert.equal(html, 'An error occurs.');
     });</code></pre></dd>
          </dl>
        </section>
      </dl>
    </section>