Repository navigation
test(docx): fail Word's restyle scenario when text is left without room for it - #854
Merged
Merged
Conversation
…oo short for it restyle-body-through-normal checked only that the body's letters grew with Normal by 2pt. An exported DOCX sets most paragraphs on exact lines, which keep their height when the letters grow, so Word overlaps the lines and cuts the letters' tops on screen; the scenario passed every corpus document regardless. The scenario now records each paragraph's largest letters and exact line before the restyle, and fails when a paragraph whose letters grew keeps an exact line that did not grow with them and now stands below 1.15 of their size, or sits in a row of exact height. It is judged by the change, not by an absolute share: the page sets many exact lines tighter than 1.1 of their letters before any edit, and that is its leading. A scenario a document has nothing to edit for is recorded N/A with what the document lacks instead of disappearing from the JSON, N/A does not fail the run, and a run of one scenario writes each document's results as a list.
…ne share The restyle scenario read only the main story, so a header or footer line set at the body size on an exact line, or held in a frame of exact height, and a text box its text just fills, could be cut by the restyle while the scenario passed - hidden today only because every corpus document fails in its body. It now reads every story the restyle reaches: the main text, each section's own headers and footers, and the text drawings hold, keyed by story and place so the reopened document matches. A grown paragraph fails on exact lines shorter than 1.1 of its letters - the share add-a-page already holds typed text to, replacing a second, stricter 1.15 - or in a row or frame of exact height, and a drawing whose text newly overflows fails too; the detail counts each and names the first of each. An edit reads as having nothing to edit only when it returns $false, not 0; drawings-follow-text is N/A when no drawing stands beside text; the N/A reasons count characters, as Find-BodyParagraph does.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The restyle scenario passed documents whose text Word visibly breaks after the restyle.
restyle-body-through-normalinscripts/docx-visual/edit-protocol-corpus.ps1checked one thing: that the body's letters grew with Normal by 2pt. It passed every corpus document.An exported DOCX sets almost every paragraph on an exact line (
w:lineRule="exact"), and an exact line keeps its height when the letters grow. After Normal +2pt, Word setscv-editorial_blue's profile in 11.5pt letters on the 10.3pt lines its 9.5pt letters had. The lines overlap, and on screen Word also cuts the letters' tops. Word's PDF export does not show the cut, so the fidelity gate cannot catch it either.What changed
Get-StoryParagraphscollects every paragraph Normal reaches: the main text, each section's own headers and footers, and the text drawings hold. Each is keyed by story and place, so the reopened document gives the same keys.Before the edit it records each paragraph's largest letters (
Get-LargestLetters) and the drawings whose text already overflows (Get-OverflowingFrames).The scenario fails when a paragraph whose letters grew:
Get-HeldBox);or when a drawing's text newly overflows it.
The detail counts each kind and names the first of each, for example
'Platform engineer with 1' (body 8) 9.5 -> 11.5pt letters on 10.3pt exact lines.$EXACT_LINE_SHARE, whichadd-a-pageuses for typed text.cv-editorial_blueare. That spacing is the page's leading, not a cut the edit made.N/Awith a reason from$NOT_APPLICABLE, instead of vanishing fromedit-protocol-corpus.json.N/Adoes not fail the run.[bool] $false. PowerShell treats0 -eq $falseas true, so an edit ending on a call that returns 0 would otherwise turn intoN/A.drawings-follow-textisN/Awhen no drawing stands beside text, for example when the only drawings are page backgrounds.Invoke-Protocol's result is wrapped in@(...), because PowerShell hands a one-element array back as its element.Testsentry describe the checks.Verification
Known-answer documents in Word 16.0 (16.0.20430), all scenarios:
restyleheader 1.1 1(12 → 14pt on 14.4pt lines) and the overflowingdrawing 1cv-editorial_bluereceipt-modernOn the exported documents the other scenarios keep the statuses an earlier run of the protocol gave them, including
receipt-modern'sadd-a-pageFAIL: text typed at its end goes into its closing table. The table, list and drawing scenarios are recordedN/Awhere a document has none.Full corpus, 62 documents exported at
7c9808c7c,-Scenario restyle-body-through-normal:MintEditorialandMintEditorialLetterpass: none of their exact lines falls below 1.1×.scenariosis a list.Documentation guards:
./mvnw -B -ntp test -pl :graph-compose-core -Dtest='com.demcha.documentation.**'→ BUILD SUCCESS, 166 tests../mvnw -B -ntp test -f qa/pom.xml -Dtest='com.demcha.documentation.**'→ BUILD SUCCESS, 28 tests.No Java, POM or workflow file changes, so the full reactor gate was not run.
Lane: test — the local Word editing protocol (
scripts/docx-visual) and its docs. No backend or public API change.