Daniel Werner has uploaded a new change for review.
https://gerrit.wikimedia.org/r/67870
Change subject: Added tests for SiteLinksEditTool value row insertion behavior
......................................................................
Added tests for SiteLinksEditTool value row insertion behavior
When a new value row gets inserted into the SiteLinksEditTool, it will first be
inserted into the
tfoot part of the table, so the row won't be affected by table sorting. After
the value got saved,
it is supposed to be moved into the tbody section. This behavior is now ensured
by these test.
Change-Id: Iad16410be423f3af88dead38fbb51a127a4b4a52
---
M lib/tests/qunit/wikibase.ui.SiteLinksEditTool.tests.js
1 file changed, 94 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/70/67870/1
diff --git a/lib/tests/qunit/wikibase.ui.SiteLinksEditTool.tests.js
b/lib/tests/qunit/wikibase.ui.SiteLinksEditTool.tests.js
index 6a97383..53ec483 100644
--- a/lib/tests/qunit/wikibase.ui.SiteLinksEditTool.tests.js
+++ b/lib/tests/qunit/wikibase.ui.SiteLinksEditTool.tests.js
@@ -53,6 +53,27 @@
} ) );
/**
+ * Executes assertions testing how many values are currently in a
certain part of the
+ * SiteLinksEditTool's subject table.
+ *
+ * @param {QUnit.assert} assert
+ * @param {wb.ui.SiteLinksEditTool} subject
+ * @param {Object} definition The Table's part (e.g. "tbody" or "tfoot"
as key, the expected
+ * number of values in that section as number.
+ * @param {string} testStepDescription
+ */
+ function assertValuesInTableSections( assert, subject, definition,
testStepDescription ) {
+ $.each( definition, function( section, expected ) {
+ var queryPath = section + '
.wb-ui-propertyedittool-editablevalue';
+ assert.strictEqual(
+ subject.getSubject().find( queryPath ).length,
+ expected,
+ expected + ' value(s) in ' + section + ' ' +
testStepDescription
+ );
+ } );
+ }
+
+ /**
* Allows to enter a value into the SiteLinksEditTool which can then be
saved by calling
* stopEditing( true ) on the returned EditableValue. This is necessary
because of some ugly
* fake API requests have to be mocked to do this.
@@ -181,6 +202,79 @@
);
} );
+ QUnit.test( 'no value rows in table initially', function( assert ) {
+ assert.strictEqual(
+ this.subject.getValues( true ).length,
+ 0,
+ 'no values or pending values in edit tool initially'
+ );
+
+ assertValuesInTableSections(
+ assert,
+ this.subject,
+ { thead: 0, tbody: 0, tfoot: 0 },
+ 'initially'
+ );
+ } );
+
+ QUnit.test( 'pending value gets moved from tfoot to tbody after it got
saved', function( assert ) {
+ var subject = this.subject;
+
+ assertValuesInTableSections(
+ assert,
+ subject,
+ { tbody: 0, tfoot: 0 },
+ 'initially'
+ );
+
+ hackyValueInsertionAndSave( subject, [ 'dewiki', 'Berlin' ],
'dewiki' );
+
+ assertValuesInTableSections(
+ assert,
+ subject,
+ { tbody: 1, tfoot: 0 },
+ 'after entering and saving first value'
+ );
+
+ hackyValueInsertionAndSave( subject, [ 'enwiki', 'London' ],
'enwiki' );
+
+ assertValuesInTableSections(
+ assert,
+ subject,
+ { tbody: 2, tfoot: 0 },
+ 'after saving second value'
+ );
+ } );
+
+ QUnit.test( 'pending value gets removed from tfoot after cancelling
value insertion', function( assert ) {
+ var subject = this.subject;
+
+ assertValuesInTableSections(
+ assert,
+ subject,
+ { tbody: 0, tfoot: 0 },
+ 'initially'
+ );
+
+ var newValue = hackyValueInsertion( this.subject, [ 'dewiki',
'Berlin' ], 'dewiki' );
+
+ assertValuesInTableSections(
+ assert,
+ subject,
+ { tbody: 0, tfoot: 1 },
+ 'after inserting pending value'
+ );
+
+ newValue.stopEditing( false );
+
+ assertValuesInTableSections(
+ assert,
+ subject,
+ { tbody: 0, tfoot: 0 },
+ 'after cancelling pending value insertion'
+ );
+ } );
+
QUnit.test( 'adding a new editable site link', function( assert ) {
assert.ok(
--
To view, visit https://gerrit.wikimedia.org/r/67870
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iad16410be423f3af88dead38fbb51a127a4b4a52
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Werner <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits