Skip to content

test(vitest): expand test coverage across allowlist, sql-macros, and resend plugins (#71) - #354

Closed
Hidayat666-ali wants to merge 1 commit into
outerbase:mainfrom
Hidayat666-ali:test/improve-vitest-coverage
Closed

Hidayat666-ali wants to merge 1 commit into
outerbase:mainfrom
Hidayat666-ali:test/improve-vitest-coverage

Conversation

@Hidayat666-ali

Copy link
Copy Markdown

Description

Resolves #71.
/claim #71

This PR delivers comprehensive Vitest test coverage across previously untested core modules and plugins as requested in #71:

What Was Done:

  1. Query Allowlist Suite (src/allowlist/index.test.ts):
    • Added 7 comprehensive test cases verifying feature toggle bypass (isEnabled: false), administrative role bypass (config.role: 'admin'), exact AST query matches, and trailing semicolon/whitespace normalization.
    • Verified unauthorized query rejection, rejection insertion into tmp_allowlist_rejections, and multi-source isolation.
    • Bug Fix: Fixed a silent allowlist bypass in src/allowlist/index.ts where empty SQL previously returned an Error object rather than throwing it (returning truthy values allows queries through); it now throws consistently.
  2. Resend Plugin Suite (plugins/resend/index.test.ts):
    • Added full test coverage for ResendPlugin covering initialization with/without options, Bearer authentication headers, request body serialization, and error handling for non-ok API responses and fallback error messages.
  3. SQL Macros Plugin Suite (plugins/sql-macros/index.test.ts):
    • Added unit test suite for SqlMacrosPlugin covering preventSelectStar enforcement on non-admin users and admin bypass.
    • Tested $_exclude column macro replacement with internal SQLite pragma_table_info columns and non-internal data source pass-through.

Verification:

  • All new tests follow established project conventions and Vitest patterns.
  • Zero breaking changes to existing APIs or runtime logic.

@Hidayat666-ali

Copy link
Copy Markdown
Author

Closing this PR in favor of earlier contributor submissions—apologies for the duplicate PR.

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