Skip to content

test: fix the 5 failing specs and measure coverage of lib - #68

Draft
pritesh-jain-cstk wants to merge 2 commits into
masterfrom
test/MKT-22142-fix-specs-coverage
Draft

pritesh-jain-cstk wants to merge 2 commits into
masterfrom
test/MKT-22142-fix-specs-coverage

Conversation

@pritesh-jain-cstk

@pritesh-jain-cstk pritesh-jain-cstk commented Nov 4, 2026 •

Copy link
Copy Markdown

Branch graph

Epic MKT-21682. This PR is highlighted. Only [Routine] depends on [Tests]; the rest are independent.

Merge order: #68 before #69 (#69 is based on #68). #64 and #69 both change package.json and package-lock.json: merge #64 first, then bring master into #69 with a merge (no rebase) and regenerate the lock with npm install --legacy-peer-deps (expect a lock conflict). #65, #66, #67 and #70 are independent.

graph LR
  master --> bug1["Bug: host-only extensionEvent MKT-22139"]
  master --> bug2["Bug: getField console.log MKT-22140"]
  master --> sec["Security: Dependabot MKT-22141"]
  master --> s64["Snyk/audit + LICENSE: existing #64"]
  master --> tests["[Tests] MKT-22142"]
  tests --> ci["[Routine] MKT-22143"]
  master --> docs["[Docs] MKT-22144"]
  style tests fill:#f9d71c,stroke:#333,stroke-width:2px
Loading

What

Jira: MKT-22142

Consumer impact: none. Tests and karma config only; lib/ and dist unchanged.

  • Why it matters: npm test fails on master (5 of 133), and the release workflow runs it before publishing. The 2.2.4 release (2026-01-16) build job failed and publish was skipped, so npm still serves 2.2.3; its logs have expired, so whether the specs or the Node 16 install failed is not known.
  • 4 specs (Extension initialize/setReady, ContentstackUIExtension init/init failure) posted real init/ready messages to the karma page, which never answers ("No ack"); their stubs were defined but never wired. post-robot's exports are read-only getters, so the specs now stub Extension.initialize and extension.postRobot, and reset the extensionEvent listener between specs (post-robot refuses a second one for the same window). init also asserts the SDK version is sent and that a second init reuses the instance.
  • getField invalid uid: asserts the prefix Invalid uid, Field not found. That prefix is not documented anywhere (the API reference does not list getField errors); it is the code's current contract (lib/entry.js:114) and the text 2.2.3 throws. b6d18c5 appended the cause to the message; that change is unreleased on npm, and extensions that compare the message for equality would see it differ on the next release.
  • getField Invalid Uid Multiple used a valid path (group.group.group.0) inside try with no assertion when nothing threw; it is now "getField multiple group instance" and checks the uid and data. The returned instance has no data_type and its schema is the subfield list; the docs do not define this, so it is not asserted.
  • Coverage: babel-plugin-istanbul (already a devDependency) instruments lib/; npm run test:coverage reports 97.23% lines (was 0/0). npm test no longer writes coverage/. The 90% gate is added in the [Routine] PR, where CI runs it.

Readiness items

tests.coverage, tests.coverage-script, tests.hollow-review (one hollow spec fixed)

Commands (exit codes, Node 24 locally)

Command master this branch
npm ci 1 (ERESOLVE, pre-existing) 1 (same)
npm ci --legacy-peer-deps 0 0
npm run build 0 (26 ESLint warnings) 0 (same)
lint / typecheck n/a (lint runs inside build; plain JS) n/a
npm test 1 (5 failed, 128 passed) 0 (133 passed)
npm audit --omit=dev 0 0
npm run test:coverage n/a (no script) 0 (97.23% lines)

Commits went through the repo's hooks (GitGuardian pre-commit and pre-push); none bypassed. Local Snyk cannot authenticate (org permission / 401), so the PR's Snyk checks are the scan.

CI: security-license fails here as on master: it requires the current year in LICENSE (still 2019-2025). Fixed by #64 (DX-29607), not by this PR. All Snyk, GitGuardian, CodeQL and policy checks pass.

🤖 Generated with Claude Code

MKT-22142.
- Extension and ContentstackUIExtension specs posted real 'init'/'ready'
  messages with no host to answer; stub Extension.initialize and
  extension.postRobot instead, and reset the extensionEvent listener
  between specs.
- getField invalid-uid spec asserts the documented message prefix.
- 'getField Invalid Uid Multiple' used a valid path and asserted nothing;
  it now checks the returned instance.
- Instrument lib/ with babel-plugin-istanbul; npm run test:coverage
  reports it (97% lines). npm test no longer writes coverage/.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@snyk-io

snyk-io Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues
✅ Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

🔒 Security Scan Results

ℹ️ Note: Only vulnerabilities with available fixes (upgrades or patches) are counted toward thresholds.

Check Type Count (with fixes) Without fixes Threshold Result
🔴 Critical Severity 0 0 10 ✅ Passed
🟠 High Severity 0 0 25 ✅ Passed
🟡 Medium Severity 0 0 500 ✅ Passed
🔵 Low Severity 0 0 1000 ✅ Passed

⏱️ SLA Breach Summary

✅ No SLA breaches detected. All vulnerabilities are within acceptable time thresholds.

Severity Breaches (with fixes) Breaches (no fixes) SLA Threshold (with/no fixes) Status
🔴 Critical 0 0 15 / 30 days ✅ Passed
🟠 High 0 0 30 / 120 days ✅ Passed
🟡 Medium 0 0 90 / 365 days ✅ Passed
🔵 Low 0 0 180 / 365 days ✅ Passed

✅ BUILD PASSED - All security checks passed

MKT-22142.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

🔒 Security Scan Results

ℹ️ Note: Only vulnerabilities with available fixes (upgrades or patches) are counted toward thresholds.

Check Type Count (with fixes) Without fixes Threshold Result
🔴 Critical Severity 0 0 10 ✅ Passed
🟠 High Severity 0 0 25 ✅ Passed
🟡 Medium Severity 0 0 500 ✅ Passed
🔵 Low Severity 0 0 1000 ✅ Passed

⏱️ SLA Breach Summary

✅ No SLA breaches detected. All vulnerabilities are within acceptable time thresholds.

Severity Breaches (with fixes) Breaches (no fixes) SLA Threshold (with/no fixes) Status
🔴 Critical 0 0 15 / 30 days ✅ Passed
🟠 High 0 0 30 / 120 days ✅ Passed
🟡 Medium 0 0 90 / 365 days ✅ Passed
🔵 Low 0 0 180 / 365 days ✅ Passed

✅ BUILD PASSED - All security checks passed

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