Move Selenium test from mediawiki/core

Bug: T187859
Change-Id: Ib153f1d55e4471c4dc1e16ad3c9ae0ea9f73acf5
This commit is contained in:
addshore 2018-02-21 13:58:51 +01:00 committed by Jforrester
parent 2cd16d6012
commit 68292ad0a8
4 changed files with 96 additions and 0 deletions

View file

@ -0,0 +1,11 @@
{
"extends": "../../.eslintrc.json",
"env": {
"es6": true,
"mocha": true,
"node": true
},
"globals": {
"browser": false
}
}

33
tests/selenium/README.md Normal file
View file

@ -0,0 +1,33 @@
# Selenium tests
Please see tests/selenium/README.md file in mediawiki/core repository (usually at mediawiki/vagrant/mediawiki).
## Usage
Set up MediaWiki-Vagrant:
cd mediawiki/vagrant
vagrant up
vagrant provision
cd mediawiki
npm install
Run both mediawiki/core and skin tests from mediawiki/core folder:
npm run selenium
To run only skin tests, first in one terminal tab (or window) start Chromedriver:
chromedriver --url-base=wd/hub --port=4444
Then, in another terminal tab (or window) go to mediawiki/core folder:
./node_modules/.bin/wdio tests/selenium/wdio.conf.js --spec skins/SKIN-NAME/tests/selenium/specs/*.js
Run only one skin test file from mediawiki/core folder:
./node_modules/.bin/wdio tests/selenium/wdio.conf.js --spec skins/SKIN-NAME/tests/selenium/specs/FILE-NAME.js
To run only one skin test from mediawiki/core folder (name contains string 'TEST-NAME'):
./node_modules/.bin/wdio tests/selenium/wdio.conf.js --spec skins/SKIN-NAME/tests/selenium/specs/FILE-NAME.js --mochaOpts.grep preferences TEST-NAME

View file

@ -0,0 +1,7 @@
'use strict';
const Page = require( '../../../../../tests/selenium/pageobjects/page' );
class UserMessagePage extends Page {
get usermessage() { return browser.element( 'div.usermessage' ); }
}
module.exports = new UserMessagePage();

View file

@ -0,0 +1,45 @@
'use strict';
const assert = require( 'assert' ),
CreateAccountPage = require( '../../../../../tests/selenium/pageobjects/createaccount.page' ),
EditPage = require( '../../../../../tests/selenium/pageobjects/edit.page' ),
UserLoginPage = require( '../../../../../tests/selenium/pageobjects/userlogin.page' ),
UserMessagePage = require( '../pageobjects/usermessage.page' );
describe( 'User', function () {
var password,
username;
before( function () {
// disable VisualEditor welcome dialog
UserLoginPage.open();
browser.localStorage( 'POST', { key: 've-beta-welcome-dialog', value: '1' } );
} );
beforeEach( function () {
browser.deleteCookie();
username = `User-${Math.random().toString()}`;
password = Math.random().toString();
} );
it( 'should be able to view new message banner', function () {
// create user
browser.call( function () {
return CreateAccountPage.apiCreateAccount( username, password );
} );
// create talk page with content
browser.call( function () {
return EditPage.apiEdit( 'User_talk:' + username, Math.random().toString() );
} );
// log in
UserLoginPage.login( username, password );
// check
assert.equal( UserMessagePage.usermessage.getText(), 'You have a new message (last change).' );
} );
} );