Repository navigation
Add document-level tests for the Word export - #1271
Open
jasonleenaylor wants to merge 1 commit into
Open
jasonleenaylor wants to merge 1 commit into
jasonleenaylor wants to merge 1 commit into
Conversation
Add eight tests that call LcmWordGenerator.SavePublishedDocx and assert with XPath on the parts of the saved .docx file: the body, sections, page headers, styles, numbering, the embedded picture, and settings. They cover a left-to-right dictionary, a right-to-left vernacular, a right-to-left analysis language in a left-to-right dictionary, and a reversal index. The only existing tests that reach SavePublishedDocx are skipped unless FW_RUN_MANUAL_DOCX_EXPORT_TESTS is set. SavePublishedDocx sets the static LcmWordGenerator.IsBidi, and nothing reset it between tests. Its setter becomes internal so the fixture's Setup can reset it, and the fixture is marked NonParallelizable. LcmWordGeneratorTests becomes a partial class so the new tests share its fixture. Co-Authored-By: Claude <noreply@anthropic.com>
NUnit Tests 1 files ±0 1 suites ±0 12m 18s ⏱️ +48s For more details on these failures, see this check. Results for commit 60072b1. ± Comparison against base commit c5da1ae. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1271 +/- ##
==========================================
+ Coverage 40.60% 41.14% +0.54%
==========================================
Files 1601 1603 +2
Lines 360728 360816 +88
Branches 42239 42246 +7
==========================================
+ Hits 146474 148467 +1993
+ Misses 184615 182933 -1682
+ Partials 29639 29416 -223
🚀 New features to boost your workflow:
|
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.
Start here:
Src/xWorks/xWorksTests/LcmWordGeneratorDocumentTests.cs, the eight tests at the bottom of the file. Each test name says which document it saves and what it checks.What it does
Adds eight tests that call
LcmWordGenerator.SavePublishedDocx, open the saved .docx, and assert on its XML parts with XPath. They cover a left-to-right dictionary, a right-to-left vernacular, a right-to-left analysis language in a left-to-right dictionary, and a reversal index. This is item 0.O-0 of the plan in #1259.Why it is needed
No test reached
SavePublishedDocxin a normal run. The two that call it are skipped unlessFW_RUN_MANUAL_DOCX_EXPORT_TESTS=1. The plan reworks the style resolver, the image reader and the writer's static state. These tests are how those changes are shown not to alter the saved document.Where to look
LcmWordGenerator.IsBidigets aninternalsetter so the fixture'sSetupcan reset it. Without the reset, the right-to-left test left ittruefor every later test in the process.w:rtlto a run only when the entry style is right-to-left (LcmWordGenerator.cs:2841).SavePublishedDocx_RightToLeftAnalysisInLeftToRightDictionary_HasNoRightToLeftMarksrecords that Arabic glosses in a left-to-right dictionary get no mark. @mark-sil, is that intended?w:ind/@w:left), so they hold whether the writer emits onew:indelement or three.[NonParallelizable], because the writer keeps the document it is building in static fields.Not here
Verification
LcmWordGeneratorTests: 40 total, 38 passed, 2 skipped (the manual .docx tests).xWorksTests: 2,026 total, 2,024 passed, 2 skipped.main. None of them touch these files, and the tests were not rerun on top of them.Next: approve, or say that the right-to-left behaviour above is a defect and I will file it.
Reading this a year from now -- start here
These tests were written before the Word writer moved to liblcm. They pin what the writer saved at that time, including behaviour nobody had decided was correct. A test here that fails after a deliberate change to Word output is expected to be updated, not worked around.
What each test pins
w:rtlw:bidion every section and on the entry style only,w:rtlon the Hebrew runs and no others, complex-script font propertiesw:rtlorw:bidiAssertions that depend on thread timing (numbering ids, style order) hold in any order.
Paths not taken
OpenXmlValidatoron each document and allowed 13 known kinds of error. "This document has exactly these defects" is not a property anyone intends, and the check could not tell a fixed error from a present one. The errors are in LT-22927. The assertion to add once they are fixed is that the validator reports none.ind left=720and compared arrays. That pinned the number ofw:indelements and hid attribute ordering in a helper.w:indelements per style, and the typedIndentationproperty returns only the first. Reading the file with the library that wrote it also makes the tests less independent.Preflight review details
Code Review Summary
Branch: word-export-document-tests
Base: main (merge base 19f02c1)
Date: 2026-12-01
Review model: Claude Fable 5 (Claude Code)
Files changed: 3
Overview
The branch adds eight document-level tests for the Word export. Each test
calls
LcmWordGenerator.SavePublishedDocx, opens the saved .docx, and assertson its XML parts with XPath. This is item 0.O-0 of the plan to move dictionary
configuration to liblcm (PR #1259). The tests exist so that the Word writer
rework in later items (0.L, 0.O-1, 0.O-2) can be shown not to change output.
The review found no failing assertion. It found five Important and four Minor
points about how robust the tests were. Six led to changes during the review,
two were left by decision, and one was dropped on evidence. The validator
check was taken out of the branch and filed as LT-22927.
Contract/API Changes
LcmWordGenerator.IsBidi: the setter changed fromprivatetointernalso the test fixture can reset it. No behaviour change. xWorksTests already
has
InternalsVisibleTo.No other production code changed.
Findings
Critical - Must address before merge
None.
Important - Should address before merge
SaveAndReadDocxused a fixed temp folder name, shared by everytest run on the machine, so two worktrees could delete each other's files.
(fixed during review:
Path.GetRandomFileName(), as other xWorks testsdo)
SavePublishedDocxassignsMasterFragment,s_styleCollectionandIsBidi.IsBidistayedtrueafter the right-to-left test, and thefixture could not run in parallel with itself. (fixed during review:
SetupresetsIsBidinext toClearStyleCollection(); the fixture is[NonParallelizable]; the setter isinternal)StylePropertiesreduced style XML to strings such as"ind left=720"and compared arrays of them at 14 call sites. It pinnedthe writer's element layout and hid attribute ordering in the helper.
(fixed during review: removed; five XPath assertion helpers plus
AssertPropertyCountreplace it)defects. It was checked one way, used one list for four documents, and
matched the SDK's description text. (fixed during review: all validator
code removed from the branch; the 13 kinds of error are filed as LT-22927)
The right-to-left analysis test asserts that Arabic glosses in a(Author: keep the test as a record of current behaviour and askleft-to-right dictionary get no
w:rtlmark, which may be a writerdefect.
Mark on the PR whether it is intended.)
Minor - Consider
ran first, so a left-to-right document could differ by run order. (fixed
during review: created with
WritingSystemManager.GetOrSet, which does notadd it to the project's vernacular list)
review: rewrapped by hand)
The new helpers overlap the manual-docx helpers, and
(Author: leave. A test of saved output compares against"EvenPages","OddPages"and"Letter Heading"repeatWordStylesGeneratorconstants.
literal text, and merging helpers means editing existing tests.)
Five tests regenerate the same left-to-right document.(Dropped onevidence: each repeated save takes about 30 ms.)
Required Validation / Evidence
Run on 2026-12-01 after the last in-review change, with
-CommentHygiene -TokenHygiene:./build.ps1 -BuildTests -SkipNative: succeeded, 0 warnings, 0 errors../test.ps1 -TestProject Src/xWorks/xWorksTests -TestFilter FullyQualifiedName~LcmWordGeneratorTests: 40 total, 38 passed, 2 skipped(the manual .docx tests), 0 failed.
right-to-left analysis, reversal index): each 1 of 1 passed. This checks
that they do not depend on run order.
xWorksTests: 2,026 total, 2,024 passed, 2 skipped, 0 failed.Not done:
origin/main. None of those commits touchthe three changed files. The tests were not rerun on top of them.
Jira: developer-only test change, no ticket needed for the branch itself.
LT-22927 covers the validation errors the tests exposed.
Positive Observations
writer is built and can move to liblcm with it.
in any order.
finallyblock.in the existing fixture.
Interview Notes
adds no static state (one
static readonlyarray, since removed, andstateless helpers). It does make the fixture depend on the writer's
existing statics; the author chose the reset-in-
Setuprepair.StyleProperties: the author objected to reducing XML to strings and choseXPath assertions.
review (run the validator on today's output early). The author decided the
branch carries no validator code and that the errors go to Jira. Office
2007 is the intended schema, for cross-platform support.
writer does today. Kept, with a question to Mark.
In-Review Quality Check
The validation above was run with every in-review change applied.
Suggested Review Focus
w:rtlon right-to-left text in a left-to-right dictionary"intended? (
LcmWordGenerator.cs:2841, test atLcmWordGeneratorDocumentTests.cs:695)items (0.L, 0.O-1, 0.O-2)?
internal setonIsBidiacceptable until 0.O-2 removes thestatic?
🤖 Generated with Claude Code
This change is