test(npm): publish filter + datastore guard coverage (S11 Step 16, 2/2)
Part 2 of 2 of the npm hosted plan — Step 16: publish handler — commit transaction.
🗂️ Stacked MRs
Split into 2 stacked MRs to keep each within the review size limit (~600 ideal reviewable LoC). Each part targets the previous one (part 1 → main); review and merge bottom-up.
- feat(npm): publish handler commit transaction (... (!780 - merged) • Dzmitry (Dima) Meshcharakou • 19.2
- test(npm): publish filter + datastore guard cov... (!781 - merged) • Dzmitry (Dima) Meshcharakou • 19.2
👈
📦 What this part adds
Follow-up test coverage surfaced by the Step 16 branch review - no production behavior change (the only non-test edit is a doc-comment clarification that shipped in part 1). It adds fast white-box unit tests for the publish package.json filter helpers, an integration test proving the dist sub-filter drops the non-canonical keys every real npm CLI attaches (fileCount / unpackedSize / signatures) so the strict datastore schema still accepts the row, argument-guard unit tests for the three new Step 16 datastore write methods, and a more direct AC 27 force-expire assertion (against the DB clock rather than the seeded future value).
✅ Spec coverage
| Coverage added | Test |
|---|---|
| Allow-list projection: allow-listed kept, denylisted/unknown dropped | TestFilterPackageJSON |
dist sub-filter: canonical kept, extras dropped, null -> {}, non-object -> error |
TestFilterDist |
| Top-level allow-list predicate | TestStoredPackageJSONField |
Nullable scope mapping (@scope preserved, unscoped -> NULL) |
TestOptionalScope |
dist sub-filter end-to-end (realistic dist filtered, persists 201) |
TestPublishCommitIntegration_DistExtraFieldsFiltered |
IncrementRepositoryPublishCounters argument guards |
TestRepositoryStore_IncrementRepositoryPublishCounters_Guards |
IncrementNpmPackagePublishCounters argument guards |
TestNpmPackageStore_IncrementNpmPackagePublishCounters_Guards |
ForceExpireNpmMetadataTx argument guards |
TestNpmMetadataFileStore_ForceExpireNpmMetadataTx_Guards |
📚 References
- Plan: https://gitlab.com/gitlab-org/ops/artifact-registry/-/blob/main/docs/plans/2026-05-11-npm-hosted.md
- Spec: https://gitlab.com/gitlab-org/ops/artifact-registry/-/blob/main/docs/specs/S11-npm-hosted.md
Related to #122 (closed)