From bee41d87bdfa00d2a2f2a912d21bd8087a12b685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20R=C3=B8sdal?= Date: Wed, 17 Mar 2021 12:26:41 +0100 Subject: [PATCH] Remove CasperJS tests, since CasperJS and PhantomJS is no longer maintained. --- .github/workflows/ci.yml | 3 - README.md | 2 - scripts/ci-run.sh | 47 ------ scripts/install/deb.sh | 3 - scripts/install/ext-install.sh | 9 -- tests/README.md | 18 --- tests/casperjs-1.1.4/.gitignore | 8 - tests/freeciv-web-autogame.js | 59 ------- tests/freeciv-web-tests.js | 270 -------------------------------- 9 files changed, 419 deletions(-) delete mode 100755 scripts/ci-run.sh delete mode 100644 tests/README.md delete mode 100644 tests/casperjs-1.1.4/.gitignore delete mode 100644 tests/freeciv-web-autogame.js delete mode 100644 tests/freeciv-web-tests.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 11d16111d..9896822b4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,6 +21,3 @@ jobs: - name: install shell: bash run: ./scripts/install/install.sh --mode=TEST - - name: run tests - shell: bash - run: ./scripts/ci-run.sh diff --git a/README.md b/README.md index 6bdf8751a..35d1ea7aa 100644 --- a/README.md +++ b/README.md @@ -193,8 +193,6 @@ Freeciv-Web continuous integration on Travis CI ----------------------------------------------- Freeciv-Web is built on Travis CI on every commit. This is the current build status: [![Build Status](https://api.travis-ci.org/freeciv/freeciv-web.png)](https://travis-ci.org/freeciv/freeciv-web) -Freeciv-web has CasperJS tests which are run by Travis CI on every commit, and by Vagrant when creating a new image. The tests can be found in tests/freeciv-web-tests.js. Please make sure that patches and commits for Freeciv-web don't break the CasperJS tests. Thanks! - Developers interested in Freeciv-web ------------------------------------ diff --git a/scripts/ci-run.sh b/scripts/ci-run.sh deleted file mode 100755 index 9c006f633..000000000 --- a/scripts/ci-run.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -# Freeciv-web CI test script - -error=0 - -casper_test () { - xvfb-run --server-args="-screen 0 800x600x24" casperjs --engine=phantomjs test "$@" - err=$? - if [ $err -ne 0 ]; then - >&2 echo "Freeciv-web CasperJS test $@ failed with exit code ${err}" - error=1 - fi -} - -basedir=$(pwd) - -cd ${basedir}/scripts/ && ./start-freeciv-web.sh - -cat ${basedir}/logs/*.log - -echo "============================================" -#echo "Start testing of Freeciv-web using CasperJS:" -#cd ${basedir}/tests/ - -#casper_test freeciv-web-tests.js - -#echo "Running Freeciv-web server in autogame mode." -#mv "${basedir}"/publite2/pubscript_singleplayer.serv{,.bak} -#cp ${basedir}/publite2/pubscript_autogame.serv ${basedir}/publite2/pubscript_singleplayer.serv -#killall freeciv-web -#sleep 20 -#casper_test freeciv-web-autogame.js -#mv "${basedir}"/publite2/pubscript_singleplayer.serv{.bak,} - -echo "running pbem unit tests." -cd ${basedir}/pbem -if ! python3 test_pbem.py; then - error=1 -fi - -#echo "==============================" -if [ ${error} -eq 0 ]; then - echo "Freeciv-web built, tested and started correctly: Build successful!" -else - exit 1 -fi diff --git a/scripts/install/deb.sh b/scripts/install/deb.sh index 3293662b7..6eeaa20ff 100755 --- a/scripts/install/deb.sh +++ b/scripts/install/deb.sh @@ -119,7 +119,4 @@ echo "==== Installing Handlebars ====" cd "${TMPINSTDIR}" sudo -H npm install handlebars@4.5.3 -g -if [ "${FCW_INSTALL_MODE}" = TEST ]; then - ext_install_casperjs -fi diff --git a/scripts/install/ext-install.sh b/scripts/install/ext-install.sh index 68bd836db..0382b2c05 100755 --- a/scripts/install/ext-install.sh +++ b/scripts/install/ext-install.sh @@ -55,13 +55,4 @@ ext_install_tomcat8 () { ext_installed[${#ext_installed[@]}]="tomcat8" } -ext_install_casperjs () { - echo "==== Installing CasperJS for testing ====" - cd "${basedir}/tests" - curl -LOsS 'https://github.com/casperjs/casperjs/archive/1.1.4.zip' - unzip -qo 1.1.4.zip - rm 1.1.4.zip - sudo ln -sf "${basedir}/casperjs-1.1.4/bin/casperjs" /usr/local/bin/casperjs - ext_installed[${#ext_installed[@]}]="casperjs" -} diff --git a/tests/README.md b/tests/README.md deleted file mode 100644 index 59ba5ca91..000000000 --- a/tests/README.md +++ /dev/null @@ -1,18 +0,0 @@ - CasperJS tests for Freeciv-web. -=============================== - - This test is run automatically when setting up Vagrant or TravisCI installation. - - Freeciv-web requires CasperJS 1.1.2, PhantomJS 2.0 or SlimerJS version 0.10.0pre, - and xvfb (for headless tests). - - The tests can also be run manually like this in the /tests directory: - - ```bash - xvfb-run casperjs --engine=phantomjs test freeciv-web-tests.js - ``` - Running the tests will also produce two screenshots. - - The automatic build by Travis-CI uses PhantomJS. - -freeciv-web-autogame.js will start a server autogame for 200 turns. This is run by Travis-CI also. diff --git a/tests/casperjs-1.1.4/.gitignore b/tests/casperjs-1.1.4/.gitignore deleted file mode 100644 index eecc4e279..000000000 --- a/tests/casperjs-1.1.4/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -.DS_Store -/*.xml -/*.png -/docs/*.js -/docs/*.xml -/docs/_build -/tmp -*.pyc diff --git a/tests/freeciv-web-autogame.js b/tests/freeciv-web-autogame.js deleted file mode 100644 index 74c8ecf4f..000000000 --- a/tests/freeciv-web-autogame.js +++ /dev/null @@ -1,59 +0,0 @@ -/********************************************************************** - Autogame tests for Freeciv-web. - Use publite2/pubscript_autogame.serv for testing. -***********************************************************************/ -casper.on('remote.message', function(message) { - this.echo('JavaScript console: ' + message); -}); - -casper.options.waitTimeout = 60 * 60 * 1000; -casper.options.viewportSize = {width: 1024, height: 768}; - -casper.test.begin('Test starting new Freeciv-web autogame', 3, function suite(test) { - casper.start("http://localhost/webclient/?action=new&type=singleplayer"); - - casper.waitForSelector('#username_req', function() { - test.assertHttpStatus(200); - test.assertTitleMatch(/Freeciv-web/, 'Freeciv-web title is present'); - }); - - casper.then(function() { - this.echo("Filling in username in new game dialog."); - this.sendKeys('#username_req', 'CasperJS', {reset : true}); - this.echo("Starting Freeciv-web autogame for 200 turns! (this can take a long time! 30 minutes+)"); - }); - - casper.thenEvaluate(function() { - /* Starting new game automatically from Javascript.*/ - dialog_close_trigger = "button"; - if (validate_username()) { - $("#dialog").dialog('close'); - setTimeout("send_message('/ai CasperJs');", 4000); - setTimeout("send_message('/start');", 4200); - setInterval("eval(\"console.log('Running autogame... Current turn: ' + game_info['turn'] + ' - chat messages: ' + get_chatbox_text());\");", 30000); - } - }); - - casper.waitForText("T200", function() { - //this.clickLabel('Ok'); - this.echo("Captured screenshot to be saved as screenshot-autogame.png"); - this.capture('screenshot-autogame.png', undefined, { - format: 'png', - quality: 100 - }); - }); - - casper.then(function() { - this.echo("Checking number of turns completed."); - - test.assertEval(function() { - return game_info['turn'] >= 200; - }, "Checks that 200 turns has past."); - - }); - - casper.run(function() { - test.done(); - }); - - }); diff --git a/tests/freeciv-web-tests.js b/tests/freeciv-web-tests.js deleted file mode 100644 index 39ec2294e..000000000 --- a/tests/freeciv-web-tests.js +++ /dev/null @@ -1,270 +0,0 @@ -/********************************************************************** - CasperJS tests for Freeciv-web. -***********************************************************************/ - -casper.options.waitTimeout = 20000; -casper.options.viewportSize = {width: 1024, height: 768}; - -casper.on('remote.message', function(message) { - this.echo('JavaScript console: ' + message); -}); - -casper.test.begin('Test of Tomcat8 running on localhost port 8080.', 2, function suite(test) { - casper.start("http://localhost:8080/", function() { - test.assertHttpStatus(200); - test.assertTitleMatch(/Freeciv-web/, 'Freeciv-web title is present'); - }); - - casper.run(function() { - test.done(); - }); -}); - - -casper.test.begin('Test of Freeciv-proxy on port 7001.', 2, function suite(test) { - casper.start("http://localhost:7001/status", function() { - test.assertHttpStatus(200); - test.assertTextExists('Freeciv WebSocket Proxy Status', - 'Test that Freeciv-proxy contains expected text.'); - }); - - casper.run(function() { - test.done(); - }); -}); - - -casper.test.begin('Test of Freeciv-web frontpage on localhost port 80 (nginx).', 3, function suite(test) { - casper.start("http://localhost", function() {}); - - casper.waitForText("Freeciv-web", function() { - test.assertHttpStatus(200); - test.assertTitleMatch(/Freeciv-web/, 'Freeciv-web title is present'); - test.assertExists('#single-button'); - }); - - casper.run(function() { - test.done(); - }); -}); - -casper.test.begin('Test that game list is responding.', 4, function suite(test) { - casper.start("http://localhost/game/list", function() { - test.assertHttpStatus(200); - test.assertExists('#single-player-tab', 'Test that game-list contains expected tabs.'); - test.assertExists('#multi-player-tab', 'Test that game-list contains expected tabs.'); - test.assertExists('#play-by-email-tab', 'Test that game-list contains expected tabs.'); - }); - - casper.run(function() { - test.done(); - }); -}); - - -casper.test.begin('Test of Freeciv-web frontpage', 3, function suite(test) { - casper.start("http://localhost", function() { - casper.wait(5000, function() { - test.assertHttpStatus(200); - test.assertTitleMatch(/Freeciv-web/, 'Freeciv-web title is present'); - test.assertExists('#single-button'); - }); - }); - - casper.run(function() { - test.done(); - }); -}); - -casper.test.begin('Test starting new Freeciv-web game', 10, function suite(test) { - casper.start("http://localhost/webclient/?action=new&type=singleplayer", function() { - test.assertHttpStatus(200); - test.assertTitleMatch(/Freeciv-web/, 'Freeciv-web title is present'); - }); - - casper.waitForSelector('#username_req', function() { - this.echo("Captured screenshot to be saved as screenshot-1.png"); - this.capture('screenshot-1.png', undefined, { - format: 'png', - quality: 100 - }); - - }); - - casper.then(function() { - this.echo("Filling in username in new game dialog."); - this.sendKeys('#username_req', 'CasperJS', {reset : true}); - }); - - casper.thenEvaluate(function() { - /* Starting new game automatically from Javascript.*/ - dialog_close_trigger = "button"; - if (validate_username()) { - $("#dialog").dialog('close'); - setTimeout("pregame_start_game();", 3000); - } - }); - - casper.waitForText("World map", function() { - this.echo("Captured screenshot to be saved as screenshot-2.png"); - this.capture('screenshot-2.png', undefined, { - format: 'png', - quality: 100 - }); - }); - - casper.then(function() { - this.echo("Checking that JavaScript objects in browser memory are as expected."); - - test.assertEval(function() { - return tileset['u.settlers'].length == 5 && tileset['f.shield.england'].length == 5; - }, "Checks that tileset contains settlers and english flag."); - - test.assertEval(function() { - return map['xsize'] > 0 - && map['ysize'] > 0 - && tiles[5]['x'] >= 0 - && tiles[5]['y'] >= 0 - && tiles[5]['terrain'] != null; - }, "Checks properties of map and tiles."); - - - test.assertEval(function() { - return techs[1] != null - && techs[1]['name'] != null - && techs[1]['name'].length > 0 - && techs[1]['num_reqs'] > 0 - && techs[1]['req'].length == 2 - && techs[1]['req'][0] > 0 - && techs[1]['req'][1] > 0; - }, "Checks some properties of the tech object."); - - test.assertEval(function() { - return players[0] != null && players[0]['name'].length > 0 - && players[0]['username'].length > 0 - && players[0]['playerno'] >= 0 - && nations[players[0]['nation']] - && players[0]['love'].length > 0 - && players[0]['is_ready'] == true - }, "Checks some properties of the player object."); - - test.assertEval(function() { - return game_info['turn'] == 1 - && game_info['year'] == -4000 - && game_info['timeout'] == 0 - && game_info['gold'] > 0 - && game_info['aifill'] > 0; - }, "Checks some properties of the game_info object."); - - test.assertEval(function() { - return server_settings['size']['val'] > 0; - }, "Checking some server settings."); - - test.assertEval(function() { - return unit_types[0]['name'].length > 0 - && unit_types[0]['helptext'].length > 0 - && unit_types[0]['graphic_str'].length > 0 - }, "Checks some properties of the unit_types object."); - - - test.assertEval(function() { - return nations[0]['adjective'].length > 0 - && nations[0]['graphic_str'].length > 0; - }, "Checks some properties of the nations object."); - - }); - - casper.run(function() { - test.done(); - }); -}); - -casper.test.begin('Test pregame settings dialog ruleset switcher', - 3, function suite(test) { - casper.start("http://localhost/webclient/?action=new&type=singleplayer"); - - casper.waitForSelector('#username_req', function() { - this.echo("Filling in username in new game dialog."); - this.sendKeys('#username_req', 'CasperJS'); - - this.echo("Selecting to customize game in new game dialog."); - this.clickLabel("Customize Game"); - }); - - casper.waitForSelector('#pregame_settings_button', function() { - this.echo("Opening pre game settings dialog."); - this.click('#pregame_settings_button'); - }); - - casper.waitForSelector('#ruleset', function() { - this.echo("Loading webperimental."); - }); - - casper.thenEvaluate(function() { - /* Change to webperimental. */ - $('#ruleset').val('webperimental').change(); - }); - - casper.waitFor( - function() { - return this.evaluate(function() { - return "Webperimental" == ruleset_control['name']; - }); - }, - function() { - test.pass("Loaded webperimental."); - }); - - casper.wait(1000, function() { - this.echo("Loading civ2civ3."); - }); - - casper.thenEvaluate(function() { - /* Change to civ2civ3. */ - $('#ruleset').val('civ2civ3').change(); - }); - - casper.waitFor( - function() { - return this.evaluate(function() { - return "Civ2Civ3 ruleset" == ruleset_control['name']; - }); - }, - function() { - test.pass("Loaded civ2civ3."); - }); - - casper.wait(1000, function() { - this.echo("Loading classic."); - }); - - casper.thenEvaluate(function() { - /* Change to classic. */ - $('#ruleset').val('classic').change(); - }); - - casper.waitFor( - function() { - return this.evaluate(function() { - return "Classic ruleset" == ruleset_control['name']; - }); - }, - function() { - test.pass("Loaded classic."); - }); - - casper.run(function() { - test.done(); - }); -}); - -casper.test.begin('Test auto generated manual text extraction.', - 1, function suite(test) { - casper.start("http://localhost/man/classic7.html", function() { - test.assertHttpStatus(200); - }); - - casper.run(function() { - test.done(); - }); -});