Esanders has uploaded a new change for review.

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

Change subject: Ensure all test documents have an internal list
......................................................................

Ensure all test documents have an internal list

Also change test that was inserting paragraph after
the internal list to insert before it.

Change-Id: Ia96702670ab4dbabab870b179cd52c4279acc57b
---
M tests/dm/ve.dm.Transaction.test.js
M tests/dm/ve.dm.TransactionProcessor.test.js
M tests/dm/ve.dm.example.js
3 files changed, 30 insertions(+), 22 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor 
refs/changes/20/277820/1

diff --git a/tests/dm/ve.dm.Transaction.test.js 
b/tests/dm/ve.dm.Transaction.test.js
index 3be861b..a60e882 100644
--- a/tests/dm/ve.dm.Transaction.test.js
+++ b/tests/dm/ve.dm.Transaction.test.js
@@ -54,10 +54,10 @@
                complexTableDoc = ve.dm.example.createExampleDocument( 
'complexTable' ),
                listWithMetaDoc = ve.dm.example.createExampleDocument( 
'listWithMeta' ),
                doc2 = new ve.dm.Document(
-                       ve.dm.example.preprocessAnnotations( [ { type: 
'paragraph' }, { type: '/paragraph' } ] )
+                       ve.dm.example.preprocessAnnotations( [ { type: 
'paragraph' }, { type: '/paragraph' }, { type: 'internalList' }, { type: 
'/internalList' } ] )
                ),
                doc3 = new ve.dm.Document(
-                       ve.dm.example.preprocessAnnotations( [ { type: 
'paragraph' }, 'F', 'o', 'o', { type: '/paragraph' } ] )
+                       ve.dm.example.preprocessAnnotations( [ { type: 
'paragraph' }, 'F', 'o', 'o', { type: '/paragraph' }, { type: 'internalList' }, 
{ type: '/internalList' } ] )
                ),
                cases = {
                        'paragraph before first element': {
@@ -74,16 +74,17 @@
                                ]
                        },
                        'paragraph after last element': {
-                               args: [ doc, 63, [ { type: 'paragraph' }, '1', 
{ type: '/paragraph' } ] ],
+                               args: [ doc, 61, [ { type: 'paragraph' }, '1', 
{ type: '/paragraph' } ] ],
                                ops: [
-                                       { type: 'retain', length: 63 },
+                                       { type: 'retain', length: 61 },
                                        {
                                                type: 'replace',
                                                remove: [],
                                                insert: [ { type: 'paragraph' 
}, '1', { type: '/paragraph' } ],
                                                insertedDataOffset: 0,
                                                insertedDataLength: 3
-                                       }
+                                       },
+                                       { type: 'retain', length: 2 }
                                ]
                        },
                        'split paragraph': {
@@ -292,7 +293,7 @@
                                                insertedDataOffset: 0,
                                                insertedDataLength: 8
                                        },
-                                       { type: 'retain', length: 1 }
+                                       { type: 'retain', length: 3 }
                                ]
                        },
                        'inserting three paragraphs into a document with just 
an empty paragraph': {
@@ -306,7 +307,7 @@
                                                insertedDataOffset: 0,
                                                insertedDataLength: 13
                                        },
-                                       { type: 'retain', length: 1 }
+                                       { type: 'retain', length: 3 }
                                ]
                        },
                        'inserting one paragraph into empty paragraph moves 
insertion before': {
@@ -319,7 +320,7 @@
                                                insertedDataOffset: 0,
                                                insertedDataLength: 5
                                        },
-                                       { type: 'retain', length: 2 }
+                                       { type: 'retain', length: 4 }
                                ],
                                range: new ve.Range( 0, 5 )
                        },
@@ -333,7 +334,8 @@
                                                insert: [ { type: 'paragraph' 
}, 'B', 'A', 'R', { type: '/paragraph' } ],
                                                insertedDataOffset: 0,
                                                insertedDataLength: 5
-                                       }
+                                       },
+                                       { type: 'retain', length: 2 }
                                ],
                                range: new ve.Range( 5, 10 )
                        },
@@ -348,7 +350,7 @@
                                                insertedDataOffset: 1,
                                                insertedDataLength: 5
                                        },
-                                       { type: 'retain', length: 3 }
+                                       { type: 'retain', length: 5 }
                                ],
                                range: new ve.Range( 3, 8 )
                        },
@@ -397,8 +399,7 @@
                                                insertedDataOffset: 0,
                                                insertedDataLength: 1
                                        },
-                                       { type: 'retain', length: 8 },
-                                       { type: 'retainMetadata', length: 1 }
+                                       { type: 'retain', length: 10 }
                                ]
                        }
                        // TODO test cases for unclosed openings
@@ -1643,7 +1644,8 @@
                                        { type: 'replace',
                                                remove: [ { type: '/listItem' 
}, { type: '/list' } ],
                                                insert: []
-                                       }
+                                       },
+                                       { type: 'retain', length: 2 }
                                ]
                        },
                        'replaces a table with a list': {
@@ -1744,7 +1746,7 @@
                                                insert: 
ve.dm.MetaLinearData.static.merge( listMetaDoc.getMetadata().slice( 10, 12 ) )[ 
0 ],
                                                remove: []
                                        },
-                                       { type: 'retainMetadata', length: 1 }
+                                       { type: 'retain', length: 2 }
                                ]
                        },
                        'checks integrity of unwrapOuter parameter': {
@@ -2257,7 +2259,8 @@
                                                remove: [],
                                                insert: [ element ]
                                        },
-                                       { type: 'retainMetadata', length: 1 }
+                                       { type: 'retainMetadata', length: 1 },
+                                       { type: 'retain', length: 2 }
                                ]
                        },
                        'inserting trailing metadata (2)': {
@@ -2269,7 +2272,8 @@
                                                type: 'replaceMetadata',
                                                remove: [],
                                                insert: [ element ]
-                                       }
+                                       },
+                                       { type: 'retain', length: 2 }
                                ]
                        }
                };
@@ -2322,7 +2326,8 @@
                                                        }
                                                ],
                                                insert: []
-                                       }
+                                       },
+                                       { type: 'retain', length: 2 }
                                ]
                        },
                        'checks metadata at offset is non-empty': {
@@ -2371,7 +2376,8 @@
                                                type: 'replaceMetadata',
                                                remove: [ 
listWithMetaDoc.metadata.getData( 12 )[ 0 ] ],
                                                insert: [ newElement ]
-                                       }
+                                       },
+                                       { type: 'retain', length: 2 }
                                ]
                        },
                        'checks offset is in bounds': {
diff --git a/tests/dm/ve.dm.TransactionProcessor.test.js 
b/tests/dm/ve.dm.TransactionProcessor.test.js
index da02abb..4dd588c 100644
--- a/tests/dm/ve.dm.TransactionProcessor.test.js
+++ b/tests/dm/ve.dm.TransactionProcessor.test.js
@@ -585,7 +585,7 @@
                                        ] ]
                                ],
                                expected: function ( data ) {
-                                       ve.batchSplice( data, data.length - 2, 
0, [
+                                       ve.batchSplice( data, data.length - 4, 
0, [
                                                {
                                                        type: 'alienMeta',
                                                        originalDomElements: $( 
'<meta property="fourteen" />' ).toArray()
@@ -607,7 +607,7 @@
                                        ] ]
                                ],
                                expected: function ( data ) {
-                                       ve.batchSplice( data, data.length, 0, [
+                                       ve.batchSplice( data, data.length - 2, 
0, [
                                                {
                                                        type: 'alienMeta',
                                                        originalDomElements: $( 
'<meta property="fourteen" />' ).toArray()
@@ -624,7 +624,7 @@
                                        [ 'newFromMetadataRemoval', 12, new 
ve.Range( 0, 1 ) ]
                                ],
                                expected: function ( data ) {
-                                       ve.batchSplice( data, data.length - 2, 
2, [] );
+                                       ve.batchSplice( data, data.length - 4, 
2, [] );
                                }
                        },
                        'preserves trailing metadata': {
diff --git a/tests/dm/ve.dm.example.js b/tests/dm/ve.dm.example.js
index 17fff07..dc5ab67 100644
--- a/tests/dm/ve.dm.example.js
+++ b/tests/dm/ve.dm.example.js
@@ -847,7 +847,9 @@
                type: 'alienMeta',
                originalDomElements: $( '<meta property="thirteen" />' 
).toArray()
        },
-       { type: '/alienMeta' }
+       { type: '/alienMeta' },
+       { type: 'internalList' },
+       { type: '/internalList' }
 ];
 
 ve.dm.example.mergedCellsHtml =

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia96702670ab4dbabab870b179cd52c4279acc57b
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>

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

Reply via email to