Skip to content

test: expand snapshot coverage to guard upcoming library refactor - #1880

Draft
WillieRuemmele wants to merge 6 commits into
mainfrom
test/expand-snapshot-coverage
Draft

WillieRuemmele wants to merge 6 commits into
mainfrom
test/expand-snapshot-coverage

Conversation

@WillieRuemmele

Copy link
Copy Markdown
Member

What does this PR do?

Adds test coverage only (no changes under src/) so that a large upcoming refactor of SDR's internals (new XML, zip, HTTP and logging libraries; class-to-function API changes) can be checked against today's behavior instead of against rewritten unit tests.

  • Snapshot coverage for every registry strategy class. New sample projects for adapter/transformer/attribute combinations that had none: LWC/Aura and newer bundles, matchingContentFile (incl. Wave), mixedContent (Document, ExperienceBundle), computeApp, plus default+children and legacySuffix types.
  • Zip contents. Each standard project now snapshots the logical contents of the generated mdapi zip (sorted entry names, sizes, sha256), read by an independent minimal zip reader rather than jszip. It also asserts that zipFileCount equals the real entry count including directory entries, posix paths, no duplicates, and that content is compressed and not bloated. Zip bytes are intentionally not snapshotted (timestamps, library).
  • XML adversarial fixture. Entities (named/decimal/hex/nbsp), CDATA, comments, empty/self-closing elements, whitespace, unicode, numeric-looking text, BOM, CRLF. The test file header documents what round-trips unchanged and what is normalized today.
  • No-op retrieve test. For each standard project, merges the original mdapi over the committed expected source and requires every XML file to stay byte-identical, since any change would show up as a local modification in source-tracking.
  • Lifecycle/telemetry contract. Records the Lifecycle events SDR emits during source deploy/retrieve (name, order, payload keys/types) and the exact metadata_api_deploy_result telemetry keys.
  • Fixes to existing tests. Five dirsAreIdentical calls were never awaited (suppressed by no-floating-promises) so they could not fail; two also pointed at snapshot directories that don't exist. Awaited them, fixed the paths, removed two stale baseline files (undecomposed PermissionSet/SharingRules parents that fresh conversion no longer produces), and dropped the five eslint suppressions.

What issues does this PR fix or reference?

None. Preparation for the libraries-monorepo / Effect migration.

Functionality Before

Snapshot tests covered the convert path for a subset of strategies. Nothing asserted zip contents, byte-stability of unchanged retrieves, or the Lifecycle/telemetry contract, and five directory checks silently never ran.

Functionality After

Same product behavior (no src/ changes). The test suite now fails if any of the above change.

Metadata Registry: Successful Deploy and Retrieve (required if applicable)

N/A: no registry changes.

Notes for reviewers

  • Expected snapshots were generated from current main, so they pin existing behavior, including some quirks (e.g. XML comments are hoisted next to their parent, whitespace in values is trimmed, <tag/> becomes <tag></tag>). Fixtures are hand-written, not retrieved from an org.
  • Not covered yet: retrieve-side zips from a real org, deploy/retrieve replay with recorded responses, polling/retry, request payloads, scale-NUT size/time thresholds.

Adds sample projects for adapter/transformer/registry-attribute classes that had no
snapshot coverage: bundle (lwc/aura, newer bundles), matchingContentFile (incl. wave),
mixedContent (documents, experiences), computeApp, default+children and legacySuffix.
Adds zipSnap/sourceToZipManifest to the snapshot helpers. Converts each sample project to an
in-memory mdapi zip and snapshots the sorted entry names/sizes/hashes (not bytes, which vary by
timestamp/library). Reads the zip with an independent minimal reader and asserts:
- zipFileCount reported by convert() equals real entry count (incl. directory entries)
- posix paths only, no duplicate entries
- zip is not bloated / is meaningfully compressed on larger content

Guards against regressions when swapping the zip library.
xmlAdversarial: objects, fields and labels covering entities, CDATA, comments,
empty elements, whitespace, unicode, numeric-looking text, BOM and CRLF.
Locks in current round-trip behavior ahead of any XML parser or builder swap.

lifecycleContract: records the Lifecycle events (name, order, payload keys)
SDR emits during source-format deploy and retrieve, plus the deploy telemetry
customDimensions, so refactors cannot silently change what consumers see.
Adds a no-op merge test to every standard snapshot project: merge the original
mdapi over the committed expected source and require no XML file to change.
Any byte change here is something source-tracking would flag as a local edit.

Also awaits five dirsAreIdentical calls that could never fail, and excludes
binary and lossy-snapshot files from the comparison.
dirsAreIdentical was called without await in forceignore, customLabels-multiple,
preset-sharingRules, preset-PermSet and staticResource, so a missing or extra
file could never fail those tests (eslint no-floating-promises suppressed them).

forceignore and customLabels-multiple also pointed at snapshot directories that
do not exist; fixed the paths. Removed two stale baseline files that fresh
conversion no longer produces (undecomposed PermissionSet and SharingRules
parents, left over from before the presets decomposed them) and the matching
known-change exception. Drops the five eslint suppressions.
@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown

This PR lacks any commits of the 'fix' or 'feat' type, and therefore will not trigger a release. To silence all further warnings, react to this warning comment (or any other) with the 👀 emoji.

NOTE: If your repo uses squash commits, make sure to add the appropriate conventional commit prefix (e.g., 'fix:', 'feat:', 'chore:', etc) in the squash commit message.

Windows checkouts convert fixtures to CRLF, which changes
zip entry sizes and hashes and makes the no-op merge test
report changed files. Force LF so baselines are identical
on every platform.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants