Catrope has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/74105


Change subject: Fix ordering of store items in converter tests
......................................................................

Fix ordering of store items in converter tests

In the DomFromData tests, we put the provided storeItems in the store
first, then run preprocessAnnotations (which puts annotations in the
store). However, in DataFromDom we ran preprocessAnnotations first
(which puts annotations in the store), then ran getDataFromDom (which
is expected to put the asserted store items in the store). Because the
order was reversed between these two tests, it was impossible to write
a test for an annotation whose toDataElement function adds to the store.

Fix this by reordering the operations in the DataFromDom test, doing the
conversion first and only then running preprocessAnnotations on the
expected data. This preprocessAnnotations call will not write to the store
if the test passes, because all annotations in the expected data should
already have been put in the store by the conversion.

Change-Id: I8f741d96fe12590fd711542794570fb95b1132d0
---
M modules/ve/test/ve.test.utils.js
1 file changed, 6 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor 
refs/changes/05/74105/1

diff --git a/modules/ve/test/ve.test.utils.js b/modules/ve/test/ve.test.utils.js
index 9811424..97039b2 100644
--- a/modules/ve/test/ve.test.utils.js
+++ b/modules/ve/test/ve.test.utils.js
@@ -46,7 +46,7 @@
 };
 
 ve.test.utils.runGetDataFromDomTests = function( assert, cases ) {
-       var msg, doc, store, internalList, i, length, hash, n = 0;
+       var msg, doc, store, internalList, i, length, hash, data, n = 0;
 
        // TODO: this is a hack to make normal heading/preformatted
        // nodes the most recently registered, instead of the MW versions
@@ -68,14 +68,11 @@
                        doc = new ve.dm.Document( [] );
                        store = doc.getStore();
                        internalList = doc.getInternalList();
+                       data = ve.dm.converter.getDataFromDom(
+                               ve.createDocumentFromHtml( cases[msg].html ), 
store, internalList
+                       ).getData();
                        ve.dm.example.preprocessAnnotations( cases[msg].data, 
store );
-                       assert.deepEqualWithDomElements(
-                               ve.dm.converter.getDataFromDom(
-                                       ve.createDocumentFromHtml( 
cases[msg].html ), store, internalList
-                               ).getData(),
-                               cases[msg].data,
-                               msg
-                       );
+                       assert.deepEqualWithDomElements( data, cases[msg].data, 
msg );
                        // check storeItems have been added to store
                        if ( cases[msg].storeItems ) {
                                for ( i = 0, length = 
cases[msg].storeItems.length; i < length; i++ ) {
@@ -101,7 +98,7 @@
 
        for ( msg in cases ) {
                store = new ve.dm.IndexValueStore();
-               // load storeItems into store
+               // Load storeItems into store
                if ( cases[msg].storeItems ) {
                        for ( i = 0, length = cases[msg].storeItems.length; i < 
length; i++ ) {
                                store.index( cases[msg].storeItems[i].value, 
cases[msg].storeItems[i].hash );

-- 
To view, visit https://gerrit.wikimedia.org/r/74105
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8f741d96fe12590fd711542794570fb95b1132d0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to