Commit Graph

7 Commits

Author SHA1 Message Date
Ho Ngoc Hai
cf1dee5491 feat(notifications): add NotificationsPublisher (outbox-backed) — GOO-173
Phase 1 step 2 — introduce the publisher primitive that emits
notification.requested envelopes through the RFC-004 transactional
outbox. Listeners and command handlers will migrate onto this in a
follow-up commit (flag-gated cutover).

- NotificationsPublisher exposes:
  * publishWithin(tx, input) — preferred; appends to outbox inside an
    existing Prisma transaction so the row commits atomically with the
    domain mutation that triggered the notification
  * publishStandalone(input) — opens a single-row tx; convenience for
    callers that don't already own one
- Builds EventEnvelope<NotificationRequestedPayload> via the Phase 0
  envelope builder (UUIDv7 eventId, current trace id, ISO occurredAt)
- Producer string: "goodgo-api/notifications"; eventType:
  "notification.requested"
- aggregateId on outbox row = notificationId for downstream tracing
- Optional fields (locale, priority, dedupeKey) only included when set,
  matching the JSON Schema's additionalProperties=false contract

Tests (4 specs, all green):
- publishWithin builds a valid envelope (assertValidEnvelope) and writes
  to the supplied tx with aggregateId
- publishStandalone opens its own transaction
- Optional fields are omitted when undefined and preserved when provided
- UUIDv7 eventIds are strictly time-ordered between successive calls

Not yet wired in NotificationsModule providers — that lands with the
listener cutover in the next commit so we don't ship dead DI nodes.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-24 14:12:55 +07:00
Ho Ngoc Hai
68b65cb848 test(web): increase frontend test coverage to ~70% page coverage
- Fix vitest config to include [locale] directory tests (was excluded)
- Fix register.spec.tsx: use getByRole('heading') to avoid duplicate text match
- Fix search.spec.tsx: add QueryClientProvider wrapper and mock saved searches hook
- Add 12 new page test files covering dashboard, admin, public, and OAuth pages:
  - dashboard (main, profile, payments, subscription, KYC)
  - admin (dashboard, users)
  - public (landing, pricing)
  - analytics
  - OAuth callbacks (Google, Zalo)
- 29 test files, 174 tests, 16/23 pages covered (69.6%)

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-10 23:14:16 +07:00
Ho Ngoc Hai
e0154a0105 fix: resolve lint errors — import deduplication, ordering, and test config
- Enable prefer-inline for import-x/no-duplicates to support barrel
  import patterns (value + type imports from same module)
- Inline duplicate type imports in middleware.ts and listing-form-steps.tsx
- Fix import ordering across API test files and MCP controller
- Add next-intl mock to search spec (FilterBar uses useTranslations)
- Exclude [locale] test duplicates from vitest (need proper i18n test setup)

All 801 tests passing (653 API + 119 web + 29 MCP). Zero lint errors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-09 08:49:29 +07:00
Ho Ngoc Hai
0c26dd85ef fix: resolve all lint errors across codebase
- Convert CacheTTL enum to const object to fix duplicate value errors
- Fix import ordering in test files (eslint-disable for vi.mock pattern)
- Fix unused variable warnings (prefix with underscore)
- Auto-fix import ordering in subscription page, dashboard layout
- 0 lint errors remaining

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-08 23:13:35 +07:00
Ho Ngoc Hai
ccb82fddf8 feat(cache): implement Redis caching for search & analytics hot paths
- Add TTL-specific cache durations: district stats (5min), market report (15min), heatmap (5min)
- Add Redis caching to GeoSearch handler with 60s TTL
- Add cache invalidation on listing.approved, listing.updated, listing.deactivated, listing.sold events
- Invalidate search, geo_search, and all analytics cache prefixes on listing state changes
- Update tests for new CacheService dependency in event handler and geo-search handler

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-08 22:51:16 +07:00
Ho Ngoc Hai
8705a2d9a8 fix: resolve all ESLint errors across API and web packages
Fix 19+ lint errors: unused imports (Phone, DuplicateCandidate, listingDetailsSchema),
import ordering violations, consistent-type-imports, and constant binary expression
in test file.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-08 16:29:44 +07:00
Ho Ngoc Hai
cd2abdba7b test(web): add Vitest setup and unit tests for validations and utils
- Add vitest config and test script to web app
- Auth validation tests: phone format, password rules, registration flow
- Listing validation tests: all schema steps, constants, merged schema
- Utils tests: cn() class merging with Tailwind conflict resolution
- 36 tests across 3 test files

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-08 14:59:00 +07:00