Skip to content

test(utils): add coverage for attestation-CSV and PNG-export helpers (#1976) - #2001

Draft
s6pa1rta3n-lab wants to merge 1 commit into
Commitlabs-Org:masterfrom
s6pa1rta3n-lab:fix-issue-1976
Draft

s6pa1rta3n-lab wants to merge 1 commit into
Commitlabs-Org:masterfrom
s6pa1rta3n-lab:fix-issue-1976

Conversation

@s6pa1rta3n-lab

Copy link
Copy Markdown

Summary

Closes #1976.

Restores src/utils/chartExport.ts and adds comprehensive unit test coverage in src/utils/__tests__/chartExport.test.ts for attestation CSV export helpers and PNG export functions with DOM and canvas mocking:

  • Attestation CSV Export Helpers:

    • buildAttestationCsvRows: covers ISO string conversion for Date instances and pass-through for pre-formatted strings, as well as mixed inputs.
    • buildAttestationCsvContent: verifies header row inclusion, field formatting, formula-injection character escaping (=, +, -, @), and empty array handling.
    • buildAttestationExportFilename: verifies filename sanitization and fallback to 'commitment' on empty input ID.
    • ATTESTATION_CSV_HEADERS: validates all 6 standard export columns.
  • PNG Export Functions:

    • loadImage: validates resolution on successful image loading and rejection on load error.
    • exportSvgElementToPng: tests error paths for missing 2D canvas context (Canvas context unavailable), failed PNG blob generation (Failed to create PNG blob), and image loading failure (Failed to load chart SVG for PNG export). Also verifies successful blob generation and download triggering, including auto-injection of missing xmlns attributes.
    • exportChartContainerToPng: tests error path when svg.recharts-surface is missing (Chart SVG not found) and successful export delegation when present.

Payout Stipulations Checklist

  • Restore src/utils/chartExport.ts with all required export symbols.
  • Extend src/utils/__tests__/chartExport.test.ts to test buildAttestationCsvRows with both Date and string timestamps.
  • Test formula escaping and empty array handling in buildAttestationCsvContent.
  • Test filename sanitization and empty ID fallback in buildAttestationExportFilename.
  • Test PNG export error paths (Canvas context unavailable, Chart SVG not found, Failed to create PNG blob, image load failure) using DOM and canvas mocks.
  • Pass all unit tests and achieve 100% test coverage for chartExport.ts.
  • Zero linting or code formatting errors.
  • Self-documenting code with JSDoc docstrings and no inline comments.

Payout Routing

  • EVM (Base/Arbitrum/Polygon/ETH): 0xF46C9F6d70C50BF81ef3588AB523a90a594a2F89
  • Stellar: GCL6OXAMLD75BMTINA6EMRUDWK5THQUSHMYNLSNBCJAPZJHNYJTUNIBC

@vercel

vercel Bot commented Sep 29, 2026

Copy link
Copy Markdown

@s6pa1rta3n-lab is attempting to deploy a commit to the 1nonly's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

chartExport.test.ts has no coverage for the attestation-CSV or PNG-export helpers in chartExport.ts

1 participant