test(document-api): word-in-the-loop validation for anchored metadata (SD-3201)#3373
Merged
Merged
Conversation
… (SD-3201)
Closes the round-trip gap from SD-3104: SuperDoc -> DOCX -> Word save /
edit -> SuperDoc. The SuperDoc -> DOCX -> SuperDoc round-trip was already
proven by tests/doc-api-stories/tests/metadata/all-commands.ts; this adds
Word in the middle as deterministic fixtures replayed in CI.
Two fixtures, both generated from one SuperDoc-side source (one paragraph,
one anchored citation 'fixture-cite-001' over 'duty of care'):
- baseline-word-resaved.docx: opened in Word, re-saved without edits.
Proves Word does not strip the customXml part or the hidden SDT
wrapper on save.
- baseline-word-edited.docx: opened in Word with text inserted inside
the cited span. Proves the SDT survives content edits and the anchor
expands to cover the edited content (no orphan, no detach).
Replay test under tests/doc-api-stories/tests/word-roundtrip/:
- list({ namespace }) returns the citation
- get({ id }) returns the payload byte-for-byte (Word does not
renormalize the customXml part)
- resolve({ id }) returns a SelectionTarget
- list({ within: resolvedTarget }) confirms the anchor still covers
the post-edit range
What this does not cover
- New Word version regressions. A separate live script gated on Word
API access is the pre-customer-rollout pre-flight; not in this PR.
- Word's 'Inspect Document' / Document Inspector cleanup, which can
strip Custom XML Data as 'personal information.' Documented as a
known limitation in the namespace adoption guide (SD-3209).
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b2ff89d7d3
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…3201) Soften the inline comment to match what the test actually asserts: the anchor did not detach (resolve returns a selection target with text endpoints), and the citation is still listable via within-scoped list. Text-content equality of the resolved range against the edited string is explicitly not asserted here. Also drop the 'byte-for-byte' wording on the no-edit fixture — the assertion is parsed-payload equality, not raw XML byte equality.
…D-3201)
Replaces the self-referential metadata.list({ within: resolved.target })
block with a slice of the resolved block's text via editor.doc.extract.
The slice now asserts the SDT range covers 'duty' + 'reasonable' +
'care' — proving the Word-inserted word is inside the anchor using a
read surface (extract) that's independent of the metadata store.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Closes the round-trip gap from SD-3104 (#3351). The SuperDoc → DOCX → SuperDoc cycle was already proven by
tests/doc-api-stories/tests/metadata/all-commands.ts; this PR adds Microsoft Word in the middle as deterministic fixtures replayed in CI.Coverage
Two fixtures under
tests/doc-api-stories/tests/word-roundtrip/fixtures/, both produced by opening a SuperDoc-exported baseline in Microsoft Word and saving:baseline-word-resaved.docx— WordSave As, no edits. Proves Word does not strip the customXml part or the hidden SDT wrapper on a no-op save.baseline-word-edited.docx— text inserted inside the cited span ("duty of care" → "duty reasonable of care"). Proves the SDT survives content edits without detaching.Replay test asserts
For each fixture, the SuperDoc client reopens the file and verifies:
metadata.list({ namespace })returns the citationmetadata.get({ id })returns the expected payload (Word does not alter the customXml data during save or inline edits)metadata.resolve({ id })returns aselectiontarget with text endpoints — the anchor did not orphanmetadata.list({ within: target })confirms the citation is still listable in its own resolved range after Word's run-splittingText-content equality of the resolved range against the edited string is not asserted (see the inline comment at
all-commands.ts:109).Why deterministic fixtures, not live Word API
Fixtures run in CI without Word access. Catching new-Word-version regressions (Document Inspector strips customXml, Word changes SDT semantics, etc.) is a separate live pre-rollout check — not gated by CI.
What this does not cover