var Mocha = require('mocha'),
    _ = require('underscore'),
    moduleTest = require('./module');

module.exports = function (browser, dashboard, suite, config) {

  suite = Mocha.Suite.create(suite, dashboard.title);

  suite.beforeAll(function () {
    return browser.get(config.baseUrl + dashboard.slug)
      .$('body.ready', 5000)
      // if a dashboard isn't ready after 5s then there's probably a failed module
      // run module tests to help establish which
      .fail(function () {});
  });

  var tests = {
    exists: function exists() {
      return browser
        .title()
          .should.become(dashboard.title + ' - ' + dashboard.strapline + ' - GOV.UK')
        .$('h1').text()
          .should.eventually.equal(dashboard.strapline + '\n' + dashboard.title)
        .$('body.ready')
          .should.eventually.exist;
    }
  };

  _.each(tests, function (test, key) {
    suite.addTest(new Mocha.Test(key, test));
  });

  var modules = Mocha.Suite.create(suite, 'modules');
  dashboard.modules.forEach(function (module) {
    moduleTest(browser, module, modules, config);
  });

};
var Mocha = require('mocha'),
    _ = require('underscore'),
    moduleTest = require('./module');

module.exports = function (browser, dashboard, suite, config) {

  suite = Mocha.Suite.create(suite, dashboard.title);

  suite.beforeAll(function () {
    return browser.get(config.baseUrl + dashboard.slug)
      .setWindowSize(1024, 800)
      .$('body.ready', 5000)
      // if a dashboard isn't ready after 5s then there's probably a failed module
      // run module tests to help establish which
      .fail(function () {});
  });

  var tests = {
    exists: function exists() {
      return browser
        .title()
          .should.become(dashboard.title + ' - ' + dashboard.strapline + ' - GOV.UK')
        .$('h1').text()
          .should.eventually.equal(dashboard.strapline + '\n' + dashboard.title)
        .$('body.ready')
          .should.eventually.exist;
    }
  };

  _.each(tests, function (test, key) {
    suite.addTest(new Mocha.Test(key, test));
  });

  var modules = Mocha.Suite.create(suite, 'modules');
  dashboard.modules.forEach(function (module) {
    moduleTest(browser, module, modules, config);
  });

};
Set window size to desktop display dimensions
Set window size to desktop display dimensions

Some tests were failing because the default window dimensions cause the site to display in "mobile" format, truncating some elements and causing tests to fail.
