summaryrefslogtreecommitdiff
path: root/www/wiki/tests/selenium/pageobjects
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/tests/selenium/pageobjects')
-rw-r--r--www/wiki/tests/selenium/pageobjects/createaccount.page.js49
-rw-r--r--www/wiki/tests/selenium/pageobjects/delete.page.js39
-rw-r--r--www/wiki/tests/selenium/pageobjects/edit.page.js39
-rw-r--r--www/wiki/tests/selenium/pageobjects/history.page.js13
-rw-r--r--www/wiki/tests/selenium/pageobjects/page.js8
-rw-r--r--www/wiki/tests/selenium/pageobjects/preferences.page.js20
-rw-r--r--www/wiki/tests/selenium/pageobjects/restore.page.js21
-rw-r--r--www/wiki/tests/selenium/pageobjects/userlogin.page.js27
8 files changed, 216 insertions, 0 deletions
diff --git a/www/wiki/tests/selenium/pageobjects/createaccount.page.js b/www/wiki/tests/selenium/pageobjects/createaccount.page.js
new file mode 100644
index 00000000..105f4092
--- /dev/null
+++ b/www/wiki/tests/selenium/pageobjects/createaccount.page.js
@@ -0,0 +1,49 @@
+'use strict';
+const Page = require( './page' );
+
+class CreateAccountPage extends Page {
+
+ get username() { return browser.element( '#wpName2' ); }
+ get password() { return browser.element( '#wpPassword2' ); }
+ get confirmPassword() { return browser.element( '#wpRetype' ); }
+ get create() { return browser.element( '#wpCreateaccount' ); }
+ get heading() { return browser.element( '#firstHeading' ); }
+
+ open() {
+ super.open( 'Special:CreateAccount' );
+ }
+
+ createAccount( username, password ) {
+ this.open();
+ this.username.setValue( username );
+ this.password.setValue( password );
+ this.confirmPassword.setValue( password );
+ this.create.click();
+ }
+
+ apiCreateAccount( username, password ) {
+
+ const MWBot = require( 'mwbot' ), // https://github.com/Fannon/mwbot
+ Promise = require( 'bluebird' );
+ let bot = new MWBot();
+
+ return Promise.coroutine( function* () {
+ yield bot.loginGetCreateaccountToken( {
+ apiUrl: `${browser.options.baseUrl}/api.php`,
+ username: browser.options.username,
+ password: browser.options.password
+ } );
+ yield bot.request( {
+ action: 'createaccount',
+ createreturnurl: browser.options.baseUrl,
+ createtoken: bot.createaccountToken,
+ username: username,
+ password: password,
+ retype: password
+ } );
+ } ).call( this );
+
+ }
+
+}
+module.exports = new CreateAccountPage();
diff --git a/www/wiki/tests/selenium/pageobjects/delete.page.js b/www/wiki/tests/selenium/pageobjects/delete.page.js
new file mode 100644
index 00000000..d43cb9f6
--- /dev/null
+++ b/www/wiki/tests/selenium/pageobjects/delete.page.js
@@ -0,0 +1,39 @@
+'use strict';
+const Page = require( './page' );
+
+class DeletePage extends Page {
+
+ get reason() { return browser.element( '#wpReason' ); }
+ get watch() { return browser.element( '#wpWatch' ); }
+ get submit() { return browser.element( '#wpConfirmB' ); }
+ get displayedContent() { return browser.element( '#mw-content-text' ); }
+
+ open( name ) {
+ super.open( name + '&action=delete' );
+ }
+
+ delete( name, reason ) {
+ this.open( name );
+ this.reason.setValue( reason );
+ this.submit.click();
+ }
+
+ apiDelete( name, reason ) {
+
+ const MWBot = require( 'mwbot' ), // https://github.com/Fannon/mwbot
+ Promise = require( 'bluebird' );
+ let bot = new MWBot();
+
+ return Promise.coroutine( function* () {
+ yield bot.loginGetEditToken( {
+ apiUrl: `${browser.options.baseUrl}/api.php`,
+ username: browser.options.username,
+ password: browser.options.password
+ } );
+ yield bot.delete( name, reason );
+ } ).call( this );
+
+ }
+
+}
+module.exports = new DeletePage();
diff --git a/www/wiki/tests/selenium/pageobjects/edit.page.js b/www/wiki/tests/selenium/pageobjects/edit.page.js
new file mode 100644
index 00000000..33a27f0f
--- /dev/null
+++ b/www/wiki/tests/selenium/pageobjects/edit.page.js
@@ -0,0 +1,39 @@
+'use strict';
+const Page = require( './page' );
+
+class EditPage extends Page {
+
+ get content() { return browser.element( '#wpTextbox1' ); }
+ get displayedContent() { return browser.element( '#mw-content-text' ); }
+ get heading() { return browser.element( '#firstHeading' ); }
+ get save() { return browser.element( '#wpSave' ); }
+
+ openForEditing( name ) {
+ super.open( name + '&action=edit' );
+ }
+
+ edit( name, content ) {
+ this.openForEditing( name );
+ this.content.setValue( content );
+ this.save.click();
+ }
+
+ apiEdit( name, content ) {
+
+ const MWBot = require( 'mwbot' ), // https://github.com/Fannon/mwbot
+ Promise = require( 'bluebird' );
+ let bot = new MWBot();
+
+ return Promise.coroutine( function* () {
+ yield bot.loginGetEditToken( {
+ apiUrl: `${browser.options.baseUrl}/api.php`,
+ username: browser.options.username,
+ password: browser.options.password
+ } );
+ yield bot.edit( name, content, `Created page with "${content}"` );
+ } ).call( this );
+
+ }
+
+}
+module.exports = new EditPage();
diff --git a/www/wiki/tests/selenium/pageobjects/history.page.js b/www/wiki/tests/selenium/pageobjects/history.page.js
new file mode 100644
index 00000000..869484e6
--- /dev/null
+++ b/www/wiki/tests/selenium/pageobjects/history.page.js
@@ -0,0 +1,13 @@
+'use strict';
+const Page = require( './page' );
+
+class HistoryPage extends Page {
+
+ get comment() { return browser.element( '#pagehistory .comment' ); }
+
+ open( name ) {
+ super.open( name + '&action=history' );
+ }
+
+}
+module.exports = new HistoryPage();
diff --git a/www/wiki/tests/selenium/pageobjects/page.js b/www/wiki/tests/selenium/pageobjects/page.js
new file mode 100644
index 00000000..77bb1f4e
--- /dev/null
+++ b/www/wiki/tests/selenium/pageobjects/page.js
@@ -0,0 +1,8 @@
+// From http://webdriver.io/guide/testrunner/pageobjects.html
+'use strict';
+class Page {
+ open( path ) {
+ browser.url( browser.options.baseUrl + '/index.php?title=' + path );
+ }
+}
+module.exports = Page;
diff --git a/www/wiki/tests/selenium/pageobjects/preferences.page.js b/www/wiki/tests/selenium/pageobjects/preferences.page.js
new file mode 100644
index 00000000..98b87fe9
--- /dev/null
+++ b/www/wiki/tests/selenium/pageobjects/preferences.page.js
@@ -0,0 +1,20 @@
+'use strict';
+const Page = require( './page' );
+
+class PreferencesPage extends Page {
+
+ get realName() { return browser.element( '#mw-input-wprealname' ); }
+ get save() { return browser.element( '#prefcontrol' ); }
+
+ open() {
+ super.open( 'Special:Preferences' );
+ }
+
+ changeRealName( realName ) {
+ this.open();
+ this.realName.setValue( realName );
+ this.save.click();
+ }
+
+}
+module.exports = new PreferencesPage();
diff --git a/www/wiki/tests/selenium/pageobjects/restore.page.js b/www/wiki/tests/selenium/pageobjects/restore.page.js
new file mode 100644
index 00000000..071f7f98
--- /dev/null
+++ b/www/wiki/tests/selenium/pageobjects/restore.page.js
@@ -0,0 +1,21 @@
+'use strict';
+const Page = require( './page' );
+
+class RestorePage extends Page {
+
+ get reason() { return browser.element( '#wpComment' ); }
+ get submit() { return browser.element( '#mw-undelete-submit' ); }
+ get displayedContent() { return browser.element( '#mw-content-text' ); }
+
+ open( name ) {
+ super.open( 'Special:Undelete/' + name );
+ }
+
+ restore( name, reason ) {
+ this.open( name );
+ this.reason.setValue( reason );
+ this.submit.click();
+ }
+
+}
+module.exports = new RestorePage();
diff --git a/www/wiki/tests/selenium/pageobjects/userlogin.page.js b/www/wiki/tests/selenium/pageobjects/userlogin.page.js
new file mode 100644
index 00000000..0061d0c2
--- /dev/null
+++ b/www/wiki/tests/selenium/pageobjects/userlogin.page.js
@@ -0,0 +1,27 @@
+'use strict';
+const Page = require( './page' );
+
+class UserLoginPage extends Page {
+
+ get username() { return browser.element( '#wpName1' ); }
+ get password() { return browser.element( '#wpPassword1' ); }
+ get loginButton() { return browser.element( '#wpLoginAttempt' ); }
+ get userPage() { return browser.element( '#pt-userpage' ); }
+
+ open() {
+ super.open( 'Special:UserLogin' );
+ }
+
+ login( username, password ) {
+ this.open();
+ this.username.setValue( username );
+ this.password.setValue( password );
+ this.loginButton.click();
+ }
+
+ loginAdmin() {
+ this.login( browser.options.username, browser.options.password );
+ }
+
+}
+module.exports = new UserLoginPage();