Merge "Selenium tests for Math"
This commit is contained in:
commit
5581b9779a
|
@ -1,7 +1,8 @@
|
||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "grunt test"
|
"test": "grunt test",
|
||||||
|
"selenium-test": "wdio tests/selenium/wdio.conf.js"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint-config-wikimedia": "0.5.0",
|
"eslint-config-wikimedia": "0.5.0",
|
||||||
|
@ -12,6 +13,10 @@
|
||||||
"grunt-jsonlint": "1.1.0",
|
"grunt-jsonlint": "1.1.0",
|
||||||
"grunt-stylelint": "0.9.0",
|
"grunt-stylelint": "0.9.0",
|
||||||
"stylelint": "8.2.0",
|
"stylelint": "8.2.0",
|
||||||
"stylelint-config-wikimedia": "0.4.2"
|
"stylelint-config-wikimedia": "0.4.2",
|
||||||
|
"wdio-mediawiki": "0.1.7",
|
||||||
|
"wdio-mocha-framework": "0.5.8",
|
||||||
|
"wdio-spec-reporter": "0.0.5",
|
||||||
|
"webdriverio": "4.12.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
# Selenium tests
|
||||||
|
|
||||||
|
Please see tests/selenium/README.md file in mediawiki/core repository and
|
||||||
|
https://www.mediawiki.org/wiki/Selenium/Node.js.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Set up MediaWiki-Vagrant:
|
||||||
|
|
||||||
|
cd mediawiki/vagrant
|
||||||
|
vagrant up
|
||||||
|
vagrant roles enable math
|
||||||
|
vagrant provision
|
||||||
|
|
||||||
|
Run both mediawiki/core and Math tests from mediawiki/core folder:
|
||||||
|
|
||||||
|
npm run selenium
|
||||||
|
|
||||||
|
To run only Math tests in one terminal window or tab start Chromedriver:
|
||||||
|
|
||||||
|
chromedriver --url-base=/wd/hub --port=4444
|
||||||
|
|
||||||
|
In another terminal tab or window go to mediawiki/core folder:
|
||||||
|
|
||||||
|
./node_modules/.bin/wdio tests/selenium/wdio.conf.js --spec extensions/Math/tests/selenium/specs/*.js
|
||||||
|
|
||||||
|
Run only one Math test file from mediawiki/core:
|
||||||
|
|
||||||
|
./node_modules/.bin/wdio tests/selenium/wdio.conf.js --spec extensions/Math/tests/selenium/specs/basic.js
|
|
@ -0,0 +1,9 @@
|
||||||
|
'use strict';
|
||||||
|
const Page = require( 'wdio-mediawiki/Page' );
|
||||||
|
|
||||||
|
class MathPage extends Page {
|
||||||
|
|
||||||
|
get img() { return browser.element( '.mwe-math-fallback-image-inline' ); }
|
||||||
|
|
||||||
|
}
|
||||||
|
module.exports = new MathPage();
|
|
@ -0,0 +1,26 @@
|
||||||
|
'use strict';
|
||||||
|
const assert = require('assert'),
|
||||||
|
Api = require('wdio-mediawiki/Api'),
|
||||||
|
MathPage = require('../pageobjects/math.page');
|
||||||
|
|
||||||
|
|
||||||
|
describe('Math', function () {
|
||||||
|
|
||||||
|
it('should work for addition', function () {
|
||||||
|
|
||||||
|
// page should have random name
|
||||||
|
var pageName = Math.random().toString();
|
||||||
|
|
||||||
|
// create a page with a simple addition
|
||||||
|
browser.call(function () {
|
||||||
|
return Api.edit(pageName, '<math>3 + 2</math>');
|
||||||
|
});
|
||||||
|
|
||||||
|
MathPage.openTitle(pageName);
|
||||||
|
|
||||||
|
// check if the page displays the image
|
||||||
|
assert(MathPage.img.isExisting());
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
|
@ -0,0 +1,88 @@
|
||||||
|
/**
|
||||||
|
* See also: http://webdriver.io/guide/testrunner/configurationfile.html
|
||||||
|
*/
|
||||||
|
const fs = require( 'fs' ),
|
||||||
|
saveScreenshot = require( 'wdio-mediawiki' ).saveScreenshot;
|
||||||
|
|
||||||
|
exports.config = {
|
||||||
|
// ======
|
||||||
|
// Custom WDIO config specific to MediaWiki
|
||||||
|
// ======
|
||||||
|
// Use in a test as `browser.options.<key>`.
|
||||||
|
// Defaults are for convenience with MediaWiki-Vagrant
|
||||||
|
|
||||||
|
// Wiki admin
|
||||||
|
username: process.env.MEDIAWIKI_USER || 'Admin',
|
||||||
|
password: process.env.MEDIAWIKI_PASSWORD || 'vagrant',
|
||||||
|
|
||||||
|
// Base for browser.url() and Page#openTitle()
|
||||||
|
baseUrl: ( process.env.MW_SERVER || 'http://127.0.0.1:8080' ) + (
|
||||||
|
process.env.MW_SCRIPT_PATH || '/w'
|
||||||
|
),
|
||||||
|
|
||||||
|
// ==================
|
||||||
|
// Test Files
|
||||||
|
// ==================
|
||||||
|
specs: [
|
||||||
|
__dirname + '/specs/*.js'
|
||||||
|
],
|
||||||
|
|
||||||
|
// ============
|
||||||
|
// Capabilities
|
||||||
|
// ============
|
||||||
|
capabilities: [ {
|
||||||
|
// https://sites.google.com/a/chromium.org/chromedriver/capabilities
|
||||||
|
browserName: 'chrome',
|
||||||
|
maxInstances: 1,
|
||||||
|
chromeOptions: {
|
||||||
|
// If DISPLAY is set, assume developer asked non-headless or CI with Xvfb.
|
||||||
|
// Otherwise, use --headless (added in Chrome 59)
|
||||||
|
// https://chromium.googlesource.com/chromium/src/+/59.0.3030.0/headless/README.md
|
||||||
|
args: [
|
||||||
|
...( process.env.DISPLAY ? [] : [ '--headless' ] ),
|
||||||
|
// Chrome sandbox does not work in Docker
|
||||||
|
...( fs.existsSync( '/.dockerenv' ) ? [ '--no-sandbox' ] : [] )
|
||||||
|
]
|
||||||
|
}
|
||||||
|
} ],
|
||||||
|
|
||||||
|
// ===================
|
||||||
|
// Test Configurations
|
||||||
|
// ===================
|
||||||
|
|
||||||
|
// Level of verbosity: silent | verbose | command | data | result | error
|
||||||
|
logLevel: 'error',
|
||||||
|
|
||||||
|
// Setting this enables automatic screenshots for when a browser command fails
|
||||||
|
// It is also used by afterTest for capturig failed assertions.
|
||||||
|
screenshotPath: process.env.LOG_DIR || __dirname + '/log',
|
||||||
|
|
||||||
|
// Default timeout for each waitFor* command.
|
||||||
|
waitforTimeout: 10 * 1000,
|
||||||
|
|
||||||
|
// See also: http://webdriver.io/guide/testrunner/reporters.html
|
||||||
|
reporters: [ 'spec' ],
|
||||||
|
|
||||||
|
// See also: http://mochajs.org
|
||||||
|
mochaOpts: {
|
||||||
|
ui: 'bdd',
|
||||||
|
timeout: 60 * 1000
|
||||||
|
},
|
||||||
|
|
||||||
|
// =====
|
||||||
|
// Hooks
|
||||||
|
// =====
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save a screenshot when test fails.
|
||||||
|
*
|
||||||
|
* @param {Object} test Mocha Test object
|
||||||
|
*/
|
||||||
|
afterTest: function ( test ) {
|
||||||
|
var filePath;
|
||||||
|
if ( !test.passed ) {
|
||||||
|
filePath = saveScreenshot( test.title );
|
||||||
|
console.log( '\n\tScreenshot: ' + filePath + '\n' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue