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 {
|
|
|
|
|
2020-05-25 18:17:41 +00:00
|
|
|
get mobileView() { return $( '#footer-places-mobileview' ); }
|
2017-08-22 11:22:26 +00:00
|
|
|
|
2017-02-14 16:05:08 +00:00
|
|
|
openDesktop( name ) {
|
2017-12-08 18:40:57 +00:00
|
|
|
super.openTitle( name );
|
2020-05-25 18:17:41 +00:00
|
|
|
this.resourceLoaderModuleStatus( READ_MORE_MODULE_NAME, 'loading' );
|
2017-02-14 16:05:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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() {
|
2020-05-25 18:17:41 +00:00
|
|
|
return $( '.ext-related-articles-card' );
|
2017-02-14 16:05:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get readMore() {
|
|
|
|
this.readMoreCodeIsLoaded();
|
2020-05-25 18:17:41 +00:00
|
|
|
this.extCardsCard.waitForExist( { timeout: 2000 } );
|
2017-02-14 16:05:08 +00:00
|
|
|
return this.extCardsCard;
|
|
|
|
}
|
|
|
|
|
|
|
|
isCardVisible() {
|
2020-05-25 18:17:41 +00:00
|
|
|
return $( CARD_SELECTOR ).isDisplayed();
|
2017-02-14 16:05:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
readMoreCodeIsLoaded() {
|
2020-06-23 19:30:43 +00:00
|
|
|
browser.waitUntil( async () => {
|
2020-05-25 18:17:41 +00:00
|
|
|
return await browser.execute( async ( status ) => {
|
|
|
|
return await mw && mw.loader && mw.loader.getState( 'ext.relatedArticles.readMore' ) === status;
|
2017-02-14 16:05:08 +00:00
|
|
|
}, 'ready' );
|
|
|
|
}, 2000, 'Related pages did not load' );
|
|
|
|
}
|
|
|
|
|
|
|
|
resourceLoaderModuleStatus( moduleName, moduleStatus ) {
|
2020-06-23 19:30:43 +00:00
|
|
|
return browser.waitUntil( async () => {
|
|
|
|
return await browser.execute( async ( module ) => {
|
2020-05-25 18:17:41 +00:00
|
|
|
return await mw && mw.loader && mw.loader.getState( module.name ) === module.status;
|
2017-02-14 16:05:08 +00:00
|
|
|
}, { status: moduleStatus, name: moduleName } );
|
|
|
|
}, 10000, 'Related pages did not load' );
|
|
|
|
}
|
|
|
|
|
|
|
|
seeReadMore() {
|
2020-05-25 18:17:41 +00:00
|
|
|
$( CARD_SELECTOR ).waitForExist( { timeout: 10000 } );
|
2017-02-14 16:05:08 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
module.exports = new ReadMorePage();
|