Files
larksuite__cli/tests/cli_e2e/slides/coverage.md
2026-08-24 18:26:23 +08:00

33 lines
10 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Slides CLI E2E Coverage
## Metrics
- Denominator: 7 leaf commands
- Covered: 7
- Coverage: 100%
## Summary
- TestSlides_CreateWorkflowAsUser: proves the user slides workflow through `create presentation with slide as user` and `get created presentation xml as user`; creates a fresh presentation, asserts returned IDs, then reads back the XML content to prove the title and slide body persisted.
- TestSlidesCreateRepeatedSlideFileDryRunE2E / TestSlidesCreateSlidesFileAndStdinDryRunE2E / TestSlidesCreateRejectsBothSlideFormsDryRunE2E: cover the `+create` file inputs through the built binary, which is the only layer that can prove the point of the feature — a multi-line, quote-heavy page reaches `slide.content` byte-for-byte with no JSON encoder in the caller's hands, and repeated `--slide` order is page order. The refusal case pins the exit-2 envelope (`param: "--slide"`) that an agent parses to repair its own command; the package test never runs the dispatcher and so cannot see it.
- TestSlidesAddSlideDryRunE2E / TestSlidesDeleteSlideDryRunE2E: pin the request shapes the unit tests cover, but through the real binary, which is the only layer that proves a full `<slide>` XML document survives flag parsing with its quotes and angle brackets intact. Delete additionally proves the shortcut runs without `--yes`, unlike the high-risk-write raw command.
- TestSlides_SlideAddDeleteWorkflowAsUser: live add/delete round trip on a throwaway presentation created and torn down per run. Asserts against a readback rather than the write's own response, so it proves what the request shape cannot: the returned `slide_id` addresses a real page, `--before-slide-id` positions the page between its neighbours instead of merely being forwarded, and the deleted page is gone while both neighbours survive.
- TestSlidesUpdateSlideDryRunE2E / TestSlidesUpdateAliasDryRunE2E / TestSlidesUpdateSlideRefuses*DryRunE2E: dry-run coverage for `+update-slide` through the built binary — one request carrying one `block_replace` part whose `block_id` is the PAGE id (the whole design; an element id there would replace one element and leave the rest of the page), the `slide` service alias / `+update` command alias / `--xml` spelling, and the two refusals that must not produce a request (a bare element root, and a root id naming a different page).
- TestSlidesUpdateSlideLiveE2E: required live-backend assertion for `+update-slide`; creates a throwaway presentation with the lane's bot credential, replaces its page using the returned page id as `block_id`, reads that page back through `+xml-get`, verifies the new marker replaced the old marker without changing `slide_id`, and self-cleans.
- TestSlides_HistoryWorkflow: opt-in live round-trip coverage for `+update-slide`; creates a presentation, updates its page in place, asserts the returned `slide_id`, the persisted marker, and that an element written back with its original id keeps that id, then reverts through slide history and self-cleans. It runs only when `LARK_SLIDES_HISTORY_E2E=1` and therefore does not yet exercise the default live lane.
- TestSlidesReplaceSlideNormalizationDryRunE2E / TestSlidesReplaceSlideEmptyReplacementDryRunE2E / TestSlidesReplaceSlideDryRunE2E: dry-run coverage for `+replace-slide` through the built binary. The normalization case proves `replace` / `insert`, `target_id`, `content`, and `element` become a canonical request and that structured output records all conversions. The other cases preserve the strict boundary: an actually-empty canonical payload still fails, while a legitimate mixed `block_replace` + `block_insert` batch remains unchanged.
- TestSlides_ReplaceSlideAliasWorkflowAsUser: live alias round trip on a throwaway presentation. It reads server-assigned block IDs, replaces one target through `replace` / `target_id` / `content`, inserts another through `insert` / `element`, reads the deck back to prove both writes persisted in the requested position while a control block survived, and deletes the presentation in cleanup.
- TestSlides_ImageUploadDryRunParentType: dry-run coverage for the drive `parent_type` an image upload carries through `+media-upload --file` and the `<img src="@...">` placeholder pipeline behind `+add-slide` / `+update-slide`. A native deck must upload as `slide_file` and an imported "office" deck as `office_slide_file`; the negative half matters most, because the backend does not validate `parent_node` against the `parent_type`, so a wrong value uploads successfully and only shows up later as an image that will not render. Each of the three surfaces is also exercised with a wiki `--presentation`, whose real token a preview must not resolve; those cases pin `slide_file`, which is sound rather than a guess because `resolvePresentationID` rejects any wiki node whose `obj_type` is not `slides` and an imported office deck is a drive `file` node. They exist because the production code now asserts that value directly instead of arriving at it by running the placeholder through the office check. `+create` is deliberately absent from this lane: it has no `--presentation` flag, so it always uploads into a deck it just created through the API, and its native-only expectation is pinned in the unit lane where it can be stated as such.
- TestSlidesMediaDownloadDryRunE2E / TestSlidesMediaDownloadValidationDryRunE2E / TestSlidesMediaDownloadOutputConflictDryRunE2E: dry-run coverage for `+media-download` through the built binary. Pins both requests the shortcut plans — the direct Drive media download first, and the `preview_download?preview_type=16` source-file preview fallback second — along with the `file_token` and resolved `output` fields across `--output`, `--output-dir`, and default output-dir. The validation cases pin the empty-token and output/output-dir conflict envelopes through the real command registration, which the package test (stubbing at the HTTP layer) cannot reach.
- TestSlidesMediaUploadDownloadLiveE2E: required live-backend assertion for the media upload→download round trip; creates a throwaway presentation, generates a deterministic 8×8 PNG fixture, uploads it via `+media-upload`, verifies the returned `file_token`, `file_name`, `presentation_id`, and `size` match the local fixture, then downloads the token back via `+media-download`, verifies the saved path lands under `--output-dir`, the reported `content_type` is image/*, `source` is either `"download"` or `"preview"`, and the on-disk byte count matches the reported `size`. The presentation is deleted in cleanup. This is the only layer that can prove a real Slides media token survives the direct-to-preview transition and returns decodable image bytes.
## Command Table
| Status | Cmd | Type | Testcase | Key parameter shapes | Notes / uncovered reason |
| --- | --- | --- | --- | --- | --- |
| ✓ | slides +create | shortcut | slides_create_workflow_test.go::TestSlides_CreateWorkflowAsUser/create presentation with slide as user; slides_create_slide_inputs_dryrun_test.go::TestSlidesCreateRepeatedSlideFileDryRunE2E, TestSlidesCreateSlidesFileAndStdinDryRunE2E, TestSlidesCreateRejectsBothSlideFormsDryRunE2E | `--title`; `--slides ["<slide ...>"]` / `--slides @deck.json` / `--slides -`; repeated `--slide @page.xml` | live lane reads back through raw slides API to prove persisted XML; dry-run lane pins the file inputs and the mutual-exclusion refusal |
| ✓ | slides +add-slide | shortcut | slides_slide_add_delete_dryrun_test.go::TestSlidesAddSlideDryRunE2E; slides_slide_add_delete_workflow_test.go::TestSlides_SlideAddDeleteWorkflowAsUser | `--slide "<slide ...>"`; `--before-slide-id`; `--revision-id` | live append and insert both verified by reading the deck back |
| ✓ | slides +delete-slide | shortcut | slides_slide_add_delete_dryrun_test.go::TestSlidesDeleteSlideDryRunE2E, TestSlidesDeleteSlideWikiDryRunE2E; slides_slide_add_delete_workflow_test.go::TestSlides_SlideAddDeleteWorkflowAsUser | `--slide-id`; `--revision-id`; wiki URL | live delete runs on a throwaway deck; readback proves the neighbours survive |
| ✓ | slides +update-slide | shortcut | slides_update_slide_dryrun_test.go::TestSlidesUpdateSlideDryRunE2E (+ alias / refusal cases); slides_update_slide_workflow_test.go::TestSlidesUpdateSlideLiveE2E; slides_history_workflow_test.go::TestSlides_HistoryWorkflow (opt-in history/revert) | `--presentation`; `--slide-id`; `--content "<slide ...>"`; `--revision-id` | default live CI proves a real in-place update and readback; opt-in workflow adds history/revert and element-id preservation |
| ✓ | slides +replace-slide | shortcut | slides_replace_slide_dryrun_test.go::TestSlidesReplaceSlideNormalizationDryRunE2E, TestSlidesReplaceSlideEmptyReplacementDryRunE2E, TestSlidesReplaceSlideDryRunE2E; slides_replace_slide_workflow_test.go::TestSlides_ReplaceSlideAliasWorkflowAsUser | `--presentation`; `--slide-id`; canonical and compatibility `--parts` shapes | dry-run pins canonical request construction and validation; live workflow proves alias replace/insert persistence, target ID preservation, insertion ordering, control-block survival, and cleanup |
| ✓ | slides +media-upload | shortcut | slides_image_upload_dryrun_test.go::TestSlides_ImageUploadDryRunParentType (dry-run); slides_media_workflow_test.go::TestSlidesMediaUploadDownloadLiveE2E (live round trip) | `--presentation` with a native, an imported-office, and an unresolved wiki reference; `--file` | dry-run lane pins the native/office `parent_type` split across `+media-upload` and the `@path` placeholder pipeline, plus the wiki case, which is native by construction because a non-`slides` wiki node never reaches an upload; live round-trip proves a real Slides media token uploads successfully and survives the direct-to-preview transition when downloaded back |
| ✓ | slides +media-download | shortcut | slides_media_download_dryrun_test.go::TestSlidesMediaDownloadDryRunE2E, TestSlidesMediaDownloadValidationDryRunE2E, TestSlidesMediaDownloadOutputConflictDryRunE2E; slides_media_workflow_test.go::TestSlidesMediaUploadDownloadLiveE2E (live round trip) | `--file-token`; `--output` / `--output-dir` | dry-run pins the two-step direct→preview plan with `preview_type=16`, output resolution, and validation envelopes through the real binary; live round-trip proves a real Slides media token downloads successfully (either direct or preview fallback) with matching byte count and image content type |