From b25d303007d0c076a2afe97f823bdd1fb9ec35c6 Mon Sep 17 00:00:00 2001 From: Jakob Warkotsch Date: Mon, 18 Jun 2018 16:13:42 +0200 Subject: [PATCH] Add browser test for basic watchlist functionality Will be used to test more advanced title/link formatters downstream. Bug: T191601 Change-Id: I0747c2d361e951f8b3765a3dca548e55edb72216 --- tests/selenium/pageobjects/watchable.page.js | 13 ++++++ tests/selenium/pageobjects/watchlist.page.js | 15 +++++++ tests/selenium/specs/specialwatchlist.js | 44 ++++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 tests/selenium/pageobjects/watchable.page.js create mode 100644 tests/selenium/pageobjects/watchlist.page.js create mode 100644 tests/selenium/specs/specialwatchlist.js diff --git a/tests/selenium/pageobjects/watchable.page.js b/tests/selenium/pageobjects/watchable.page.js new file mode 100644 index 0000000000..896b2f4d71 --- /dev/null +++ b/tests/selenium/pageobjects/watchable.page.js @@ -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 index 0000000000..58a003fdca --- /dev/null +++ b/tests/selenium/pageobjects/watchlist.page.js @@ -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 index 0000000000..1e33b2bfca --- /dev/null +++ b/tests/selenium/specs/specialwatchlist.js @@ -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 ); + } ); + +} ); -- 2.20.1