diff --git a/tests/selenium/fixtures/test_page.wikitext b/tests/selenium/fixtures/test_page.wikitext index f08e5fdbb..0c8ca5349 100644 --- a/tests/selenium/fixtures/test_page.wikitext +++ b/tests/selenium/fixtures/test_page.wikitext @@ -1,7 +1,7 @@ =Popups test page= ==Valid links== -* [[Main Page]] +* [[Popups test page 2]] ==Invalid links== # blah diff --git a/tests/selenium/fixtures/test_page_2.wikitext b/tests/selenium/fixtures/test_page_2.wikitext new file mode 100644 index 000000000..8ae1f9ce4 --- /dev/null +++ b/tests/selenium/fixtures/test_page_2.wikitext @@ -0,0 +1,7 @@ +=Popups test page 2= + +==Valid links== +* [[Popups test page]] + +==Invalid links== +# blah diff --git a/tests/selenium/pageobjects/popups.page.js b/tests/selenium/pageobjects/popups.page.js index e2e491f4c..ac79d2361 100644 --- a/tests/selenium/pageobjects/popups.page.js +++ b/tests/selenium/pageobjects/popups.page.js @@ -8,18 +8,26 @@ const REFERENCE_POPUPS_SELECTOR = '.mwe-popups-type-reference', POPUPS_MODULE_NAME = 'ext.popups.main'; +function makePage( title, path ) { + return new Promise( ( resolve ) => { + fs.readFile( path, 'utf-8', ( err, content ) => { + if ( err ) { + throw err; + } + resolve( content ); + } ); + } ).then( ( content ) => { + return Api.edit( title, content ); + } ); +} class PopupsPage extends Page { setup() { browser.call( () => { - return new Promise( ( resolve ) => { - fs.readFile( `${ __dirname }/../fixtures/test_page.wikitext`, 'utf-8', ( err, content ) => { - if ( err ) { - throw err; - } - resolve( content ); - } ); - } ).then( ( content ) => { - return Api.edit( TEST_PAGE_TITLE, content ); + const path = `${ __dirname }/../fixtures/`; + // FIXME: Cannot use Promise.all as wdio-mediawiki/Api will trigger a bad + // token error. + return makePage( `${TEST_PAGE_TITLE} 2`, `${path}/test_page_2.wikitext` ).then( () => { + return makePage( TEST_PAGE_TITLE, `${path}test_page.wikitext` ); } ); } ); }