Merge "Add browser test for basic watchlist functionality"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 25 Jun 2018 09:49:02 +0000 (09:49 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 25 Jun 2018 09:49:02 +0000 (09:49 +0000)
tests/selenium/pageobjects/watchable.page.js [new file with mode: 0644]
tests/selenium/pageobjects/watchlist.page.js [new file with mode: 0644]
tests/selenium/specs/specialwatchlist.js [new file with mode: 0644]

diff --git a/tests/selenium/pageobjects/watchable.page.js b/tests/selenium/pageobjects/watchable.page.js
new file mode 100644 (file)
index 0000000..896b2f4
--- /dev/null
@@ -0,0 +1,13 @@
+const Page = require( 'wdio-mediawiki/Page' );
+
+class WatchablePage extends Page {
+
+       get confirmWatch() { return browser.element( '#mw-content-text button[type="submit"]' ); }
+
+       watch( title ) {
+               super.openTitle( title, { action: 'watch' } );
+               this.confirmWatch.click();
+       }
+}
+
+module.exports = new WatchablePage();
diff --git a/tests/selenium/pageobjects/watchlist.page.js b/tests/selenium/pageobjects/watchlist.page.js
new file mode 100644 (file)
index 0000000..58a003f
--- /dev/null
@@ -0,0 +1,15 @@
+const Page = require( 'wdio-mediawiki/Page' );
+
+class WatchlistPage extends Page {
+       get titles() {
+               return browser.element( '.mw-changeslist' )
+                       .$$( '.mw-changeslist-line .mw-title' );
+       }
+
+       open() {
+               super.openTitle( 'Special:Watchlist' );
+       }
+
+}
+
+module.exports = new WatchlistPage();
diff --git a/tests/selenium/specs/specialwatchlist.js b/tests/selenium/specs/specialwatchlist.js
new file mode 100644 (file)
index 0000000..1e33b2b
--- /dev/null
@@ -0,0 +1,44 @@
+const assert = require( 'assert' ),
+       Api = require( 'wdio-mediawiki/Api' ),
+       WatchlistPage = require( '../pageobjects/watchlist.page' ),
+       WatchablePage = require( '../pageobjects/watchable.page' ),
+       LoginPage = require( 'wdio-mediawiki/LoginPage' );
+
+describe( 'Special:Watchlist', function () {
+       let username, password;
+
+       function getTestString( prefix = '' ) {
+               return prefix + Math.random().toString() + '-öäü-♠♣♥♦';
+       }
+
+       before( function () {
+               username = getTestString( 'user-' );
+               password = getTestString( 'password-' );
+
+               browser.call( function () {
+                       return Api.createAccount( username, password );
+               } );
+       } );
+
+       beforeEach( function () {
+               browser.deleteCookie();
+               LoginPage.login( username, password );
+       } );
+
+       it( 'should show page with new edit', function () {
+               const title = getTestString( 'Title-' );
+
+               browser.call( function () {
+                       return Api.edit( title, getTestString() ); // create
+               } );
+               WatchablePage.watch( title );
+               browser.call( function () {
+                       return Api.edit( title, getTestString() ); // edit
+               } );
+
+               WatchlistPage.open();
+
+               assert.strictEqual( WatchlistPage.titles[ 0 ].getText(), title );
+       } );
+
+} );