Behaviour SwRS-MDOKFSTUDIO-REVIEW-009
A changed block shows as a side-by-side diff with its word marks, cut by line hunks, and a malformed baseline message is dropped
While the side-by-side diff is on and a baseline for the current render is held, the page SHALL replace each block that changed since the last commit by a card with the rendered block at the last commit on the left and the rendered current block on the right, keep on the left of a block that lies inside one hunk only the block at the last commit that shares the most words with it (each kept by one block at most) and show the other blocks at the last commit of that hunk as removed blocks in their source order, mark the removed words on the left and the added words on the right, leave the left empty for an added block and show a removed block with an empty right side, leave unchanged blocks as they are, and show the original blocks again when the diff goes off or the baseline is stale; the baseline message previewBaselineDiff is accepted only with an html string of at most 20 MiB and at most 100 000 hunks of non-negative integer lines whose ends are not more than one before their starts, for the current render, and any other is dropped; the removed and added words are the character ranges found by comparing the block at the last commit with the current block word by word, consecutive changed words merged into one range, all words of both texts being marked when the comparison would exceed 4 000 000 word pairs; the changed blocks are found from line hunks that give the last-commit lines and the current lines as 1-based inclusive ranges, with an empty side for lines only added or only removed, merged with the hunk next to them when only blank lines separate them, ignoring differences of line endings, and reported as one hunk when more than 20 000 lines differ or more than 2000 edits are needed.
Scenarios 8
The situations the tests check; open one to read it.
nominalCards for changed blocks
| Input | Outcome |
|---|
| A block with changed words | a card of two columns: the block at the last commit on the left with the removed words marked, the current block on the right with the added words marked; the original block is hidden |
| An added block | a card with an empty left side |
| A removed block | a card with the removed block on the left and an empty right side, in the place of the removal |
| A list or table with a changed item or row | one card with the whole list or table on both sides |
| A paragraph removed next to an edited one (one hunk holds both) | the edited paragraph is a card with its own text at the last commit on the left (the one that shares the most words with it); the removed paragraph is a card with an empty right side, before or after it in source order |
| Two blocks inside one hunk that holds one block at the last commit | the block that shares the most words with it keeps it on its left; the other is an added block |
| An unchanged block | shown as it is, no card |
boundaryGoing back
| Input | Outcome |
|---|
| The diff switched off, or edit mode on | the cards go away and the original blocks show again |
| A baseline of an older render than the page content | no card is made |
| A baseline whose hunks are empty | no card is made |
| The page content is patched | the cards are made again from the held baseline when it matches the new content |
nominalA well-formed baseline message
| Input | Outcome |
|---|
| previewBaselineDiff with an html string and hunks of non-negative integers whose ends are at least one before their starts | accepted for the current render |
refusalDropped baseline messages
| Input | Outcome |
|---|
| previewBaselineDiff with a non-string html, no hunks, a negative or fractional line, an end more than one before its start, or a null hunk | dropped |
| An html of more than 20 MiB, or more than 100 000 hunks | dropped |
| A baseline message of a stale render | dropped |
nominalChanged words of a card
| Input | Outcome |
|---|
| Two identical texts | no range on either side |
| One word replaced | that word is removed on the old side and added on the new side |
| Several consecutive words replaced | one range per run, the space between them included |
| Separate changes | separate ranges |
| Words only inserted or only deleted | ranges on one side only |
| Texts that come in pieces (text nodes) | compared as one text in which a piece boundary separates words, the ranges given inside their piece |
boundaryWord diff size limit
| Input | Outcome |
|---|
| Texts of more than 4 000 000 word pairs | all words of both texts are marked |
nominalHunks with both sides
| Input | Outcome |
|---|
| Two identical texts, or texts that differ only by line endings | no hunk |
| One line modified | one hunk with the same line on both sides |
| Lines added | a hunk whose base side is empty (base end one before base start) |
| Lines removed | a hunk whose current side is empty (end one before start) |
| Two separate edits | two hunks |
| Lines removed and added before the next common line | one hunk |
| Lines removed (or added) next to a changed line, only blank lines between them on both sides | one hunk that holds both and the blank lines between them |
| Lines removed (or added) next to a changed line, a heading or any other non-blank line between them | two hunks |
| Two changed lines (both sides not empty), only blank lines between them | two hunks |
boundaryHunk size limits and block mapping
| Input | Outcome |
|---|
| More than 20 000 differing lines, or more than 2000 edits | one hunk covers the whole differing middle |
| A block of the current text and the hunks | the block is changed when it meets a hunk with current lines or holds a removal; its base lines are the base side of the hunk it lies in, or its own lines shifted by the hunks before it |