Improved www.ttss.krakow.pl
5515fcacb41ce1d10833e8aef44cfd00c8ecac8c..15df3c0b618c6343acdb02f220659606428e8835
2017-03-18 Jacek Kowalski
Execute functional tests using casperjs
15df3c diff | tree
2017-03-18 Jacek Kowalski
Remove unused function declinate()
707215 diff | tree
2017-03-18 Jacek Kowalski
Update page title on language change
d59e36 diff | tree
1 files modified
2 files added
69 ■■■■■ changed files
.travis.yml 17 ●●●●● patch | view | raw | blame | history
index.js 7 ●●●● patch | view | raw | blame | history
tests.js 45 ●●●●● patch | view | raw | blame | history
.travis.yml
New file
@@ -0,0 +1,17 @@
language: php
php:
  - 5.4
  - 5.5
  - 5.6
  - 7.0
  - nightly
sudo: required
before_script:
  - 'php -S 127.0.0.1:8080 &'
  - 'nvm install stable'
  - 'npm install casperjs'
script:
  - 'node_modules/casperjs/bin/casperjs tests.js'
index.js
@@ -393,11 +393,6 @@
    }).fail(fail_ajax).always(loading_end);
}
function declinate(num, singular, plural) {
    if(num == 1) return num + ' ' + singular;
    return num + ' ' + plural;
}
function startTimer(date) {
    if(date) {
        setText(refresh_text, lang.last_refreshed.replace('$time', lang.time_now));
@@ -456,6 +451,8 @@
    
    if(stop_id) return;
    
    setText(page_title, lang.page_title);
    if(stop_name_autocomplete.value) {
        setText(refresh_text, lang.select_stop_click_go);
    } else {
tests.js
New file
@@ -0,0 +1,45 @@
casper.test.begin('Stop name autocompletion', 4, function(test) {
    casper.start('http://127.0.0.1:8080/', function() {
        test.assertTitleMatches(/^TTSS\s/, 'Page title: TTSS...');
    });
    var autocomplete_pairs = [
        ['bag', 'Teatr Bagatela'],
        ['d g', 'Dworzec Główny'],
        ['świę', 'Plac Wszystkich Świętych'],
    ];
    autocomplete_pairs.forEach(function(value) {
        casper.then(function() {
            this.sendKeys('#stop-name', value[0], {reset: true});
        }).wait(200, function() {
            test.assertSelectorHasText(
                '#stop-name-autocomplete > option',
                value[1],
                'Autocomplete: ' + value[1]
            );
        });
    });
    casper.run(function() {
        test.done();
    });
});
casper.test.begin('Translation engine', 2, function(test) {
    casper.start('http://127.0.0.1:8080/#!pl', function() {
        test.assertTitleMatches(/odjazdy/i, 'Page title: ...odjazdy...');
    });
    casper.wait(200, function() {
        test.assertSelectorHasText(
            '[data-translate=header_lines]',
            'Linie',
            'Translation: Lines -> Linie'
        );
    });
    casper.run(function() {
        test.done();
    });
});