mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-30 18:34:40 +00:00
selenium: Replace Node.js Assert library with WebdriverIO Expect library
Assertions from Expect library are more readable that assertions from Assert library. Bug: T325740 Change-Id: I9224c52975919a512ac3b0342bb3805edecec6b3
This commit is contained in:
parent
7e4a6f6176
commit
eb1ddbb132
|
@ -7,7 +7,6 @@ const
|
|||
Util = require( 'wdio-mediawiki/Util' ),
|
||||
TEST_PAGE_POPUPS_TITLE = 'Page popups test page',
|
||||
POPUPS_SELECTOR = '.mwe-popups',
|
||||
PAGE_POPUPS_SELECTOR = '.mwe-popups-type-page',
|
||||
PAGE_POPUPS_LINK_SELECTOR = '.mw-body-content ul a',
|
||||
POPUPS_MODULE_NAME = 'ext.popups.main';
|
||||
|
||||
|
@ -18,6 +17,10 @@ async function makePage( title, path ) {
|
|||
await bot.edit( title, content );
|
||||
}
|
||||
class PopupsPage extends Page {
|
||||
get pagePopupsSelector() {
|
||||
return $( '.mwe-popups-type-page' );
|
||||
}
|
||||
|
||||
async setupPagePreviews() {
|
||||
return browser.call( async () => {
|
||||
const path = `${ __dirname }/../fixtures/`;
|
||||
|
@ -55,22 +58,6 @@ class PopupsPage extends Page {
|
|||
await $( PAGE_POPUPS_LINK_SELECTOR ).moveTo();
|
||||
}
|
||||
|
||||
async doNotSeePreview( selector ) {
|
||||
return browser.waitUntil( async () => !( await $( selector ).isDisplayed() ) );
|
||||
}
|
||||
|
||||
async doNotSeePagePreview() {
|
||||
return this.doNotSeePreview( PAGE_POPUPS_SELECTOR );
|
||||
}
|
||||
|
||||
async seePreview( selector ) {
|
||||
return await $( selector ).isDisplayed();
|
||||
}
|
||||
|
||||
async seePagePreview() {
|
||||
return await this.seePreview( PAGE_POPUPS_SELECTOR );
|
||||
}
|
||||
|
||||
async openPagePopupsTest() {
|
||||
return super.openTitle( TEST_PAGE_POPUPS_TITLE );
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
const assert = require( 'assert' ),
|
||||
page = require( '../pageobjects/popups.page' );
|
||||
const page = require( '../pageobjects/popups.page' );
|
||||
|
||||
describe( 'Dwelling on a valid page link', function () {
|
||||
before( async function () {
|
||||
|
@ -15,24 +14,24 @@ describe( 'Dwelling on a valid page link', function () {
|
|||
|
||||
it( 'I should see a page preview', async function () {
|
||||
await page.dwellPageLink();
|
||||
await assert( await page.seePagePreview(), 'Page preview is shown.' );
|
||||
await expect( await page.pagePopupsSelector ).toBeDisplayed( { message: 'Page preview is shown.' } );
|
||||
} );
|
||||
|
||||
it( 'I should not see a page preview on hash fragment', async function () {
|
||||
await page.dwellPageFragment();
|
||||
assert( await page.doNotSeePagePreview(), 'Page preview is not shown.' );
|
||||
await expect( await page.pagePopupsSelector ).not.toBeDisplayed( { message: 'Page preview is not shown.' } );
|
||||
} );
|
||||
|
||||
it( 'Abandoning link hides page preview', async function () {
|
||||
await page.dwellPageLink();
|
||||
await page.abandonLink();
|
||||
assert( await page.doNotSeePagePreview(), 'Page preview is kept hidden.' );
|
||||
await expect( await page.pagePopupsSelector ).not.toBeDisplayed( { message: 'Page preview is kept hidden.' } );
|
||||
} );
|
||||
|
||||
it( 'Quickly hovering, abandoning and re-hovering a link shows page preview', async function () {
|
||||
await page.hoverPageLink();
|
||||
await page.abandonLink();
|
||||
await page.dwellPageLink();
|
||||
assert( await page.seePagePreview(), 'Page preview is shown.' );
|
||||
await expect( await page.pagePopupsSelector ).toBeDisplayed( { message: 'Page preview is shown.' } );
|
||||
} );
|
||||
} );
|
||||
|
|
Loading…
Reference in a new issue