2017-02-14 16:05:08 +00:00
|
|
|
'use strict';
|
|
|
|
const CARD_SELECTOR = '.ext-related-articles-card',
|
2017-12-08 18:40:57 +00:00
|
|
|
Page = require( 'wdio-mediawiki/Page' ),
|
2017-02-14 16:05:08 +00:00
|
|
|
READ_MORE_MODULE_NAME = 'ext.relatedArticles.readMore';
|
|
|
|
|
|
|
|
class ReadMorePage extends Page {
|
|
|
|
|
2017-08-22 11:22:26 +00:00
|
|
|
get mobileView() { return browser.element( '#footer-places-mobileview' ); }
|
|
|
|
|
2017-02-14 16:05:08 +00:00
|
|
|
openDesktop( name ) {
|
2017-12-08 18:40:57 +00:00
|
|
|
super.openTitle( name );
|
2017-02-14 16:05:08 +00:00
|
|
|
this.resourceLoaderModuleStatus( READ_MORE_MODULE_NAME, 'registered' );
|
|
|
|
}
|
|
|
|
|
|
|
|
openMobile( name ) {
|
2017-12-08 18:40:57 +00:00
|
|
|
super.openTitle( name );
|
2017-08-22 11:22:26 +00:00
|
|
|
this.mobileView.click();
|
2017-02-14 16:05:08 +00:00
|
|
|
this.resourceLoaderModuleStatus( READ_MORE_MODULE_NAME, 'ready' );
|
|
|
|
}
|
|
|
|
|
|
|
|
get extCardsCard() {
|
|
|
|
return browser.element( '.ext-related-articles-card' );
|
|
|
|
}
|
|
|
|
|
|
|
|
get readMore() {
|
|
|
|
this.readMoreCodeIsLoaded();
|
|
|
|
this.extCardsCard.waitForExist( 2000 );
|
|
|
|
return this.extCardsCard;
|
|
|
|
}
|
|
|
|
|
|
|
|
isCardVisible() {
|
|
|
|
return browser.isVisible( CARD_SELECTOR );
|
|
|
|
}
|
|
|
|
|
|
|
|
readMoreCodeIsLoaded() {
|
|
|
|
browser.waitUntil( function () {
|
|
|
|
return browser.execute( function ( status ) {
|
|
|
|
return mw && mw.loader && mw.loader.getState( 'ext.relatedArticles.readMore' ) === status;
|
|
|
|
}, 'ready' );
|
|
|
|
}, 2000, 'Related pages did not load' );
|
|
|
|
}
|
|
|
|
|
|
|
|
resourceLoaderModuleStatus( moduleName, moduleStatus ) {
|
|
|
|
return browser.waitUntil( function () {
|
|
|
|
return browser.execute( function ( module ) {
|
|
|
|
return mw && mw.loader && mw.loader.getState( module.name ) === module.status;
|
|
|
|
}, { status: moduleStatus, name: moduleName } );
|
|
|
|
}, 10000, 'Related pages did not load' );
|
|
|
|
}
|
|
|
|
|
|
|
|
seeReadMore() {
|
|
|
|
browser.waitForExist( CARD_SELECTOR, 10000 );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
module.exports = new ReadMorePage();
|