Skip to content

Add unit tests for the API key scope helpers - #1089

Merged
jrhizor merged 1 commit into
elmohq:mainfrom
shawnrruss:test/scopes-unit-tests
Nov 3, 2026
Merged

jrhizor merged 1 commit into
elmohq:mainfrom
shawnrruss:test/scopes-unit-tests

Conversation

@shawnrruss

Copy link
Copy Markdown
Contributor

Closes #1088.

Adds apps/web/src/lib/api/__tests__/scopes.test.ts, covering every case listed in the issue, in the style of analytics-range.test.ts:

  • permissionsToScopes: read-only, write-only (no read added), read-write in canonical order, unknown actions dropped, other resources ignored, non-array api, and null / undefined / "api" (via it.each).
  • scopesToPermissions: canonical order, unknown scopes dropped, no duplicates, empty grant kept.
  • Round trip for [], ["read"], ["write"] and ["read", "write"] (via it.each).

toEqual everywhere, so scope order is checked. scopes.ts is unchanged; no bug found. This is my first contribution, so .github/contributors.txt gets my username.

How I checked it:

  • cd apps/web && pnpm exec vitest run --project=unit src/lib/api/__tests__/scopes.test.ts: 17 tests passed.
  • biome check on the new file: clean.

🤖 Generated with Claude Code

@shawnrruss
shawnrruss requested a review from jrhizor as a code owner November 2, 2026 13:57
@vercel

vercel Bot commented Nov 2, 2026

Copy link
Copy Markdown

@GlobMarl3y is attempting to deploy a commit to the Blue Whale Labs Team on Vercel.

A member of the Team first needs to authorize it.

@shawnrruss shawnrruss closed this Nov 2, 2026
@shawnrruss
shawnrruss deleted the test/scopes-unit-tests branch November 2, 2026 14:09
@shawnrruss
shawnrruss restored the test/scopes-unit-tests branch November 2, 2026 14:33
@shawnrruss shawnrruss reopened this Nov 2, 2026

@jrhizor jrhizor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jrhizor
jrhizor merged commit 67e4b07 into elmohq:main Nov 3, 2026
1 check failed
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.

Add unit tests for the API key scope helpers

2 participants