Improved www.ttss.krakow.pl
Jacek Kowalski
2019-05-04 0bd33d6f00f135abfd2acd1cc981afcfb0a2f0a3
Switch to Nightwatch.js for browser tests

This replaces CasperJS due to various reasons:
1. Neither PhantomJS nor SlimerJS are supported.
2. https://github.com/ariya/phantomjs/issues/13450
2 files added
1 files modified
1 files deleted
135 ■■■■■ changed files
.travis.yml 9 ●●●● patch | view | raw | blame | history
nightwatch.conf.js 50 ●●●●● patch | view | raw | blame | history
tests.js 45 ●●●●● patch | view | raw | blame | history
tests/index.js 31 ●●●●● patch | view | raw | blame | history
.travis.yml
@@ -6,10 +6,15 @@
  - 7.0
  - nightly
addons:
  firefox: latest
  chrome: stable
before_script:
  - 'php -S 127.0.0.1:8080 &'
  - 'nvm install stable'
  - 'npm install casperjs'
  - 'npm install nightwatch selenium-server chromedriver geckodriver'
script:
  - 'node_modules/casperjs/bin/casperjs test tests.js'
  - 'node_modules/.bin/nightwatch -e chrome-headless'
  - 'node_modules/.bin/nightwatch -e firefox-headless'
nightwatch.conf.js
New file
@@ -0,0 +1,50 @@
var seleniumServer = require('selenium-server');
var chromedriver = require('chromedriver');
var geckodriver = require('geckodriver');
module.exports = {
  src_folders: ['tests'],
  selenium: {
    start_process: true,
    server_path: seleniumServer.path,
    port: 4444,
    cli_args: {
      'webdriver.chrome.driver': chromedriver.path,
      'webdriver.gecko.driver': geckodriver.path,
    },
  },
  test_settings: {
    'chrome': {
      desiredCapabilities: {
        browserName: 'chrome',
      },
    },
    'chrome-headless': {
      desiredCapabilities: {
        browserName: 'chrome',
        chromeOptions: {
          args: [
            '--headless',
            '--no-sandbox',
            '--disable-gpu',
          ],
        },
      },
    },
    'firefox': {
      desiredCapabilities: {
        browserName: 'firefox',
      },
    },
    'firefox-headless': {
      desiredCapabilities: {
        browserName: 'firefox',
        'moz:firefoxOptions': {
          args: [
            '--headless',
          ],
        },
      },
    },
  },
};
tests.js
File was deleted
tests/index.js
New file
@@ -0,0 +1,31 @@
module.exports = {
    'Stop name autocompletion': function(browser) {
        browser.url('http://127.0.0.1:8080/');
        browser.getTitle(function(title) {
            this.assert.ok(title.includes('TTSS'));
        });
        var autocomplete_pairs = [
            ['baga', 'Teatr Bagatela'],
            ['d g', 'Dworzec Główny'],
            ['świę', 'Plac Wszystkich Świętych'],
            ['św g', 'Św. Gertrudy'],
            ['św.g', 'Św. Gertrudy'],
        ];
        autocomplete_pairs.forEach(function(value) {
            browser.clearValue('#stop-name');
            browser.setValue('#stop-name', value[0]);
            browser.pause(200);
            browser.expect.element('#stop-name-autocomplete > option:first-child').to.be.present.before(1000);
            browser.expect.element('#stop-name-autocomplete > option:first-child').text.to.include(value[1]).before(1000);
        });
    },
    'Translation engine': function(browser) {
        browser.url('http://127.0.0.1:8080/#!en');
        browser.pause(200);
        browser.getTitle(function(title) {
            this.assert.ok(title.includes('departures'));
        });
        browser.expect.element('[data-translate=header_line]').text.to.include('Line');
    },
};