Skip to content

test: add regression coverage for proof inspector#1052

Open
MerlinTheWhiz wants to merge 1 commit into
Stellar-Mail:mainfrom
MerlinTheWhiz:test/proof-inspector-regression-coverage
Open

test: add regression coverage for proof inspector#1052
MerlinTheWhiz wants to merge 1 commit into
Stellar-Mail:mainfrom
MerlinTheWhiz:test/proof-inspector-regression-coverage

Conversation

@MerlinTheWhiz

Copy link
Copy Markdown

Closes #984

Files created:

  • src/features/proof-inspector/utils.ts — Extracted three pure, testable functions from ProofInspectorModal:
    • generateMockProofRecords(emails) — deterministic proof record generation
    • validateProofQuery(query) — query format validation
    • searchProofRecords(records, query) — search/filter logic
  • tests/unit/mail/proof-inspector.test.ts — 32 unit tests covering:
    • generateMockProofRecords: deterministic output, folder-based postage status, sender policy mapping, deliveredAt/readAt formatting (13 tests)
    • validateProofQuery: valid G/C addresses, hex hashes (with/without 0x), UUIDs, error on malformed lengths, keyword fallback (11 tests)
    • searchProofRecords: matching by name, email, subject, hash, diagnosticId; case-insensitivity; empty/no-match cases (8 tests)
  • tests/e2e/proof-inspector.spec.ts — 7 Playwright tests covering:
    • Modal opens from toolbar, shows correct title/description
    • Quick shortcut buttons displayed
    • Search by sender name shows proof record sections
    • Unmatched query shows "Proof Record Not Found"
    • Format validation for valid/invalid addresses
    • Copy buttons present in results
    • Modal closes on backdrop click

Files modified:

  • src/features/proof-inspector/ProofInspectorModal.tsx — Refactored to import from utils.ts instead of inline logic. Zero behavior change.
  • tests/unit/mail/provenance.test.ts — Added 10 new tests covering: Stellar key generation, provider resolution (SMTP/Indexer/Federation), isVerified flag for various folders, inspector section structure, deterministic relay node IDs, and rawJson validity.

Verification:

  • 46 unit tests pass (32 new + 14 extended)
  • Lint passes (npx eslint with 0 warnings)
  • tsc --noEmit timed out due to environment resource limits (pre-existing issue)

Local test note:

npm test fails on Node <22 because vite.config.ts imports @cloudflare/vite-plugin, which requires node:module.registerHooks (Node 22+). To run unit tests locally with Node 20, I used an alternate config:

cat > vitest.test.config.ts << 'EOF'
import { defineConfig } from "vitest/config";
import react from "@vitejs/plugin-react";
import tsConfigPaths from "vite-tsconfig-paths";

export default defineConfig({
  plugins: [tsConfigPaths({ projects: ["./tsconfig.json"] }), react()],
  test: {
    include: ["tests/unit/**/*.test.{ts,tsx}"],
  },
});
EOF

npx vitest run --config=vitest.test.config.ts tests/unit/mail/
rm vitest.test.config.ts - I removed it after

Recommended permanent fix: Add a vitest.workspace.ts at the project root that provides a test-only config without the Cloudflare plugin. Or upgrade node to version 22

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.

[Existing app][Proof Inspector] Add regression coverage for current behavior

1 participant