Skip to content

test: add comprehensive Vitest suites for Clerk, SQL macros, Stats, WebSocket plugins and Durable Object lifecycle - #306

Open
Vallejo1921 wants to merge 1 commit into
outerbase:mainfrom
Vallejo1921:test/core-operations-durable-object-coverage
Open

Vallejo1921 wants to merge 1 commit into
outerbase:mainfrom
Vallejo1921:test/core-operations-durable-object-coverage

Conversation

@Vallejo1921

Copy link
Copy Markdown

Summary of Changes

Adds 64 new unit tests across 6 test suites targeting uncovered core operations, the Durable Object runtime lifecycle, and essential plugins:

  1. plugins/clerk/index.test.ts (17 tests):

    • Webhook endpoint validation (/clerk/webhook) handling POST verification with Svix headers.
    • Authentication lifecycle: token expiry, AZP claim verification, and permitted origins check.
    • Session lookup & DB caching (sessionExistsInDb) with graceful connection error recovery.
  2. plugins/sql-macros/index.test.ts (11 tests):

    • Macro definitions and registry parsing.
    • AST-based parameter substitution and unquoted string handling.
    • Query rewrite rules and syntax transformation verification.
  3. plugins/stats/index.test.ts (4 tests):

    • Metrics recording and timing aggregation.
    • Query counter and performance stats lifecycle.
  4. plugins/websocket/index.test.ts (6 tests):

    • WebSocket connection upgrade and status 101 lifecycle.
    • Active connection tracking and disconnection cleanups.
    • Message routing and error propagation.
  5. src/do.test.ts (14 new tests, 19 total):

    • Parameterized query execution with raw formatting and metadata.
    • Alarms API lifecycle (getAlarm, setAlarm, deleteAlarm).
    • Durable Object alarm() handler with cron schedule sync and error fallback rescheduling.
    • Database statistics calculation via getStatistics().
    • WebSocket client handling and selective session broadcasting.
  6. src/operation.extended.test.ts (7 tests):

    • executeExternalQuery parameter mapping (? to :paramX).
    • Outerbase raw API response parsing and malformed error fallback.
    • Plugin registry beforeQuery & afterQuery lifecycle execution.
    • Sequential transaction query processing via executeTransaction.

Test Results

All 64 tests pass cleanly:

Test Files  6 passed (6)
     Tests  64 passed (64)

Resolves #71
/claim #71

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.

Improve test coverage with Vitest

1 participant