Skip to content

Commit

Permalink
Statement Component
Browse files Browse the repository at this point in the history
  • Loading branch information
RickiJay-WMDE committed Feb 19, 2024
1 parent be9a791 commit 65953eb
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 22 deletions.
24 changes: 24 additions & 0 deletions test/helpers/pages/component/statement.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import propertyIdSelector from '../../property-id-selector.js';

class StatementComponent {
public get addReferenceLink(): ChainablePromiseElement {
return $( '=add reference' );
}
public get addStatementLink(): ChainablePromiseElement {
return $( '=add statement' );
}
public get saveStatementLink(): ChainablePromiseElement {
// Only return save button if enabled
return $( '.wikibase-toolbar-button-save[aria-disabled="false"]' ).$( '=save' );
}

public async selectProperty(
propertyId: string,
propertyLabel?: string
): Promise<void> {
await browser.keys( ( propertyLabel ?? propertyId ).split( '' ) );
await propertyIdSelector( propertyId ).click();
}
}

export default new StatementComponent();
5 changes: 0 additions & 5 deletions test/helpers/pages/entity/property.page.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import { Page } from '../page.js';

class PropertyPage extends Page {
public get saveStatementLink(): ChainablePromiseElement {
// Only return save button if enabled
return $( '.wikibase-toolbar-button-save[aria-disabled="false"]' ).$( '=save' );
}

/**
* `/wiki/Property:${propertyId}
*
Expand Down
3 changes: 2 additions & 1 deletion test/specs/repo/extensions/wikibase-edtf.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import assert from 'assert';
import WikibaseApi from 'wdio-wikibase/wikibase.api.js';
import Statement from '../../../helpers/pages/component/statement.js';
import ItemPage from '../../../helpers/pages/entity/item.page.js';
import SpecialEntityDataPage from '../../../helpers/pages/special/entity-data.page.js';
import SpecialNewPropertyPage from '../../../helpers/pages/special/new-property.page.js';
Expand Down Expand Up @@ -57,7 +58,7 @@ describe( 'WikibaseEdtf', function () {
const itemId = await WikibaseApi.createItem( 'edtf-test' );

await ItemPage.open( itemId );
await $( '=add statement' ).click();
await Statement.addStatementLink.click();
await browser.keys( 'Groundhog Day Release'.split( '' ) );
await $(
'span.ui-entityselector-description=Date on which the film Groundhog Day was broadly released to theaters'
Expand Down
9 changes: 3 additions & 6 deletions test/specs/repo/extensions/wikibase-local-media.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import assert from 'assert';
import LoginPage from 'wdio-mediawiki/LoginPage.js';
import WikibaseApi from 'wdio-wikibase/wikibase.api.js';
import Statement from '../../../helpers/pages/component/statement.js';
import ItemPage from '../../../helpers/pages/entity/item.page.js';
import PropertyPage from '../../../helpers/pages/entity/property.page.js';
import propertyIdSelector from '../../../helpers/property-id-selector.js';
import { Claim } from '../../../types/entity-data.js';

describe( 'WikibaseLocalMedia', function () {
Expand Down Expand Up @@ -69,11 +69,8 @@ describe( 'WikibaseLocalMedia', function () {
const itemId = await WikibaseApi.createItem( 'image-test-2' );
await ItemPage.open( itemId );

await $( '=add statement' ).click();

await browser.keys( propertyLabel.split( '' ) );
await propertyIdSelector( propertyId ).click();

await Statement.addStatementLink.click();
await Statement.selectProperty( propertyId, propertyLabel );
await browser.keys( 'image.png'.split( '' ) );
await $( 'ul.ui-mediasuggester-list' )
.$( 'a' )
Expand Down
17 changes: 7 additions & 10 deletions test/specs/repo/property.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import WikibaseApi from 'wdio-wikibase/wikibase.api.js';
import Statement from '../../helpers/pages/component/statement.js';
import PropertyPage from '../../helpers/pages/entity/property.page.js';
import page from '../../helpers/pages/page.js';
import SpecialEntityDataPage from '../../helpers/pages/special/entity-data.page.js';
import propertyIdSelector from '../../helpers/property-id-selector.js';
import {
wikibasePropertyItem,
wikibasePropertyString
Expand Down Expand Up @@ -37,12 +37,10 @@ describe( 'Property', function () {
} );

it( 'Should be able to add statement to property', async () => {
await $( '=add statement' ).click();
// fill out property id for statement
await browser.keys( stringPropertyId.split( '' ) );
await propertyIdSelector( stringPropertyId ).click();
await Statement.addStatementLink.click();
await Statement.selectProperty( stringPropertyId );
await browser.keys( statementText.split( '' ) );
await PropertyPage.saveStatementLink.click();
await Statement.saveStatementLink.click();
} );

it( 'Should be able to see added statement', async function () {
Expand All @@ -54,13 +52,12 @@ describe( 'Property', function () {
} );

it( 'Should be able to add reference to property', async () => {
await $( '=add reference' ).click();
await Statement.addReferenceLink.click();
// fill out property id for reference
await $( '.ui-entityselector-input' ).isFocused();
await browser.keys( stringPropertyId.split( '' ) );
await propertyIdSelector( stringPropertyId ).click();
await Statement.selectProperty( stringPropertyId );
await browser.keys( referenceText.split( '' ) );
await PropertyPage.saveStatementLink.click();
await Statement.saveStatementLink.click();
} );

it( 'Should be able to see added reference', async function () {
Expand Down

0 comments on commit 65953eb

Please sign in to comment.