diff --git a/.gitignore b/.gitignore index 0b6bdcc0..e3133653 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,6 @@ **/*.js !/rollup.config.js !/trainees.js +!/test/functional/* /cli/build /cli/dist diff --git a/.travis.yml b/.travis.yml index 8935dd8b..45cd94a1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,9 @@ jobs: script: - make all - export PATH=$PATH:$TRAVIS_BUILD_DIR/node_modules/geckodriver/bin - - yarn mocha --timeout 15000 test/functional_test.js + - node test/functional/setup_http_server & + - yarn mocha --timeout 60000 test/functional/functional_test.js + - kill %1 # - stage: test # name: "Javascript tests" # language: node_js diff --git a/test/functional/functional_test.html b/test/functional/functional_test.html new file mode 100644 index 00000000..a2fbfc3e --- /dev/null +++ b/test/functional/functional_test.html @@ -0,0 +1,14 @@ + + + + + + + + +

Functional Testing Page - isVisible

+ + + + diff --git a/test/functional_test.mjs b/test/functional/functional_test.js similarity index 91% rename from test/functional_test.mjs rename to test/functional/functional_test.js index c2b882a8..bf1f0184 100644 --- a/test/functional_test.mjs +++ b/test/functional/functional_test.js @@ -1,7 +1,7 @@ const { expect } = require('chai'); const firefox = require('selenium-webdriver/firefox'); const webdriver = require('selenium-webdriver'); -const { ancestors, isDomElement, isVisible, toDomElement } = require('../utilsForFrontend'); +const { ancestors, isDomElement, isVisible, toDomElement } = require('../../utilsForFrontend'); describe('isVisible', () => { const options = new firefox.Options(); @@ -14,7 +14,7 @@ describe('isVisible', () => { describe('Unprivileged', () => { it('should return true when an element is visible', async () => { // TODO: put actual checks here - await driver.get('https://developer.mozilla.org/'); + await driver.get('http://localhost:8000/functional_test.html'); await driver.wait(async () => { const readyState = await driver.executeScript('return document.readyState'); return readyState === 'complete'; @@ -24,7 +24,7 @@ describe('isVisible', () => { ${ancestors} ${isDomElement} ${toDomElement} - return (${isVisible}(document.getElementById("home-q"))); + return (${isVisible}(document.getElementById("image"))); `); }); const expected = true; diff --git a/test/functional/setup_http_server.js b/test/functional/setup_http_server.js new file mode 100644 index 00000000..698a1e09 --- /dev/null +++ b/test/functional/setup_http_server.js @@ -0,0 +1,22 @@ +const http = require('http'); +const fs = require('fs'); +const url = require('url'); + +const PORT = 8000; + +const server = http.createServer((request, response) => { + const path = url.parse(request.url).pathname; + fs.readFile(__dirname + path, 'utf8', (error, data) => { + if (error) { + response.writeHead(404); + response.write(`There was an error: ${error.errno}, ${error.code}`); + response.end(); + } else { + response.writeHead(200, {'Content-Type': 'text/html'}); + response.write(data); + response.end(); + } + }); +}); +server.listen(PORT); +console.log(`Serving from ${__dirname} at http://localhost:${PORT}...`);