Merge "selenium: Replace Node.js Assert library with WebdriverIO Expect library"

This commit is contained in:
jenkins-bot 2024-11-27 11:40:47 +00:00 committed by Gerrit Code Review
commit e2fdc4b129
2 changed files with 9 additions and 23 deletions

View file

@ -7,7 +7,6 @@ const
Util = require( 'wdio-mediawiki/Util' ), Util = require( 'wdio-mediawiki/Util' ),
TEST_PAGE_POPUPS_TITLE = 'Page popups test page', TEST_PAGE_POPUPS_TITLE = 'Page popups test page',
POPUPS_SELECTOR = '.mwe-popups', POPUPS_SELECTOR = '.mwe-popups',
PAGE_POPUPS_SELECTOR = '.mwe-popups-type-page',
PAGE_POPUPS_LINK_SELECTOR = '.mw-body-content ul a', PAGE_POPUPS_LINK_SELECTOR = '.mw-body-content ul a',
POPUPS_MODULE_NAME = 'ext.popups.main'; POPUPS_MODULE_NAME = 'ext.popups.main';
@ -18,6 +17,10 @@ async function makePage( title, path ) {
await bot.edit( title, content ); await bot.edit( title, content );
} }
class PopupsPage extends Page { class PopupsPage extends Page {
get pagePopupsSelector() {
return $( '.mwe-popups-type-page' );
}
async setupPagePreviews() { async setupPagePreviews() {
return browser.call( async () => { return browser.call( async () => {
const path = `${ __dirname }/../fixtures/`; const path = `${ __dirname }/../fixtures/`;
@ -55,22 +58,6 @@ class PopupsPage extends Page {
await $( PAGE_POPUPS_LINK_SELECTOR ).moveTo(); 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() { async openPagePopupsTest() {
return super.openTitle( TEST_PAGE_POPUPS_TITLE ); return super.openTitle( TEST_PAGE_POPUPS_TITLE );
} }

View file

@ -1,7 +1,6 @@
'use strict'; 'use strict';
const assert = require( 'assert' ), const page = require( '../pageobjects/popups.page' );
page = require( '../pageobjects/popups.page' );
describe( 'Dwelling on a valid page link', function () { describe( 'Dwelling on a valid page link', function () {
before( async 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 () { it( 'I should see a page preview', async function () {
await page.dwellPageLink(); 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 () { it( 'I should not see a page preview on hash fragment', async function () {
await page.dwellPageFragment(); 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 () { it( 'Abandoning link hides page preview', async function () {
await page.dwellPageLink(); await page.dwellPageLink();
await page.abandonLink(); 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 () { it( 'Quickly hovering, abandoning and re-hovering a link shows page preview', async function () {
await page.hoverPageLink(); await page.hoverPageLink();
await page.abandonLink(); await page.abandonLink();
await page.dwellPageLink(); await page.dwellPageLink();
assert( await page.seePagePreview(), 'Page preview is shown.' ); await expect( await page.pagePopupsSelector ).toBeDisplayed( { message: 'Page preview is shown.' } );
} ); } );
} ); } );