r102564 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102563‎ | r102564 | r102565 >
Date:20:24, 9 November 2011
Author:catrope
Status:deferred
Tags:
Comment:
Add test cases for inserting a paragraph break (</p><p>) in the middle of a paragraph. Interestingly, committing this insertion actually works, but rolling it back doesn't.
Modified paths:
  • /trunk/extensions/VisualEditor/tests/es/es.DocumentModel.test.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/tests/es/es.DocumentModel.test.js
@@ -547,9 +547,13 @@
548548 );
549549 } );
550550
551 -test( 'es.DocumentModel.commit, es.DocumentModel.rollback', 12, function() {
 551+test( 'es.DocumentModel.commit, es.DocumentModel.rollback', /*18*/ 15, function() {
552552 var documentModel = es.DocumentModel.newFromPlainObject( esTest.obj );
553553
 554+ // FIXME: These tests shouldn't use prepareFoo() because those functions
 555+ // normalize the transactions they create and are tested separately.
 556+ // We should be creating transactions directly and feeding those into
 557+ // commit()/rollback() --Roan
554558 var elementAttributeChange = documentModel.prepareElementAttributeChange(
555559 0, 'set', 'test', 1
556560 );
@@ -717,4 +721,73 @@
718722 ],
719723 'rollback keeps model tree up to date with removals'
720724 );
 725+
 726+ var paragraphBreak = documentModel.prepareInsertion( 2, [ { 'type': '/paragraph' }, { 'type': 'paragraph' } ] );
 727+
 728+ // Test 13
 729+ documentModel.commit( paragraphBreak );
 730+ deepEqual(
 731+ documentModel.getData( new es.Range( 0, 7 ) ),
 732+ [
 733+ { 'type': 'paragraph' },
 734+ 'a',
 735+ { 'type': '/paragraph' },
 736+ { 'type': 'paragraph' },
 737+ ['b', { 'type': 'textStyle/bold', 'hash': '#textStyle/bold' }],
 738+ ['c', { 'type': 'textStyle/italic', 'hash': '#textStyle/italic' }],
 739+ { 'type': '/paragraph' }
 740+ ],
 741+ 'commit applies an insertion transaction that splits the paragraph'
 742+ );
 743+
 744+ // Test 14
 745+ deepEqual(
 746+ documentModel.getChildren()[0].getContent(),
 747+ ['a'],
 748+ 'commit keeps model tree up to date with paragraph split (paragraph 1)'
 749+ );
 750+
 751+ // Test 15
 752+ deepEqual(
 753+ documentModel.getChildren()[1].getContent(),
 754+ [
 755+ ['b', { 'type': 'textStyle/bold', 'hash': '#textStyle/bold' }],
 756+ ['c', { 'type': 'textStyle/italic', 'hash': '#textStyle/italic' }]
 757+ ],
 758+ 'commit keeps model tree up to date with paragraph split (paragraph 2)'
 759+ );
 760+
 761+ /* FIXME broken
 762+ // Test 16
 763+ documentModel.rollback( paragraphBreak );
 764+ deepEqual(
 765+ documentModel.getData( new es.Range( 0, 5 ) ),
 766+ [
 767+ { 'type': 'paragraph' },
 768+ 'a',
 769+ ['b', { 'type': 'textStyle/bold', 'hash': '#textStyle/bold' }],
 770+ ['c', { 'type': 'textStyle/italic', 'hash': '#textStyle/italic' }],
 771+ { 'type': '/paragraph' }
 772+ ],
 773+ 'rollback reverses the effect of a paragraph split on the content'
 774+ );
 775+
 776+ // Test 17
 777+ deepEqual(
 778+ documentModel.getChildren()[0].getContent(),
 779+ [
 780+ 'a',
 781+ ['b', { 'type': 'textStyle/bold', 'hash': '#textStyle/bold' }],
 782+ ['c', { 'type': 'textStyle/italic', 'hash': '#textStyle/italic' }]
 783+ ],
 784+ 'rollback keeps model tree up to date with paragraph split (paragraphs are merged back)'
 785+ );
 786+
 787+ // Test 18
 788+ deepEqual(
 789+ documentModel.getChildren()[1].getElementType(),
 790+ 'table',
 791+ 'rollback keeps model tree up to date with paragraph split (table follows the paragraph)'
 792+ );
 793+ */
721794 } );

Follow-up revisions

RevisionCommit summaryAuthorDate
r102663Rewrite the remove() function in es.DocumentModel.operations such that the te...catrope15:50, 10 November 2011

Status & tagging log