From 248beb378dc7bdb864edb5486e2556cd81e7bea6 Mon Sep 17 00:00:00 2001 From: Ricki Jay Date: Mon, 19 Feb 2024 15:11:09 +0100 Subject: [PATCH] Property Page methods --- test/helpers/pages/entity/property.page.ts | 11 +++++++++++ test/specs/repo/property.ts | 22 +++++++++++----------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/test/helpers/pages/entity/property.page.ts b/test/helpers/pages/entity/property.page.ts index 2ef43f29f..6da957f0a 100644 --- a/test/helpers/pages/entity/property.page.ts +++ b/test/helpers/pages/entity/property.page.ts @@ -1,6 +1,17 @@ import { Page } from '../page.js'; class PropertyPage extends Page { + public get changeHistoryList(): ChainablePromiseElement { + return $( 'ul.mw-contributions-list' ); + } + public get mostRecentChange(): ChainablePromiseElement { + return this.changeHistoryList.$( 'li.before' ); + } + + public async openHistoryTab(): Promise { + return $( '=View history' ).click(); + } + /** * `/wiki/Property:${propertyId} * diff --git a/test/specs/repo/property.ts b/test/specs/repo/property.ts index 19ccd195a..996f5bece 100644 --- a/test/specs/repo/property.ts +++ b/test/specs/repo/property.ts @@ -78,7 +78,7 @@ describe( 'Property', function () { } ); it( 'Should show changes in "View history" tab', async () => { - await $( '=View history' ).click(); + await PropertyPage.openHistoryTab(); await expect( $( '.comment*=Created claim' ) ).toExist(); await expect( $( '.comment*=Changed claim' ) ).toExist(); await expect( $( '.comment*=Created a new Property' ) ).toExist(); @@ -92,25 +92,25 @@ describe( 'Property', function () { } ); it( 'Should be able to revert a change', async () => { - await $( '=View history' ).click(); + await PropertyPage.openHistoryTab(); await expect( - ( await $( 'ul.mw-contributions-list' ).$$( 'li' ) ).length - ).toBe( 3 ); - await $( 'ul.mw-contributions-list' ).$( 'li.before' ).$( 'a=undo' ).click(); + await PropertyPage.changeHistoryList.$$( 'li' ) + ).toHaveLength( 3 ); + await PropertyPage.mostRecentChange.$( 'a=undo' ).click(); await $( 'label=Summary (will be appended to an automatically generated summary):' ).click(); await browser.keys( undoSummaryText.split( '' ) ); await $( 'button=Save page' ).click(); - await $( '=View history' ).click(); + await PropertyPage.openHistoryTab(); await expect( - ( await $( 'ul.mw-contributions-list' ).$$( 'li' ) ).length - ).toBe( 4 ); + await PropertyPage.changeHistoryList.$$( 'li' ) + ).toHaveLength( 4 ); await expect( $( 'span.mw-tag-marker-mw-undo' ) ).toExist(); - await expect( - $( 'ul.mw-contributions-list' ).$( 'li.before' ) - ).toHaveTextContaining( undoSummaryText ); + await expect( PropertyPage.mostRecentChange ).toHaveTextContaining( + undoSummaryText + ); } ); it( 'Should be able to set label, description, aliases', async () => {