fix(docs): initialize body for partial document data#7074
Conversation
View Deployment
|
Playwright test resultsDetails
|
|
What is the original problem, and is there a way to reproduce it? |
|
Original downstream issue: https://github.com/dream-num/univer-cli/issues/461 The problem was observed through Univer CLI SaC document authoring. Users could discover const fDocument = univerAPI.createDocument({
id: 'doc-demo',
title: 'Demo Doc',
documentStyle: {},
});
fDocument.appendText('Univer');
// The downstream report used insertParagraph after createDocument in the same missing-body path.Before this PR, that partial document snapshot kept The downstream report also contains a second symptom: after users tried to work around the error by hand-writing a minimal body, the handcrafted body had invalid/incomplete document structure and two paragraph insertions collapsed into one paragraph. That is why the downstream issue looks like several separate gaps. The root blocker for this PR is the missing-body partial snapshot: callers should not need to handcraft Expected behavior after this PR: |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #7074 +/- ##
==========================================
- Coverage 62.16% 62.07% -0.10%
==========================================
Files 2592 2595 +3
Lines 153097 153725 +628
Branches 34999 35178 +179
==========================================
+ Hits 95177 95428 +251
- Misses 57920 58297 +377 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Related downstream report: Univer CLI document creation followed by Facade text insertion failed because the created document had no body.
This PR makes partial document data without
bodyinitialize as a standard empty document inDocumentDataModel. This is necessary because Facade callers can create documents with onlyidandtitle, then naturally callappendTextorinsertText; before this change the document had no body and those APIs failed withThe document body is empty.The fix keeps a single document creation path by normalizing missing-body document snapshots at the core data-model boundary. It does not add CLI string matching or Facade fallback behavior. Documents that already provide a body keep their supplied body.
How to test them:
pnpm --filter @univerjs/core exec vitest run src/docs/data-model/__tests__/document-data-model.spec.ts src/docs/data-model/__tests__/empty-snapshot.spec.tspnpm --filter @univerjs/docs exec vitest run src/facade/__tests__/f-document-node.spec.tspnpm --filter @univerjs/core typecheckpnpm --filter @univerjs/docs typecheckgit diff --checkPull Request Checklist