Add tests for the reference preview fade effect

Bug: T214971
Change-Id: Ie59347e7f51d449900d3a107fd85b0753a14f449
This commit is contained in:
WMDE-Fisch 2019-03-21 11:59:22 +01:00
parent 2cff0a1a8e
commit dc1625de64
3 changed files with 28 additions and 4 deletions

View file

@ -8,6 +8,7 @@
==Reference links==
Lorem ipsum dolor.<ref>small reference</ref>
Reference with lots of text.<ref>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</ref>
==References==
<references />

View file

@ -76,8 +76,8 @@ class PopupsPage extends Page {
this.dwellLink( '#content ul a' );
}
dwellReferenceLink() {
this.dwellLink( '.reference a' );
dwellReferenceLink( num ) {
this.dwellLink( `.reference:nth-of-type(${ num }) a` );
}
doNotSeePreview( selector ) {
@ -104,6 +104,17 @@ class PopupsPage extends Page {
return this.seePreview( REFERENCE_POPUPS_SELECTOR );
}
seeScrollableReferencePreview() {
return browser.execute( () => {
const el = document.querySelector( '.mwe-popups-extract .mw-parser-output' );
return el.scrollHeight > el.offsetHeight;
} ).value;
}
seeFadeoutOnReferenceText() {
return browser.isExisting( '.mwe-popups-fade-out' );
}
open() {
super.openTitle( TEST_PAGE_TITLE );
}

View file

@ -11,8 +11,10 @@ describe( 'Dwelling on a valid reference link', function () {
this.skip();
}
page.open();
page.dwellReferenceLink();
page.dwellReferenceLink( 1 );
assert( page.seeReferencePreview(), 'Reference preview is shown.' );
assert( !page.seeScrollableReferencePreview(), 'Reference preview is not scrollable.' );
assert( !page.seeFadeoutOnReferenceText(), 'Reference preview has no fading effect' );
} );
it( 'Abandoning link hides reference preview', function () {
@ -20,8 +22,18 @@ describe( 'Dwelling on a valid reference link', function () {
this.skip();
}
page.open();
page.dwellReferenceLink();
page.dwellReferenceLink( 1 );
page.abandonLink();
assert( page.doNotSeeReferencePreview(), 'Reference preview is kept hidden.' );
} );
it( 'References with lots of text are scrollable and fades', function () {
if ( !page.hasReferencePopupsEnabled() ) {
this.skip();
}
page.open();
page.dwellReferenceLink( 2 );
assert( page.seeScrollableReferencePreview(), 'Reference preview has a fading effect' );
assert( page.seeFadeoutOnReferenceText(), 'Reference preview has a fading effect' );
} );
} );