Skip to content

Commit dd6d5a2

Browse files
jenkins-botGerrit Code Review
authored andcommitted
Merge "Add statement opens edit statement modal"
2 parents cfabe35 + f1d2ba7 commit dd6d5a2

21 files changed

+641
-157
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import { Util } from 'cypress-wikibase-api';
2+
3+
import { checkA11y } from '../../support/checkA11y';
4+
import { ItemViewPage } from '../../support/pageObjects/ItemViewPage';
5+
import { AddStatementFormPage } from '../../support/pageObjects/AddStatementFormPage';
6+
7+
describe( 'wbui2025 item view add statement', () => {
8+
context( 'mobile view', () => {
9+
let itemViewPage: ItemViewPage;
10+
11+
before( () => {
12+
cy.task( 'MwApi:GetOrCreatePropertyIdByDataType', { datatype: 'string' } )
13+
.then( ( propertyId: string ) => {
14+
cy.wrap( propertyId ).as( 'propertyId' );
15+
const statementData = {
16+
claims: [ {
17+
mainsnak: {
18+
snaktype: 'value',
19+
property: propertyId,
20+
datavalue: {
21+
value: 'example string value',
22+
type: 'string',
23+
},
24+
},
25+
type: 'statement',
26+
rank: 'normal',
27+
} ],
28+
};
29+
cy.task( 'MwApi:CreateItem', { label: Util.getTestString( 'item' ), data: statementData } )
30+
.then( ( itemId: string ) => {
31+
itemViewPage = new ItemViewPage( itemId );
32+
} );
33+
} );
34+
} );
35+
36+
beforeEach( () => {
37+
cy.viewport( 375, 1280 );
38+
} );
39+
40+
it( 'loads the item view and shows property selector', () => {
41+
itemViewPage.open().statementsSection();
42+
checkA11y( ItemViewPage.STATEMENTS );
43+
itemViewPage.addStatementButton().click();
44+
45+
const addStatementFormPage = new AddStatementFormPage();
46+
addStatementFormPage.propertyLookup().should( 'exist' );
47+
cy.get<string>( '@propertyId' ).then( ( propertyId ) => {
48+
addStatementFormPage.setProperty( propertyId );
49+
} );
50+
addStatementFormPage.publishButton().should( 'be.disabled' );
51+
addStatementFormPage.snakValueInput().should( 'exist' );
52+
addStatementFormPage.setSnakValue( 'some string' );
53+
addStatementFormPage.publishButton().click();
54+
addStatementFormPage.form().should( 'not.exist' );
55+
itemViewPage.mainSnakValues().eq( 1 ).should( 'have.text', 'some string' );
56+
} );
57+
58+
} );
59+
} );

cypress/support/pageObjects/AddQualifierFormPage.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Chainable = Cypress.Chainable;
22

33
export class AddQualifierFormPage {
44
public static SELECTORS = {
5-
HEADING: '.wikibase-wbui2025-add-qualifier-heading h2',
5+
HEADING: '.wikibase-wbui2025-modal-overlay__header__title-group h2',
66
PROPERTY_INPUT: '.wikibase-wbui2025-property-lookup input',
77
SNAK_VALUE_INPUT: '.wikibase-wbui2025-add-qualifier-value input',
88
SNAK_VALUE_LOOKUP: '.wikibase-wbui2025-add-qualifier-value.cdx-lookup',
@@ -11,6 +11,7 @@ export class AddQualifierFormPage {
1111
SNAK_VALUE_MENU_ITEMS: '.wikibase-wbui2025-add-qualifier-value .cdx-menu-item',
1212
MENU: '.cdx-menu',
1313
ADD_BUTTON: '.wikibase-wbui2025-add-qualifier-form .cdx-button',
14+
PROPERTY_OPTIONS: '.wikibase-wbui2025-property-lookup .cdx-menu-item',
1415
};
1516

1617
public heading(): Chainable {
@@ -51,7 +52,7 @@ export class AddQualifierFormPage {
5152

5253
public setProperty( searchTerm: string ): this {
5354
this.propertyInput().type( searchTerm );
54-
cy.get( '.wikibase-wbui2025-property-lookup .cdx-menu-item:first' ).click();
55+
cy.get( AddQualifierFormPage.SELECTORS.PROPERTY_OPTIONS ).first().click();
5556
return this;
5657
}
5758

cypress/support/pageObjects/AddReferenceFormPage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Chainable = Cypress.Chainable;
22

33
export class AddReferenceFormPage {
44
public static SELECTORS = {
5-
HEADING: '.wikibase-wbui2025-add-reference-heading h2',
5+
HEADING: 'h2.wikibase-wbui2025-modal-overlay__header__title',
66
PROPERTY_INPUT: '.wikibase-wbui2025-property-lookup input',
77
SNAK_VALUE_INPUT: '.wikibase-wbui2025-add-reference-value input',
88
ADD_BUTTON: '.wikibase-wbui2025-add-reference-form .cdx-button',
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import Chainable = Cypress.Chainable;
2+
3+
export class AddStatementFormPage {
4+
public static SELECTORS = {
5+
PROPERTY_LOOKUP: '.wikibase-wbui2025-add-statement-form_property-selector',
6+
PROPERTY_INPUT: '.wikibase-wbui2025-property-lookup input',
7+
SUBMIT_BUTTONS: '.wikibase-wbui2025-modal-overlay__footer__actions > .cdx-button',
8+
SNAK_VALUE_INPUT: '.wikibase-wbui2025-edit-statement-snak-value input',
9+
FORM: '.wikibase-wbui2025-add-statement-form',
10+
};
11+
12+
public propertyLookup(): Chainable {
13+
return cy.get( AddStatementFormPage.SELECTORS.PROPERTY_LOOKUP );
14+
}
15+
16+
public propertyInput(): Chainable {
17+
return cy.get( AddStatementFormPage.SELECTORS.PROPERTY_INPUT );
18+
}
19+
20+
public publishButton(): Chainable {
21+
return cy.get( AddStatementFormPage.SELECTORS.SUBMIT_BUTTONS ).last();
22+
}
23+
24+
public snakValueInput(): Chainable {
25+
return cy.get( AddStatementFormPage.SELECTORS.SNAK_VALUE_INPUT );
26+
}
27+
28+
public cancelButton(): Chainable {
29+
return cy.get( AddStatementFormPage.SELECTORS.SUBMIT_BUTTONS ).first();
30+
}
31+
32+
public form(): Chainable {
33+
return cy.get( AddStatementFormPage.SELECTORS.FORM );
34+
}
35+
36+
public setProperty( searchTerm: string ): this {
37+
this.propertyInput().type( searchTerm );
38+
cy.get( '.wikibase-wbui2025-property-lookup .cdx-menu-item:first' ).click();
39+
return this;
40+
}
41+
42+
public setSnakValue( inputText: string ): this {
43+
this.snakValueInput().type( inputText );
44+
return this;
45+
}
46+
47+
}

cypress/support/pageObjects/ItemViewPage.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ export class ItemViewPage {
2424

2525
public static RANK_ICON = '.wikibase-rankselector span.ui-icon';
2626

27+
public static ADD_STATEMENT_BUTTON = '.wikibase-wbui2025-add-statement-button>.cdx-button';
28+
2729
private itemId: string;
2830

2931
public constructor( itemId: string ) {
@@ -79,6 +81,10 @@ export class ItemViewPage {
7981
return cy.get( ItemViewPage.RANK_ICON, { withinSubject: context } );
8082
}
8183

84+
public addStatementButton(): Chainable {
85+
return cy.get( ItemViewPage.VUE_CLIENTSIDE_RENDERED + ' ' + ItemViewPage.ADD_STATEMENT_BUTTON );
86+
}
87+
8288
public getClassForRank( rank: string ): string {
8389
return 'wikibase-rankselector-' + rank;
8490
}

repo/i18n/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"wikibase-publish": "publish",
3232
"wikibase-cancel": "cancel",
3333
"wikibase-add": "add",
34+
"wikibase-addstatement": "add statement",
3435
"wikibase-addqualifier": "add qualifier",
3536
"wikibase-addreference": "add reference",
3637
"wikibase-save-inprogress": "Saving…",

repo/i18n/qqq.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
"wikibase-publish": "This is the generic text used for the link that saves and publishes what the user has done while the user interface has been in edit mode.\n\nUsed as <code>$1</code> in {{msg-mw|Wikibase-shortcopyrightwarning}}.\n{{Identical|Publish}}",
7575
"wikibase-cancel": "[[File:Screenshot WikidataRepo 2012-05-13 G.png|right|0x150px]]\nThis is a generic text used for a link (fig. 2 on [[m:Wikidata/Notes/JavaScript ui implementation]]) that cancels what the user has done while the user interface has been in edit mode.\n{{Identical|Cancel}}",
7676
"wikibase-add": "[[File:Wikidata Screenshot Tony Garnier \"+ add\" button.png|thumb|Wikidata Screenshot, Tony Garnier item, demonstration of \"+ add\" button]]\nThis is a generic text used for a link (fig. 3 on [[m:Wikidata/Notes/JavaScript ui implementation]]) that puts the user interface into edit mode for an additional element of some kind.\n\n{{Identical|Add}}",
77+
"wikibase-addstatement": "Label of the link to add a statement (see [[d:Wikidata:Glossary]]).",
7778
"wikibase-addqualifier": "Label of the link to add a qualifier to a claim or statement (see the [[d:Wikidata:Glossary|Wikidata glossary]]).",
7879
"wikibase-addreference": "Label of the link to add a reference to a statement (see [[d:Wikidata:Glossary]]).",
7980
"wikibase-save-inprogress": "[[File:Screenshot WikidataRepo 2012-05-25 L.png|right|350px]]\n[[File:Screenshot WikidataRepo 2012-05-25 J.png|right|350px]]\n[[File:Screenshot WikidataRepo 2012-05-25 K.png|right|350px]]\nThis is a generic placeholder message used while a save is in progress, and replaces the save and cancel links.\n{{Identical|Saving}}",

repo/includes/RepoHooks.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,7 @@ public function onResourceLoaderRegisterModules( $rl ): void {
10521052
],
10531053
'messages' => [
10541054
'wikibase-add',
1055+
'wikibase-addstatement',
10551056
'wikibase-addqualifier',
10561057
'wikibase-addreference',
10571058
'wikibase-cancel',

repo/resources/wikibase.wbui2025/store/editStatementsStore.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ const useEditStatementsStore = defineStore( 'editStatements', {
402402
}
403403
return true;
404404
},
405+
createdStatementIds: ( state ) => state.createdStatements,
405406
/**
406407
* @return {boolean|null} True or false if the statements are known to be different or the same
407408
* as the saved version in the savedStatementsStore, or null if it is not known

repo/resources/wikibase.wbui2025/wikibase.wbui2025.addQualifier.vue

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
<template>
2-
<wikibase-wbui2025-modal-overlay>
3-
<div class="wikibase-wbui2025-add-qualifier">
4-
<div class="wikibase-wbui2025-add-qualifier-heading">
5-
<div class="wikibase-wbui2025-add-qualifier-close">
6-
<cdx-button
7-
:aria-label="$i18n( 'wikibase-cancel' )"
8-
weight="quiet"
9-
@click="$emit( 'hide' )"
10-
>
11-
<cdx-icon :icon="cdxIconClose"></cdx-icon>
12-
</cdx-button>
13-
</div>
14-
<h2>{{ $i18n( 'wikibase-addqualifier' ) }}</h2>
15-
</div>
2+
<wikibase-wbui2025-modal-overlay
3+
:header="$i18n( 'wikibase-addqualifier' )"
4+
minimal-style
5+
hide-footer
6+
@hide="$emit( 'hide' )"
7+
>
8+
<template #content>
169
<div class="wikibase-wbui2025-add-qualifier-form">
1710
<cdx-button
1811
action="progressive"
@@ -45,14 +38,14 @@
4538
>
4639
</cdx-lookup>
4740
</div>
48-
</div>
41+
</template>
4942
</wikibase-wbui2025-modal-overlay>
5043
</template>
5144

5245
<script>
5346
const { defineComponent } = require( 'vue' );
5447
const { CdxButton, CdxIcon, CdxLookup, CdxTextInput } = require( '../../codex.js' );
55-
const { cdxIconCheck, cdxIconClose } = require( './icons.json' );
48+
const { cdxIconCheck } = require( './icons.json' );
5649
const supportedDatatypes = require( './supportedDatatypes.json' );
5750
const { searchByDatatype, transformSearchResults } = require( './api/commons.js' );
5851
@@ -73,7 +66,6 @@ module.exports = exports = defineComponent( {
7366
data() {
7467
return {
7568
cdxIconCheck,
76-
cdxIconClose,
7769
selectedPropertyId: null,
7870
selectedPropertyDatatype: null,
7971
snakValue: '',
@@ -169,15 +161,6 @@ module.exports = exports = defineComponent( {
169161
<style lang="less">
170162
@import 'mediawiki.skin.variables.less';
171163
172-
.wikibase-wbui2025-add-qualifier {
173-
display: flex;
174-
flex-direction: column;
175-
align-items: flex-start;
176-
gap: @spacing-65;
177-
width: 100%;
178-
height: 100%;
179-
}
180-
181164
.wikibase-wbui2025-add-qualifier-heading {
182165
align-self: stretch;
183166
padding: @spacing-100 @spacing-100 @spacing-200;

0 commit comments

Comments
 (0)