Skip to content

test(backend): add integration coverage for the admin analytics dashb… - #1203

Open
egwujiohaifesinachiperpetual-max wants to merge 1 commit into
StellerCraft:mainfrom
egwujiohaifesinachiperpetual-max:test/admin-analytics-route-integration-coverage
Open

test(backend): add integration coverage for the admin analytics dashb…#1203
egwujiohaifesinachiperpetual-max wants to merge 1 commit into
StellerCraft:mainfrom
egwujiohaifesinachiperpetual-max:test/admin-analytics-route-integration-coverage

Conversation

@egwujiohaifesinachiperpetual-max

Copy link
Copy Markdown

Closes #1161

Description

This PR adds comprehensive integration test coverage for the admin analytics dashboard route (GET /api/admin/analytics).

Fixes / Closes StellerCraft/craftEngineer Integration Test Coverage for the Admin Analytics Dashboard Route.

Changes Made

  • Added apps/backend/src/app/api/admin/analytics/admin-analytics.integration.test.ts
  • Covered the following test scenarios:
    • Unauthenticated rejection path (401): Missing session/user or auth error from Supabase.
    • Forbidden role rejection path (403): Authenticated users without admin privileges (non-matching user_metadata.role and absent from ADMIN_USER_IDS allowlist fallback).
    • Admin-authorized success path (200): Proper metric aggregation, totals calculation, and payload structure for both user_metadata.role === 'admin' and ADMIN_USER_IDS allowlist fallback.
    • Query parameters: Verification that metricType, startDate, and endDate query parameters are mapped to corresponding query filters.
    • Database error path (500): Proper error handling and error response formatting when Supabase query fails.

Verification

  • Ran npm run test --workspace=@craft/backend -- admin/analytics (9/9 tests passed).
  • Ran ESLint on apps/backend/src/app/api/admin/analytics/ with 0 warnings or errors.

Review Request

Requesting review from maintainers before merging.

@drips-wave

drips-wave Bot commented Aug 29, 2026

Copy link
Copy Markdown

@egwujiohaifesinachiperpetual-max Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

Engineer Integration Test Coverage for the Admin Analytics Dashboard Route

1 participant