Commit graph

3 commits

Author SHA1 Message Date
TheFlow
ac2db33732 fix(submissions): restructure Economist package and fix article display
- Create Economist SubmissionTracking package correctly:
  * mainArticle = full blog post content
  * coverLetter = 216-word SIR— letter
  * Links to blog post via blogPostId
- Archive 'Letter to The Economist' from blog posts (it's the cover letter)
- Fix date display on article cards (use published_at)
- Target publication already displaying via blue badge

Database changes:
- Make blogPostId optional in SubmissionTracking model
- Economist package ID: 68fa85ae49d4900e7f2ecd83
- Le Monde package ID: 68fa2abd2e6acd5691932150

Next: Enhanced modal with tabs, validation, export

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-24 08:47:42 +13:00
TheFlow
ead22be7e2 refactor: remove orphaned tests for deleted website code
REMOVED: 15 test files testing non-existent code

Website Feature Tests (5):
- api.admin.test.js - Tests admin auth (auth.controller/routes removed)
- api.auth.test.js - Tests user authentication (auth.controller/routes removed)
- api.documents.test.js - Tests CMS documents (documents.controller/routes removed)
- api.koha.test.js - Tests donation system (koha.service/controller/routes removed)
- value-pluralism-integration.test.js - Website feature test

Removed Service Tests (5):
- BlogCuration.service.test.js - Service removed
- ClaudeAPI.test.js - Service removed
- koha.service.test.js - Service removed
- AdaptiveCommunicationOrchestrator.test.js - Service removed
- ProhibitedTermsScanner.test.js - Internal tool

Removed Util Tests (1):
- markdown.util.test.js - Util removed

Research/PoC Tests (4):
- tests/poc/memory-tool/* - Phase 5 proof-of-concept research

RETAINED: Framework service tests only
- BoundaryEnforcer, ContextPressureMonitor, CrossReferenceValidator
- InstructionPersistenceClassifier, MetacognitiveVerifier
- PluralisticDeliberationOrchestrator, MemoryProxy
- Integration tests for governance, projects, sync

REASON: Tests must test code that exists. Orphaned tests
provide false confidence and maintenance burden.

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-21 21:33:16 +13:00
TheFlow
9b79c8dea3 test: increase coverage for ClaudeAPI and koha services (9% → 86%)
Major test coverage improvements for Week 1 Task 3 (PHASE-4-PREPARATION-CHECKLIST).

ClaudeAPI.service.js Coverage:
- Before: 9.41% (CRITICAL - lowest coverage in codebase)
- After: 85.88%  (exceeds 80% target)
- Tests: 34 passing
- File: tests/unit/ClaudeAPI.test.js (NEW)

Test Coverage:
- Constructor and configuration
- sendMessage() with various options
- extractTextContent() edge cases
- extractJSON() with markdown code blocks
- classifyInstruction() AI classification
- generateBlogTopics() content generation
- classifyMediaInquiry() triage system
- draftMediaResponse() AI drafting
- analyzeCaseRelevance() case study scoring
- curateResource() resource evaluation
- Error handling (network, parsing, empty responses)
- Private _makeRequest() method validation

Mocking Strategy:
- Mocked _makeRequest() to avoid real API calls
- Tested all public methods with mock responses
- Validated error paths and edge cases

koha.service.js Coverage:
- Before: 13.76% (improved from 5.79% after integration tests)
- After: 86.23%  (exceeds 80% target)
- Tests: 34 passing
- File: tests/unit/koha.service.test.js (NEW)

Test Coverage:
- createCheckoutSession() validation and Stripe calls
- handleWebhook() event routing (7 event types)
- handleCheckoutComplete() donation creation/update
- handlePaymentSuccess/Failure() status updates
- handleInvoicePaid() recurring payments
- verifyWebhookSignature() security
- getTransparencyMetrics() public data
- sendReceiptEmail() receipt generation
- cancelRecurringDonation() subscription management
- getStatistics() admin reporting

Mocking Strategy:
- Mocked Stripe SDK (customers, checkout, subscriptions, webhooks)
- Mocked Donation model (all database operations)
- Mocked currency utilities (exchange rates)
- Suppressed console output in tests

Impact:
- 2 of 4 critical services now have >80% coverage
- Added 68 comprehensive test cases
- Improved codebase reliability and maintainability
- Reduced risk for Phase 4 deployment

Remaining Coverage Targets (Task 3):
- governance.routes.js: 31.81% → 80%+ (pending)
- markdown.util.js: 17.39% → 80%+ (pending)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-09 21:17:32 +13:00