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' ) ,
2023-11-08 22:06:07 +00:00
READ _MORE _MODULE _NAME = 'ext.relatedArticles.readMore.bootstrap' ;
2017-02-14 16:05:08 +00:00
class ReadMorePage extends Page {
2024-04-20 20:15:07 +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 ( ) {
2024-06-14 12:07:36 +00:00
browser . waitUntil ( async ( ) => await browser . execute ( async ( status ) => await mw && mw . loader && mw . loader . getState ( 'ext.relatedArticles.readMore' ) === status , 'ready' ) , 2000 , 'Related pages did not load' ) ;
2017-02-14 16:05:08 +00:00
}
resourceLoaderModuleStatus ( moduleName , moduleStatus ) {
2024-06-14 12:07:36 +00:00
return browser . waitUntil ( async ( ) => await browser . execute ( async ( module ) => await mw && mw . loader && mw . loader . getState ( module . name ) === module . status , { status : moduleStatus , name : moduleName } ) , 10000 , 'Related pages did not load' ) ;
2017-02-14 16:05:08 +00:00
}
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 ( ) ;