Skip to content

test: cover playbook insights, CORS allowlists, portal origin, impersonation - #76

Closed
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/missing-test-coverage-cfe2
Closed

cursor[bot] wants to merge 2 commits into
mainfrom
cursor/missing-test-coverage-cfe2

Conversation

@cursor

@cursor cursor Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Focused regression coverage for high-blast-radius helpers still unclaimed vs open drafts #30#75 (main tip 48f3c2f).

Risky behavior now covered

  • Manager playbook insights: rent late→action / partial→watch / grace headlines; utilities draft+owed→action; disputed shares→danger; row cap at 8; onboarding incomplete→action
  • LAN/Tailscale CORS: RFC1918 + Tailscale 100.64–127 allowlist; public/malformed/non-http origins rejected (credentialed CORS blast radius)
  • Production CORS canonicalization: bare http:// host → https://www. ; localhost/loopback stay null; allowlist expands bare+www http+https
  • Email portal origin: localhost/127.0.0.1 CLIENT_ORIGIN never ships in outbound pay/maintenance links (rewrites to production www)
  • Client impersonation gates: property_manager → history-only manager gate; owner/super_admin do not; corrupt session fails closed

Test files added/updated

  • scripts/test-manager-playbook-insights.js + src/services/manager-playbook-insights-pure.js
  • scripts/test-lan-dev-cors.js
  • scripts/test-cors-origins.js + src/utils/cors-origins.js
  • scripts/test-portal-origin.js (export resolvePortalOrigin)
  • scripts/test-client-impersonation-gates.js
  • package.json npm scripts for the above

Why this reduces regression risk

These paths drive manager collection urgency, who can CORS into the API on LAN, which origin cookies/emails use in prod, and whether managers see charge UI while previewing tenants. None were covered on main; none were claimed by parallel coverage PRs (#72 Gmail redirect / #71 server impersonation pay guards / #75 email escape utils are different surfaces).

Validation

npm run test:manager-playbook-insights
npm run test:lan-dev-cors
npm run test:cors-origins
npm run test:portal-origin
npm run test:client-impersonation-gates

All passed locally (deterministic Node assert; no DB/Stripe).

Notes

Open in Web View Automation 

cursoragent and others added 2 commits August 25, 2026 10:21
Move pure builders out of DB-backed playbook service and app.js so
rent/utilities insight levels and production CORS canonicalization can
be unit-tested without side effects. Export resolvePortalOrigin for
email link origin checks.

Co-authored-by: Jose I. Montero <2eezy77@users.noreply.github.com>
…onation

Add deterministic Node suites for manager rent/utilities action levels,
LAN/Tailscale CORS matching, production www canonicalization, email
portal origin rewrite, and client manager vs owner impersonation gates.

Co-authored-by: Jose I. Montero <2eezy77@users.noreply.github.com>
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