@etus/bhono-app 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +0 -0
- package/package.json +5 -1
- package/templates/base/.husky/pre-push +26 -0
- package/templates/base/CLAUDE.md +5 -5
- package/templates/base/README.md +31 -20
- package/templates/base/docs/app_spec.txt +13 -10
- package/templates/base/docs/architecture/README.md +3 -0
- package/templates/base/docs/architecture/data-requirements.md +4 -3
- package/templates/base/docs/architecture/db-bootstrap.md +39 -0
- package/templates/base/docs/architecture/drizzle-migration-plan.md +125 -0
- package/templates/base/docs/architecture/erd.md +1 -1
- package/templates/base/docs/architecture/sql-standards.md +100 -0
- package/templates/base/docs/testing.md +36 -29
- package/templates/base/package.json +6 -5
- package/templates/base/pnpm-lock.yaml +0 -123
- package/templates/base/schema.sql +84 -0
- package/templates/base/scripts/init.sh +244 -59
- package/templates/base/src/client/hooks/use-auth.ts +5 -0
- package/templates/base/src/client/routes/_authenticated/dashboard.tsx +1 -1
- package/templates/base/src/client/routes/index.tsx +1 -1
- package/templates/base/src/server/db/client.ts +3 -5
- package/templates/base/src/server/db/records.ts +81 -0
- package/templates/base/src/server/db/seed.ts +3 -2
- package/templates/base/src/server/db/sql.ts +96 -0
- package/templates/base/src/server/index.ts +16 -2
- package/templates/base/src/server/lib/audit.ts +74 -26
- package/templates/base/src/server/lib/audited-db.ts +219 -109
- package/templates/base/src/server/lib/transaction.ts +10 -16
- package/templates/base/src/server/middleware/account.ts +8 -15
- package/templates/base/src/server/middleware/auth.ts +102 -38
- package/templates/base/src/server/middleware/rate-limit.ts +6 -1
- package/templates/base/src/server/routes/accounts/handlers.ts +18 -6
- package/templates/base/src/server/routes/audits/handlers.ts +3 -1
- package/templates/base/src/server/routes/auth/handlers.ts +14 -9
- package/templates/base/src/server/routes/auth/test-login.ts +99 -45
- package/templates/base/src/server/routes/health/handlers.ts +4 -4
- package/templates/base/src/server/routes/invitations/handlers.ts +6 -3
- package/templates/base/src/server/routes/users/handlers.ts +21 -14
- package/templates/base/src/server/services/accounts.ts +242 -217
- package/templates/base/src/server/services/audits.ts +114 -61
- package/templates/base/src/server/services/auth.ts +310 -180
- package/templates/base/src/server/services/invitations.ts +282 -222
- package/templates/base/src/server/services/users.ts +383 -293
- package/templates/base/src/server/types/index.ts +1 -2
- package/templates/base/{src/server/__tests__/fixtures.ts → tests/fixtures/server.ts} +3 -3
- package/templates/base/{src/client/__tests__/setup-browser.ts → tests/helpers/client-setup-browser.ts} +2 -2
- package/templates/base/{src/client/__tests__/setup.ts → tests/helpers/client-setup.ts} +1 -1
- package/templates/base/{src/client/__tests__/test-utils.tsx → tests/helpers/client-test-utils.tsx} +2 -2
- package/templates/base/{src/server/__tests__/setup.ts → tests/helpers/server.ts} +9 -9
- package/templates/base/tests/integration/accounts/crud.test.ts +2 -11
- package/templates/base/tests/integration/audits/list.test.ts +2 -11
- package/templates/base/tests/integration/auth/auth-service.test.ts +1 -10
- package/templates/base/tests/integration/auth/invitation-token.test.ts +2 -11
- package/templates/base/tests/integration/auth/logout.test.ts +2 -11
- package/templates/base/tests/integration/auth/oauth.test.ts +23 -42
- package/templates/base/tests/integration/auth/refresh-token.test.ts +1 -9
- package/templates/base/tests/integration/auth/session-expiry.test.ts +1 -9
- package/templates/base/tests/integration/auth/session.test.ts +2 -11
- package/templates/base/tests/integration/auth/super-admin.test.ts +1 -9
- package/templates/base/tests/integration/authorization/analytics-role.test.ts +2 -11
- package/templates/base/tests/integration/authorization/billing-role.test.ts +2 -11
- package/templates/base/tests/integration/authorization/guards-roles.test.ts +1 -9
- package/templates/base/tests/integration/authorization/multi-tenancy.test.ts +2 -11
- package/templates/base/tests/integration/authorization/roles.test.ts +2 -11
- package/templates/base/tests/integration/config/production-behavior.test.ts +2 -11
- package/templates/base/tests/integration/health/health.test.ts +25 -44
- package/templates/base/tests/integration/invitations/crud.test.ts +2 -11
- package/templates/base/tests/integration/invitations/email.test.ts +1 -9
- package/templates/base/tests/integration/middleware/auth.test.ts +3 -12
- package/templates/base/tests/integration/middleware/request-logger.test.ts +1 -9
- package/templates/base/tests/integration/performance/response-times.test.ts +1 -9
- package/templates/base/tests/integration/security/cookie-security.test.ts +2 -11
- package/templates/base/tests/integration/security/csrf-protection.test.ts +2 -11
- package/templates/base/tests/integration/security/log-sanitization.test.ts +1 -9
- package/templates/base/tests/integration/security/rate-limiting.test.ts +1 -9
- package/templates/base/tests/integration/security/sql-injection.test.ts +7 -18
- package/templates/base/tests/integration/security/xss-prevention.test.ts +2 -11
- package/templates/base/tests/integration/setup.ts +13 -90
- package/templates/base/tests/integration/smoke.test.ts +3 -2
- package/templates/base/tests/integration/storage/upload.test.ts +2 -11
- package/templates/base/tests/integration/storage/validation.test.ts +2 -11
- package/templates/base/tests/integration/users/crud.test.ts +2 -11
- package/templates/base/tests/integration/users/list.test.ts +2 -11
- package/templates/base/tests/integration/vitest.config.ts +2 -9
- package/templates/base/{src/server/__tests__ → tests}/mocks/db.ts +1 -1
- package/templates/base/{src/server/__tests__ → tests}/mocks/index.ts +1 -1
- package/templates/base/{src/server/__tests__ → tests}/mocks/kv.ts +1 -1
- package/templates/base/{src/server/__tests__ → tests}/mocks/r2.ts +1 -1
- package/templates/base/{src/client/components/__tests__ → tests/unit/client/components}/sidebar.test.tsx +1 -1
- package/templates/base/{src/client/components/ui/__tests__ → tests/unit/client/components/ui}/avatar.test.tsx +1 -1
- package/templates/base/{src/client/__tests__ → tests/unit/client/components/ui}/button.test.tsx +1 -1
- package/templates/base/{src/client/components/ui/__tests__ → tests/unit/client/components/ui}/card.test.tsx +1 -1
- package/templates/base/{src/client/components/ui/__tests__ → tests/unit/client/components/ui}/dialog.test.tsx +1 -1
- package/templates/base/{src/client/components/ui/__tests__ → tests/unit/client/components/ui}/input.test.tsx +1 -1
- package/templates/base/{src/client/components/ui/__tests__ → tests/unit/client/components/ui}/loading-skeleton.test.tsx +1 -1
- package/templates/base/{src/client/components/ui/__tests__ → tests/unit/client/components/ui}/skeleton.test.tsx +1 -1
- package/templates/base/{src/client/components/ui/__tests__ → tests/unit/client/components/ui}/sonner.test.tsx +1 -1
- package/templates/base/{src/client/components/ui/__tests__ → tests/unit/client/components/ui}/tabs.test.tsx +1 -1
- package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/account.test.tsx +1 -1
- package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/integrations.test.tsx +1 -1
- package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/settings.test.tsx +1 -1
- package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/team.test.tsx +1 -1
- package/templates/base/{src/client/__tests__ → tests/unit/client}/routes/authenticated-layout.test.tsx +1 -1
- package/templates/base/{src/client/__tests__ → tests/unit/client}/routes/dashboard.test.tsx +1 -1
- package/templates/base/{src/client/routes/__tests__ → tests/unit/client/routes}/invite.test.tsx +1 -1
- package/templates/base/{src/client/__tests__ → tests/unit/client}/routes/login.test.tsx +1 -1
- package/templates/base/{src/client/__tests__ → tests/unit/client}/routes/navigation.test.tsx +1 -1
- package/templates/base/{src/client/__tests__ → tests/unit/client}/routes/root-layout.test.tsx +1 -1
- package/templates/base/{src/server/auth/__tests__ → tests/unit/server/auth}/guards.test.ts +2 -2
- package/templates/base/{src → tests/unit}/server/auth/permissions.test.ts +1 -1
- package/templates/base/{src → tests/unit}/server/auth/roles.test.ts +1 -1
- package/templates/base/tests/unit/server/db/sql.test.ts +68 -0
- package/templates/base/{src → tests/unit}/server/env.test.ts +1 -1
- package/templates/base/tests/unit/server/lib/audited-db.test.ts +78 -0
- package/templates/base/{src → tests/unit}/server/lib/email.test.ts +1 -1
- package/templates/base/{src → tests/unit}/server/lib/errors.test.ts +1 -1
- package/templates/base/{src → tests/unit}/server/lib/oauth.test.ts +1 -1
- package/templates/base/{src → tests/unit}/server/lib/pagination.test.ts +1 -1
- package/templates/base/{src → tests/unit}/server/lib/password.test.ts +1 -1
- package/templates/base/{src → tests/unit}/server/lib/providers.test.ts +1 -1
- package/templates/base/{src → tests/unit}/server/lib/r2-storage.test.ts +2 -2
- package/templates/base/{src → tests/unit}/server/lib/session.test.ts +2 -2
- package/templates/base/{src → tests/unit}/server/lib/tokens.test.ts +1 -1
- package/templates/base/{src → tests/unit}/server/lib/transaction.test.ts +5 -14
- package/templates/base/{src → tests/unit}/server/middleware/account.test.ts +16 -24
- package/templates/base/{src → tests/unit}/server/middleware/auth.test.ts +71 -42
- package/templates/base/{src → tests/unit}/server/middleware/cors.test.ts +1 -1
- package/templates/base/{src → tests/unit}/server/middleware/error-handler.test.ts +2 -2
- package/templates/base/{src → tests/unit}/server/middleware/rate-limit.test.ts +3 -2
- package/templates/base/{src → tests/unit}/server/middleware/request-context.test.ts +1 -1
- package/templates/base/{src → tests/unit}/server/middleware/request-logger.test.ts +1 -1
- package/templates/base/{src/server/__tests__/mocks/__tests__ → tests/unit/server/mocks}/db.test.ts +1 -1
- package/templates/base/{src/server/__tests__/mocks/__tests__ → tests/unit/server/mocks}/kv.test.ts +1 -1
- package/templates/base/{src/server/__tests__/mocks/__tests__ → tests/unit/server/mocks}/r2.test.ts +1 -1
- package/templates/base/{src/server/routes/accounts/__tests__ → tests/unit/server/routes/accounts}/handlers.test.ts +12 -12
- package/templates/base/{src/server/routes/audits/__tests__ → tests/unit/server/routes/audits}/handlers.test.ts +11 -11
- package/templates/base/{src/server/routes/auth/__tests__ → tests/unit/server/routes/auth}/handlers.test.ts +13 -13
- package/templates/base/{src/server/routes/health/__tests__ → tests/unit/server/routes/health}/handlers.test.ts +27 -23
- package/templates/base/{src/server/routes/invitations/__tests__ → tests/unit/server/routes/invitations}/handlers.test.ts +14 -17
- package/templates/base/{src/server/routes/storage/__tests__ → tests/unit/server/routes/storage}/handlers.test.ts +6 -6
- package/templates/base/{src/server/routes/users/__tests__ → tests/unit/server/routes/users}/handlers.test.ts +12 -12
- package/templates/base/tests/unit/server/services/accounts.test.ts +258 -0
- package/templates/base/tests/unit/server/services/audits.test.ts +141 -0
- package/templates/base/tests/unit/server/services/auth.test.ts +179 -0
- package/templates/base/tests/unit/server/services/invitations.test.ts +165 -0
- package/templates/base/tests/unit/server/services/users.test.ts +351 -0
- package/templates/base/tsconfig.json +2 -1
- package/templates/base/vitest.config.browser.ts +3 -2
- package/templates/base/vitest.config.frontend.ts +3 -2
- package/templates/base/vitest.config.ts +7 -14
- package/templates/base/.claude/settings.local.json +0 -11
- package/templates/base/config/drizzle.config.ts +0 -10
- package/templates/base/src/server/db/schema/accounts.ts +0 -20
- package/templates/base/src/server/db/schema/audit-logs.ts +0 -26
- package/templates/base/src/server/db/schema/index.ts +0 -7
- package/templates/base/src/server/db/schema/invitations.ts +0 -30
- package/templates/base/src/server/db/schema/refresh-tokens.ts +0 -22
- package/templates/base/src/server/db/schema/user-accounts.ts +0 -25
- package/templates/base/src/server/db/schema/users.ts +0 -33
- package/templates/base/src/server/lib/audited-db.test.ts +0 -107
- package/templates/base/src/server/lib/schema-helpers.ts +0 -16
- package/templates/base/src/server/services/__tests__/accounts.test.ts +0 -764
- package/templates/base/src/server/services/__tests__/audits.test.ts +0 -235
- package/templates/base/src/server/services/__tests__/auth.test.ts +0 -765
- package/templates/base/src/server/services/__tests__/invitations.test.ts +0 -704
- package/templates/base/src/server/services/__tests__/users.test.ts +0 -755
- package/templates/base/tests/integration/lib/schema-helpers.test.ts +0 -129
- /package/templates/base/{src/client/components/__tests__ → tests/unit/client/components}/__screenshots__/sidebar.test.tsx/Sidebar-can-be-collapsed-by-default-1.png +0 -0
- /package/templates/base/{src/client/components/__tests__ → tests/unit/client/components}/__screenshots__/sidebar.test.tsx/Sidebar-expands-when-collapsed-and-expand-button-is-clicked-1.png +0 -0
- /package/templates/base/{src/client/components/__tests__ → tests/unit/client/components}/__screenshots__/sidebar.test.tsx/Sidebar-handles-logout-button-click-1.png +0 -0
- /package/templates/base/{src/client/components/__tests__ → tests/unit/client/components}/__screenshots__/sidebar.test.tsx/Sidebar-handles-navigation-clicks-1.png +0 -0
- /package/templates/base/{src/client/components/__tests__ → tests/unit/client/components}/__screenshots__/sidebar.test.tsx/Sidebar-hides-navigation-labels-when-collapsed-1.png +0 -0
- /package/templates/base/{src/client/components/__tests__ → tests/unit/client/components}/__screenshots__/sidebar.test.tsx/Sidebar-highlights-active-route-1.png +0 -0
- /package/templates/base/{src/client/components/__tests__ → tests/unit/client/components}/__screenshots__/sidebar.test.tsx/Sidebar-renders-sidebar-navigation-items-1.png +0 -0
- /package/templates/base/{src/client/components/__tests__ → tests/unit/client/components}/__screenshots__/sidebar.test.tsx/Sidebar-shows-keyboard-shortcut-hint-when-expanded-1.png +0 -0
- /package/templates/base/{src/client/components/__tests__ → tests/unit/client/components}/__screenshots__/sidebar.test.tsx/Sidebar-shows-user-info-when-authenticated-1.png +0 -0
- /package/templates/base/{src/client/components/__tests__ → tests/unit/client/components}/__screenshots__/sidebar.test.tsx/Sidebar-shows-user-initials-in-avatar-fallback-1.png +0 -0
- /package/templates/base/{src/client/components/__tests__ → tests/unit/client/components}/error-boundary.test.tsx +0 -0
- /package/templates/base/{src/client/components/ui/__tests__ → tests/unit/client/components/ui}/error-fallback.test.tsx +0 -0
- /package/templates/base/{src/client/hooks/__tests__ → tests/unit/client/hooks}/use-auth.test.tsx +0 -0
- /package/templates/base/{src/client/hooks/__tests__ → tests/unit/client/hooks}/use-theme.test.tsx +0 -0
- /package/templates/base/{src/client/__tests__ → tests/unit/client}/routes/__screenshots__/dashboard.test.tsx/Dashboard-Page-when-authenticated-should-display-dashboard-stats-cards-1.png +0 -0
- /package/templates/base/{src/client/__tests__ → tests/unit/client}/routes/__screenshots__/dashboard.test.tsx/Dashboard-Page-when-authenticated-should-display-quick-action-cards-1.png +0 -0
- /package/templates/base/{src/client/__tests__ → tests/unit/client}/routes/__screenshots__/dashboard.test.tsx/Dashboard-Page-when-authenticated-should-display-recent-activity-section-1.png +0 -0
- /package/templates/base/{src/client/__tests__ → tests/unit/client}/routes/__screenshots__/dashboard.test.tsx/Dashboard-Page-when-authenticated-should-display-user-first-name-in-welcome-message-1.png +0 -0
- /package/templates/base/{src/client/__tests__ → tests/unit/client}/routes/__screenshots__/dashboard.test.tsx/Dashboard-Page-when-authenticated-should-display-user-information-in-sidebar-1.png +0 -0
- /package/templates/base/{src/client/__tests__ → tests/unit/client}/routes/__screenshots__/dashboard.test.tsx/Dashboard-Page-when-authenticated-should-render-dashboard-when-authenticated-1.png +0 -0
- /package/templates/base/{src/client/__tests__ → tests/unit/client}/routes/__screenshots__/dashboard.test.tsx/Dashboard-Page-when-authenticated-should-show-navigation-sidebar-1.png +0 -0
- /package/templates/base/{src/client/__tests__ → tests/unit/client}/routes/__screenshots__/dashboard.test.tsx/Dashboard-Page-when-unauthenticated-should-redirect-to-login-when-not-authenticated-1.png +0 -0
- /package/templates/base/{src/client/routes/__tests__ → tests/unit/client/routes}/__screenshots__/invite.test.tsx/Invite-Token-Page-pending-invitation-state-should-display-accept-invitation-button-1.png +0 -0
- /package/templates/base/{src/client/routes/__tests__ → tests/unit/client/routes}/__screenshots__/invite.test.tsx/Invite-Token-Page-pending-invitation-state-should-display-decline-button-linking-to-homepage-1.png +0 -0
- /package/templates/base/{src/client/routes/__tests__ → tests/unit/client/routes}/__screenshots__/invite.test.tsx/Invite-Token-Page-pending-invitation-state-should-display-invitation-details--email--workspace--role--1.png +0 -0
- /package/templates/base/{src/client/routes/__tests__ → tests/unit/client/routes}/__screenshots__/invite.test.tsx/Invite-Token-Page-pending-invitation-state-should-have-a-logo-link-to-homepage-1.png +0 -0
- /package/templates/base/{src/client/routes/__tests__ → tests/unit/client/routes}/__screenshots__/invite.test.tsx/Invite-Token-Page-pending-invitation-state-should-render-invitation-page-with-inviter-name-and-workspace-1.png +0 -0
- /package/templates/base/{src/client/routes/__tests__ → tests/unit/client/routes}/__screenshots__/invite.test.tsx/Invite-Token-Page-pending-invitation-state-should-show-terms-of-service-and-privacy-policy-links-1.png +0 -0
- /package/templates/base/{src/client/__tests__ → tests/unit/client}/routes/__screenshots__/login.test.tsx/Login-Page-should-display-Google-OAuth-login-button-1.png +0 -0
- /package/templates/base/{src/client/__tests__ → tests/unit/client}/routes/__screenshots__/login.test.tsx/Login-Page-should-have-a-link-back-to-home-page-1.png +0 -0
- /package/templates/base/{src/client/__tests__ → tests/unit/client}/routes/__screenshots__/login.test.tsx/Login-Page-should-render-login-content-without-waiting-for-authentication-1.png +0 -0
- /package/templates/base/{src/client/__tests__ → tests/unit/client}/routes/__screenshots__/login.test.tsx/Login-Page-should-render-login-page-at--login-route-1.png +0 -0
- /package/templates/base/{src/client/__tests__ → tests/unit/client}/routes/__screenshots__/login.test.tsx/Login-Page-should-show-Terms-of-Service-and-Privacy-Policy-links-1.png +0 -0
- /package/templates/base/{src/client/__tests__ → tests/unit/client}/routes/__screenshots__/login.test.tsx/Login-Page-should-trigger-OAuth-flow-when-clicking-login-button-1.png +0 -0
- /package/templates/base/{src/client/__tests__ → tests/unit/client}/routes/__screenshots__/navigation.test.tsx/Navigation-404-handling-should-display-404-text-on-not-found-page-1.png +0 -0
- /package/templates/base/{src/client/__tests__ → tests/unit/client}/routes/__screenshots__/navigation.test.tsx/Navigation-404-handling-should-have-navigation-options-on-404-page-1.png +0 -0
- /package/templates/base/{src/client/__tests__ → tests/unit/client}/routes/__screenshots__/navigation.test.tsx/Navigation-404-handling-should-render-404-page-for-unknown-routes-1.png +0 -0
- /package/templates/base/{src/client/__tests__ → tests/unit/client}/routes/__screenshots__/navigation.test.tsx/Navigation-authenticated-navigation-should-navigate-from-dashboard-to-account-page-1.png +0 -0
- /package/templates/base/{src/client/__tests__ → tests/unit/client}/routes/__screenshots__/navigation.test.tsx/Navigation-authenticated-navigation-should-navigate-from-dashboard-to-integrations-page-1.png +0 -0
- /package/templates/base/{src/client/__tests__ → tests/unit/client}/routes/__screenshots__/navigation.test.tsx/Navigation-authenticated-navigation-should-navigate-from-dashboard-to-settings-page-1.png +0 -0
- /package/templates/base/{src/client/__tests__ → tests/unit/client}/routes/__screenshots__/navigation.test.tsx/Navigation-authenticated-navigation-should-navigate-from-dashboard-to-team-page-1.png +0 -0
- /package/templates/base/{src/client/__tests__ → tests/unit/client}/routes/__screenshots__/navigation.test.tsx/Navigation-home-page-navigation-should-display-navigation-links-on-home-page-1.png +0 -0
- /package/templates/base/{src/client/__tests__ → tests/unit/client}/routes/__screenshots__/navigation.test.tsx/Navigation-home-page-navigation-should-have-correct-link-destinations-on-home-page-1.png +0 -0
- /package/templates/base/{src/client/__tests__ → tests/unit/client}/routes/__screenshots__/navigation.test.tsx/Navigation-unauthenticated-navigation-should-allow-access-to-home-page-without-authentication-1.png +0 -0
- /package/templates/base/{src/client/__tests__ → tests/unit/client}/routes/__screenshots__/navigation.test.tsx/Navigation-unauthenticated-navigation-should-allow-access-to-login-page-without-authentication-1.png +0 -0
- /package/templates/base/{src/client/__tests__ → tests/unit/client}/routes/__screenshots__/navigation.test.tsx/Navigation-unauthenticated-navigation-should-redirect-unauthenticated-users-from-dashboard-to-login-1.png +0 -0
- /package/templates/base/{src/client/__tests__ → tests/unit/client}/routes/__screenshots__/navigation.test.tsx/Navigation-unauthenticated-navigation-should-redirect-unauthenticated-users-from-settings-to-login-1.png +0 -0
- /package/templates/base/{src/client/__tests__ → tests/unit/client}/routes/__screenshots__/navigation.test.tsx/Navigation-unauthenticated-navigation-should-redirect-unauthenticated-users-from-team-to-login-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/account.test.tsx/Account-Page-should-render-Active-Sessions-section-with-session-cards-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/account.test.tsx/Account-Page-should-render-page-with-correct-title--Account--1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/account.test.tsx/Account-Page-should-show-API-Access-section-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/account.test.tsx/Account-Page-should-show-Connected-Accounts-section-with-Google-connected-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/account.test.tsx/Account-Page-should-show-Danger-Zone-section-with-delete-button-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/account.test.tsx/Account-Page-should-show-Security-section-with-Two-Factor-Authentication-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/integrations.test.tsx/Integrations-Page-API-documentation-section-should-display-API-documentation-link-section-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/integrations.test.tsx/Integrations-Page-Create-Webhook-Dialog-should-have-Add-Webhook-trigger-button-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/integrations.test.tsx/Integrations-Page-category-filters-should-display-all-category-buttons-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/integrations.test.tsx/Integrations-Page-integration-cards-should-display-all-integration-cards-with-names-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/integrations.test.tsx/Integrations-Page-integration-cards-should-display-category-badges-on-cards-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/integrations.test.tsx/Integrations-Page-integration-cards-should-show-Configure-button-for-connected-integrations-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/integrations.test.tsx/Integrations-Page-integration-cards-should-show-Connect-button-for-not-connected-integrations-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/integrations.test.tsx/Integrations-Page-integration-cards-should-show-Connected-badge-for-connected-integrations-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/integrations.test.tsx/Integrations-Page-page-rendering-should-display-Available-Integrations-section-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/integrations.test.tsx/Integrations-Page-page-rendering-should-display-Webhooks-section-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/integrations.test.tsx/Integrations-Page-page-rendering-should-display-connected-count-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/integrations.test.tsx/Integrations-Page-page-rendering-should-display-page-description-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/integrations.test.tsx/Integrations-Page-page-rendering-should-display-search-input-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/integrations.test.tsx/Integrations-Page-page-rendering-should-render-with-correct-title--Integrations--1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/integrations.test.tsx/Integrations-Page-search-functionality-should-filter-integrations-based-on-search-query-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/integrations.test.tsx/Integrations-Page-search-functionality-should-search-by-description-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/integrations.test.tsx/Integrations-Page-search-functionality-should-show-no-results-message-when-search-has-no-matches-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/integrations.test.tsx/Integrations-Page-webhooks-section-should-display-existing-webhook-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/integrations.test.tsx/Integrations-Page-webhooks-section-should-display-webhook-events-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/integrations.test.tsx/Integrations-Page-webhooks-section-should-display-webhook-last-delivery-info-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/integrations.test.tsx/Integrations-Page-webhooks-section-should-display-webhook-success-status-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/integrations.test.tsx/Integrations-Page-webhooks-section-should-have-Add-Webhook-button-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/settings.test.tsx/Settings-Page-Account-tab-should-display-connected-accounts-section-with-Google-provider-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/settings.test.tsx/Settings-Page-Account-tab-should-display-sessions-and-danger-zone-sections-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/settings.test.tsx/Settings-Page-Notifications-tab-should-display-all-notification-toggle-options-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/settings.test.tsx/Settings-Page-Notifications-tab-should-display-email-notifications-section-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/settings.test.tsx/Settings-Page-Notifications-tab-should-display-toggle-switches-for-notification-options-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/settings.test.tsx/Settings-Page-Notifications-tab-should-have-toggles-checked-by-default-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/settings.test.tsx/Settings-Page-Profile-tab-should-display--Save-Changes--button-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/settings.test.tsx/Settings-Page-Profile-tab-should-display-personal-information-form-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/settings.test.tsx/Settings-Page-Profile-tab-should-display-profile-picture-section-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/settings.test.tsx/Settings-Page-Profile-tab-should-display-user-email-in-disabled-email-input-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/settings.test.tsx/Settings-Page-Profile-tab-should-display-user-initials-in-avatar-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/settings.test.tsx/Settings-Page-Profile-tab-should-display-user-name-in-the-name-input-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/settings.test.tsx/Settings-Page-page-rendering-should-display-all-three-tabs-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/settings.test.tsx/Settings-Page-page-rendering-should-display-page-description-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/settings.test.tsx/Settings-Page-page-rendering-should-render-with-correct-title--Settings--1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/settings.test.tsx/Settings-Page-tab-navigation-should-show-Profile-tab-as-default-active-tab-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/settings.test.tsx/Settings-Page-tab-navigation-should-switch-to-Account-tab-when-clicked-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/settings.test.tsx/Settings-Page-tab-navigation-should-switch-to-Notifications-tab-when-clicked-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/team.test.tsx/Team-Page-should-display-Active-Members-section-with-member-count-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/team.test.tsx/Team-Page-should-display-Pending-Invitations-section-with-invitation-details-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/team.test.tsx/Team-Page-should-have-invite-member-button-that-can-be-clicked-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/team.test.tsx/Team-Page-should-render-page-with-correct-title-and-description-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/team.test.tsx/Team-Page-should-render-search-input-that-filters-team-members-1.png +0 -0
- /package/templates/base/{src/client/routes/_authenticated/__tests__ → tests/unit/client/routes/_authenticated}/__screenshots__/team.test.tsx/Team-Page-should-show-current-user-with---you---indicator-and-role-badge-1.png +0 -0
- /package/templates/base/{src/client/__tests__ → tests/unit/client}/routes/error-components.test.tsx +0 -0
- /package/templates/base/{src/shared/schemas/__tests__ → tests/unit/shared}/schemas.test.ts +0 -0
|
@@ -1,28 +1,27 @@
|
|
|
1
1
|
// src/server/middleware/account.test.ts
|
|
2
2
|
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
3
3
|
import { Hono } from 'hono'
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import type { HonoEnv } from '@server/types'
|
|
5
|
+
import { accountMiddleware } from '@server/middleware/account'
|
|
6
|
+
import { createUserFixture, createSuperAdminFixture } from '@tests/fixtures/server'
|
|
7
|
+
import { createMockEnv, setMockQueryResult } from '@tests/helpers/server'
|
|
6
8
|
|
|
7
9
|
describe('accountMiddleware', () => {
|
|
8
|
-
|
|
9
|
-
let mockDb:
|
|
10
|
+
let env: ReturnType<typeof createMockEnv>
|
|
11
|
+
let mockDb: ReturnType<typeof createMockEnv>['DB']['_mock']
|
|
10
12
|
|
|
11
13
|
beforeEach(() => {
|
|
12
14
|
vi.clearAllMocks()
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
from: vi.fn().mockReturnThis(),
|
|
16
|
-
where: vi.fn().mockReturnThis(),
|
|
17
|
-
limit: vi.fn(),
|
|
18
|
-
}
|
|
15
|
+
env = createMockEnv()
|
|
16
|
+
mockDb = env.DB._mock
|
|
19
17
|
})
|
|
20
18
|
|
|
21
19
|
const createApp = (setupUser?: (app: Hono) => void) => {
|
|
22
|
-
const app = new Hono()
|
|
23
|
-
// Setup mock db in context
|
|
20
|
+
const app = new Hono<HonoEnv>()
|
|
21
|
+
// Setup mock db in context + env
|
|
24
22
|
app.use('*', async (c, next) => {
|
|
25
|
-
c.
|
|
23
|
+
;(c as any).env = env
|
|
24
|
+
c.set('db', env.DB)
|
|
26
25
|
await next()
|
|
27
26
|
})
|
|
28
27
|
// Setup user if provided
|
|
@@ -119,9 +118,7 @@ describe('accountMiddleware', () => {
|
|
|
119
118
|
})
|
|
120
119
|
|
|
121
120
|
// Mock membership exists
|
|
122
|
-
mockDb
|
|
123
|
-
{ userId: 'user-123', accountId: 'account-123', role: 'VIEWER' },
|
|
124
|
-
])
|
|
121
|
+
setMockQueryResult(mockDb, ['user-123', 'account-123'], { role: 'VIEWER' })
|
|
125
122
|
|
|
126
123
|
const res = await app.request('/test', {
|
|
127
124
|
headers: { 'account-id': 'account-123' },
|
|
@@ -143,9 +140,7 @@ describe('accountMiddleware', () => {
|
|
|
143
140
|
})
|
|
144
141
|
|
|
145
142
|
// Mock membership with ADMIN role
|
|
146
|
-
mockDb
|
|
147
|
-
{ userId: 'user-123', accountId: 'account-123', role: 'ADMIN' },
|
|
148
|
-
])
|
|
143
|
+
setMockQueryResult(mockDb, ['user-123', 'account-123'], { role: 'ADMIN' })
|
|
149
144
|
|
|
150
145
|
const res = await app.request('/test', {
|
|
151
146
|
headers: { 'account-id': 'account-123' },
|
|
@@ -167,9 +162,7 @@ describe('accountMiddleware', () => {
|
|
|
167
162
|
})
|
|
168
163
|
|
|
169
164
|
// Mock membership with VIEWER role
|
|
170
|
-
mockDb
|
|
171
|
-
{ userId: 'user-123', accountId: 'account-123', role: 'VIEWER' },
|
|
172
|
-
])
|
|
165
|
+
setMockQueryResult(mockDb, ['user-123', 'account-123'], { role: 'VIEWER' })
|
|
173
166
|
|
|
174
167
|
const res = await app.request('/test', {
|
|
175
168
|
headers: { 'account-id': 'account-123' },
|
|
@@ -189,8 +182,7 @@ describe('accountMiddleware', () => {
|
|
|
189
182
|
})
|
|
190
183
|
})
|
|
191
184
|
|
|
192
|
-
//
|
|
193
|
-
mockDb.limit.mockResolvedValue([])
|
|
185
|
+
// No query result -> no membership
|
|
194
186
|
|
|
195
187
|
const res = await app.request('/test', {
|
|
196
188
|
headers: { 'account-id': 'account-123' },
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
// src/server/middleware/auth.test.ts
|
|
2
2
|
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
3
3
|
import { Hono } from 'hono'
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import type { HonoEnv } from '@server/types'
|
|
5
|
+
import { sessionAuth, jwtAuth } from '@server/middleware/auth'
|
|
6
|
+
import { createUserFixture, createInactiveUserFixture } from '@tests/fixtures/server'
|
|
7
|
+
import { createMockEnv, setMockQueryResult } from '@tests/helpers/server'
|
|
6
8
|
|
|
7
9
|
// Mock the session module
|
|
8
|
-
vi.mock('
|
|
10
|
+
vi.mock('@server/lib/session', () => ({
|
|
9
11
|
getSession: vi.fn(),
|
|
10
12
|
}))
|
|
11
13
|
|
|
@@ -14,19 +16,25 @@ vi.mock('hono/jwt', () => ({
|
|
|
14
16
|
verify: vi.fn(),
|
|
15
17
|
}))
|
|
16
18
|
|
|
17
|
-
import { getSession } from '
|
|
19
|
+
import { getSession } from '@server/lib/session'
|
|
18
20
|
import { verify } from 'hono/jwt'
|
|
19
21
|
|
|
20
22
|
describe('sessionAuth', () => {
|
|
23
|
+
let env: ReturnType<typeof createMockEnv>
|
|
24
|
+
let mockDb: ReturnType<typeof createMockEnv>['DB']['_mock']
|
|
25
|
+
|
|
21
26
|
beforeEach(() => {
|
|
22
27
|
vi.clearAllMocks()
|
|
28
|
+
env = createMockEnv()
|
|
29
|
+
mockDb = env.DB._mock
|
|
23
30
|
})
|
|
24
31
|
|
|
25
32
|
const createApp = () => {
|
|
26
|
-
const app = new Hono()
|
|
27
|
-
// Setup mock db in context
|
|
33
|
+
const app = new Hono<HonoEnv>()
|
|
34
|
+
// Setup mock db in context + env
|
|
28
35
|
app.use('*', async (c, next) => {
|
|
29
|
-
c.
|
|
36
|
+
;(c as any).env = env
|
|
37
|
+
c.set('db', env.DB)
|
|
30
38
|
await next()
|
|
31
39
|
})
|
|
32
40
|
app.use('*', sessionAuth)
|
|
@@ -37,16 +45,16 @@ describe('sessionAuth', () => {
|
|
|
37
45
|
return app
|
|
38
46
|
}
|
|
39
47
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
const toUserRow = (user: ReturnType<typeof createUserFixture>) => ({
|
|
49
|
+
id: user.id,
|
|
50
|
+
email: user.email,
|
|
51
|
+
name: user.name,
|
|
52
|
+
status: user.status,
|
|
53
|
+
providerIds: user.providerIds,
|
|
54
|
+
isSuperAdmin: user.isSuperAdmin,
|
|
55
|
+
createdAt: user.createdAt,
|
|
56
|
+
updatedAt: user.updatedAt,
|
|
57
|
+
deletedAt: user.deletedAt,
|
|
50
58
|
})
|
|
51
59
|
|
|
52
60
|
it('calls next() when valid session exists', async () => {
|
|
@@ -61,7 +69,7 @@ describe('sessionAuth', () => {
|
|
|
61
69
|
})
|
|
62
70
|
|
|
63
71
|
// Mock db returns user
|
|
64
|
-
mockDb
|
|
72
|
+
setMockQueryResult(mockDb, ['user-123'], toUserRow(testUser))
|
|
65
73
|
|
|
66
74
|
const app = createApp()
|
|
67
75
|
const res = await app.request('/test')
|
|
@@ -89,8 +97,7 @@ describe('sessionAuth', () => {
|
|
|
89
97
|
isSuperAdmin: false,
|
|
90
98
|
})
|
|
91
99
|
|
|
92
|
-
//
|
|
93
|
-
mockDb.limit.mockResolvedValue([])
|
|
100
|
+
// No query result -> user not found
|
|
94
101
|
|
|
95
102
|
const app = createApp()
|
|
96
103
|
const res = await app.request('/test')
|
|
@@ -109,7 +116,7 @@ describe('sessionAuth', () => {
|
|
|
109
116
|
})
|
|
110
117
|
|
|
111
118
|
// Mock db returns inactive user
|
|
112
|
-
mockDb
|
|
119
|
+
setMockQueryResult(mockDb, ['user-123'], toUserRow(inactiveUser))
|
|
113
120
|
|
|
114
121
|
const app = createApp()
|
|
115
122
|
const res = await app.request('/test')
|
|
@@ -134,7 +141,7 @@ describe('sessionAuth', () => {
|
|
|
134
141
|
isSuperAdmin: true,
|
|
135
142
|
})
|
|
136
143
|
|
|
137
|
-
mockDb
|
|
144
|
+
setMockQueryResult(mockDb, ['user-123'], toUserRow(testUser))
|
|
138
145
|
|
|
139
146
|
const app = createApp()
|
|
140
147
|
const res = await app.request('/test')
|
|
@@ -153,28 +160,21 @@ describe('sessionAuth', () => {
|
|
|
153
160
|
})
|
|
154
161
|
|
|
155
162
|
describe('jwtAuth', () => {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
})
|
|
159
|
-
|
|
160
|
-
// Create mock database
|
|
161
|
-
let mockDb: any
|
|
163
|
+
let env: ReturnType<typeof createMockEnv>
|
|
164
|
+
let mockDb: ReturnType<typeof createMockEnv>['DB']['_mock']
|
|
162
165
|
|
|
163
166
|
beforeEach(() => {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
where: vi.fn().mockReturnThis(),
|
|
168
|
-
limit: vi.fn(),
|
|
169
|
-
}
|
|
167
|
+
vi.clearAllMocks()
|
|
168
|
+
env = createMockEnv()
|
|
169
|
+
mockDb = env.DB._mock
|
|
170
170
|
})
|
|
171
171
|
|
|
172
172
|
const createApp = () => {
|
|
173
|
-
const app = new Hono<
|
|
173
|
+
const app = new Hono<HonoEnv>()
|
|
174
174
|
// Setup mock db and env in context
|
|
175
175
|
app.use('*', async (c, next) => {
|
|
176
|
-
c.
|
|
177
|
-
|
|
176
|
+
;(c as any).env = env
|
|
177
|
+
c.set('db', env.DB)
|
|
178
178
|
await next()
|
|
179
179
|
})
|
|
180
180
|
app.use('*', jwtAuth)
|
|
@@ -197,7 +197,17 @@ describe('jwtAuth', () => {
|
|
|
197
197
|
})
|
|
198
198
|
|
|
199
199
|
// Mock db returns user
|
|
200
|
-
mockDb
|
|
200
|
+
setMockQueryResult(mockDb, ['user-123'], {
|
|
201
|
+
id: testUser.id,
|
|
202
|
+
email: testUser.email,
|
|
203
|
+
name: testUser.name,
|
|
204
|
+
status: testUser.status,
|
|
205
|
+
providerIds: testUser.providerIds,
|
|
206
|
+
isSuperAdmin: testUser.isSuperAdmin,
|
|
207
|
+
createdAt: testUser.createdAt,
|
|
208
|
+
updatedAt: testUser.updatedAt,
|
|
209
|
+
deletedAt: testUser.deletedAt,
|
|
210
|
+
})
|
|
201
211
|
|
|
202
212
|
const app = createApp()
|
|
203
213
|
const res = await app.request('/test', {
|
|
@@ -275,8 +285,7 @@ describe('jwtAuth', () => {
|
|
|
275
285
|
exp: Date.now() + 3600000,
|
|
276
286
|
})
|
|
277
287
|
|
|
278
|
-
//
|
|
279
|
-
mockDb.limit.mockResolvedValue([])
|
|
288
|
+
// No query result -> user not found
|
|
280
289
|
|
|
281
290
|
const app = createApp()
|
|
282
291
|
const res = await app.request('/test', {
|
|
@@ -297,7 +306,17 @@ describe('jwtAuth', () => {
|
|
|
297
306
|
})
|
|
298
307
|
|
|
299
308
|
// Mock db returns inactive user
|
|
300
|
-
mockDb
|
|
309
|
+
setMockQueryResult(mockDb, ['user-123'], {
|
|
310
|
+
id: inactiveUser.id,
|
|
311
|
+
email: inactiveUser.email,
|
|
312
|
+
name: inactiveUser.name,
|
|
313
|
+
status: inactiveUser.status,
|
|
314
|
+
providerIds: inactiveUser.providerIds,
|
|
315
|
+
isSuperAdmin: inactiveUser.isSuperAdmin,
|
|
316
|
+
createdAt: inactiveUser.createdAt,
|
|
317
|
+
updatedAt: inactiveUser.updatedAt,
|
|
318
|
+
deletedAt: inactiveUser.deletedAt,
|
|
319
|
+
})
|
|
301
320
|
|
|
302
321
|
const app = createApp()
|
|
303
322
|
const res = await app.request('/test', {
|
|
@@ -324,7 +343,17 @@ describe('jwtAuth', () => {
|
|
|
324
343
|
exp: Date.now() + 3600000,
|
|
325
344
|
})
|
|
326
345
|
|
|
327
|
-
mockDb
|
|
346
|
+
setMockQueryResult(mockDb, ['user-123'], {
|
|
347
|
+
id: testUser.id,
|
|
348
|
+
email: testUser.email,
|
|
349
|
+
name: testUser.name,
|
|
350
|
+
status: testUser.status,
|
|
351
|
+
providerIds: testUser.providerIds,
|
|
352
|
+
isSuperAdmin: testUser.isSuperAdmin,
|
|
353
|
+
createdAt: testUser.createdAt,
|
|
354
|
+
updatedAt: testUser.updatedAt,
|
|
355
|
+
deletedAt: testUser.deletedAt,
|
|
356
|
+
})
|
|
328
357
|
|
|
329
358
|
const app = createApp()
|
|
330
359
|
const res = await app.request('/test', {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest'
|
|
2
2
|
import { Hono } from 'hono'
|
|
3
|
-
import { configurableCors } from '
|
|
3
|
+
import { configurableCors } from '@server/middleware/cors'
|
|
4
4
|
|
|
5
5
|
describe('configurableCors', () => {
|
|
6
6
|
it('allows origin from CORS_ORIGINS list', async () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest'
|
|
2
2
|
import { Hono } from 'hono'
|
|
3
|
-
import { errorHandler } from '
|
|
4
|
-
import { ValidationError, NotFoundError, InternalError } from '
|
|
3
|
+
import { errorHandler } from '@server/middleware/error-handler'
|
|
4
|
+
import { ValidationError, NotFoundError, InternalError } from '@server/lib/errors'
|
|
5
5
|
|
|
6
6
|
describe('errorHandler', () => {
|
|
7
7
|
const createApp = () => {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
|
|
2
2
|
import { Hono } from 'hono'
|
|
3
|
-
import type { HonoEnv } from '
|
|
3
|
+
import type { HonoEnv } from '@server/types'
|
|
4
4
|
import {
|
|
5
5
|
RateLimitStore,
|
|
6
6
|
globalStore,
|
|
7
7
|
rateLimit,
|
|
8
8
|
authRateLimit,
|
|
9
9
|
rateLimitWithStore,
|
|
10
|
-
} from '
|
|
10
|
+
} from '@server/middleware/rate-limit'
|
|
11
11
|
|
|
12
12
|
describe('RateLimitStore', () => {
|
|
13
13
|
let store: RateLimitStore
|
|
@@ -76,6 +76,7 @@ describe('RateLimitStore', () => {
|
|
|
76
76
|
describe('destroy', () => {
|
|
77
77
|
it('stops cleanup interval', () => {
|
|
78
78
|
const clearIntervalSpy = vi.spyOn(global, 'clearInterval')
|
|
79
|
+
store.startPeriodicCleanup()
|
|
79
80
|
store.destroy()
|
|
80
81
|
expect(clearIntervalSpy).toHaveBeenCalled()
|
|
81
82
|
clearIntervalSpy.mockRestore()
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/server/middleware/request-context.test.ts
|
|
2
2
|
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
3
3
|
import { Hono } from 'hono'
|
|
4
|
-
import { requestContext } from '
|
|
4
|
+
import { requestContext } from '@server/middleware/request-context'
|
|
5
5
|
|
|
6
6
|
// Mock uuidv7
|
|
7
7
|
vi.mock('uuidv7', () => ({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
|
|
2
2
|
import { Hono } from 'hono'
|
|
3
|
-
import { requestLogger } from '
|
|
3
|
+
import { requestLogger } from '@server/middleware/request-logger'
|
|
4
4
|
|
|
5
5
|
describe('requestLogger', () => {
|
|
6
6
|
let consoleSpy: ReturnType<typeof vi.spyOn>
|
package/templates/base/{src/server/__tests__/mocks/__tests__ → tests/unit/server/mocks}/kv.test.ts
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/server/__tests__/mocks/__tests__/kv.test.ts
|
|
2
2
|
import { describe, it, expect, beforeEach, vi } from 'vitest'
|
|
3
|
-
import { createMockKV, seedMockKV, clearMockKV, type MockKVNamespace } from '
|
|
3
|
+
import { createMockKV, seedMockKV, clearMockKV, type MockKVNamespace } from '@tests/mocks/kv'
|
|
4
4
|
|
|
5
5
|
describe('MockKVNamespace', () => {
|
|
6
6
|
let kv: MockKVNamespace
|
package/templates/base/{src/server/__tests__/mocks/__tests__ → tests/unit/server/mocks}/r2.test.ts
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/server/__tests__/mocks/__tests__/r2.test.ts
|
|
2
2
|
import { describe, it, expect, beforeEach, vi } from 'vitest'
|
|
3
|
-
import { createMockR2, seedMockR2, clearMockR2, type MockR2Bucket } from '
|
|
3
|
+
import { createMockR2, seedMockR2, clearMockR2, type MockR2Bucket } from '@tests/mocks/r2'
|
|
4
4
|
|
|
5
5
|
describe('MockR2Bucket', () => {
|
|
6
6
|
let r2: MockR2Bucket
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// src/server/routes/accounts/__tests__/handlers.test.ts
|
|
2
2
|
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
3
3
|
import { Hono } from 'hono'
|
|
4
|
-
import type { HonoEnv } from '
|
|
5
|
-
import { accounts } from '
|
|
6
|
-
import { createMockEnv } from '
|
|
4
|
+
import type { HonoEnv } from '@server/types'
|
|
5
|
+
import { accounts } from '@server/routes/index'
|
|
6
|
+
import { createMockEnv } from '@tests/helpers/server'
|
|
7
7
|
import {
|
|
8
8
|
createUserFixture,
|
|
9
9
|
createAccountFixture,
|
|
10
|
-
} from '
|
|
11
|
-
import { NotFoundError } from '
|
|
10
|
+
} from '@tests/fixtures/server'
|
|
11
|
+
import { NotFoundError } from '@server/lib/errors'
|
|
12
12
|
|
|
13
13
|
// Test UUIDs
|
|
14
14
|
const TEST_ACCOUNT_ID = '550e8400-e29b-41d4-a716-446655440001'
|
|
@@ -17,7 +17,7 @@ const TEST_USER_ID = '550e8400-e29b-41d4-a716-446655440101'
|
|
|
17
17
|
const NON_EXISTENT_ID = '550e8400-e29b-41d4-a716-446655440999'
|
|
18
18
|
|
|
19
19
|
// Mock the accounts service
|
|
20
|
-
vi.mock('
|
|
20
|
+
vi.mock('@server/services', () => ({
|
|
21
21
|
accountsService: {
|
|
22
22
|
findAll: vi.fn(),
|
|
23
23
|
findById: vi.fn(),
|
|
@@ -28,7 +28,7 @@ vi.mock('../../../services', () => ({
|
|
|
28
28
|
},
|
|
29
29
|
}))
|
|
30
30
|
|
|
31
|
-
import { accountsService } from '
|
|
31
|
+
import { accountsService } from '@server/services'
|
|
32
32
|
|
|
33
33
|
describe('Accounts Routes', () => {
|
|
34
34
|
let mockEnv: ReturnType<typeof createMockEnv>
|
|
@@ -139,7 +139,7 @@ describe('Accounts Routes', () => {
|
|
|
139
139
|
|
|
140
140
|
expect(res.status).toBe(200)
|
|
141
141
|
expect(accountsService.findAll).toHaveBeenCalledWith(
|
|
142
|
-
|
|
142
|
+
mockEnv.DB,
|
|
143
143
|
expect.objectContaining({
|
|
144
144
|
accountId: testAccount.id,
|
|
145
145
|
}),
|
|
@@ -174,7 +174,7 @@ describe('Accounts Routes', () => {
|
|
|
174
174
|
|
|
175
175
|
expect(res.status).toBe(200)
|
|
176
176
|
expect(accountsService.findAll).toHaveBeenCalledWith(
|
|
177
|
-
|
|
177
|
+
mockEnv.DB,
|
|
178
178
|
expect.anything(),
|
|
179
179
|
expect.objectContaining({
|
|
180
180
|
query: 'search',
|
|
@@ -232,7 +232,7 @@ describe('Accounts Routes', () => {
|
|
|
232
232
|
})
|
|
233
233
|
|
|
234
234
|
expect(accountsService.findById).toHaveBeenCalledWith(
|
|
235
|
-
|
|
235
|
+
mockEnv.DB,
|
|
236
236
|
expect.objectContaining({
|
|
237
237
|
accountId: testAccount.id,
|
|
238
238
|
user: expect.objectContaining({ id: testUser.id }),
|
|
@@ -295,7 +295,7 @@ describe('Accounts Routes', () => {
|
|
|
295
295
|
|
|
296
296
|
expect(res.status).toBe(201)
|
|
297
297
|
expect(accountsService.create).toHaveBeenCalledWith(
|
|
298
|
-
|
|
298
|
+
mockEnv.DB,
|
|
299
299
|
expect.anything(),
|
|
300
300
|
expect.objectContaining({
|
|
301
301
|
name: 'Domain Account',
|
|
@@ -389,7 +389,7 @@ describe('Accounts Routes', () => {
|
|
|
389
389
|
|
|
390
390
|
expect(res.status).toBe(204)
|
|
391
391
|
expect(accountsService.delete).toHaveBeenCalledWith(
|
|
392
|
-
|
|
392
|
+
mockEnv.DB,
|
|
393
393
|
expect.anything(),
|
|
394
394
|
TEST_ACCOUNT_ID
|
|
395
395
|
)
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
// src/server/routes/audits/__tests__/handlers.test.ts
|
|
2
2
|
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
3
3
|
import { Hono } from 'hono'
|
|
4
|
-
import type { HonoEnv } from '
|
|
5
|
-
import { audits } from '
|
|
6
|
-
import { createMockEnv } from '
|
|
7
|
-
import { createUserFixture, createAccountFixture } from '
|
|
4
|
+
import type { HonoEnv } from '@server/types'
|
|
5
|
+
import { audits } from '@server/routes/index'
|
|
6
|
+
import { createMockEnv } from '@tests/helpers/server'
|
|
7
|
+
import { createUserFixture, createAccountFixture } from '@tests/fixtures/server'
|
|
8
8
|
|
|
9
9
|
// Test UUIDs
|
|
10
10
|
const TEST_USER_ID = '550e8400-e29b-41d4-a716-446655440001'
|
|
11
11
|
const TEST_ACCOUNT_ID = '550e8400-e29b-41d4-a716-446655440101'
|
|
12
12
|
|
|
13
13
|
// Mock the audits service
|
|
14
|
-
vi.mock('
|
|
14
|
+
vi.mock('@server/services/audits', () => ({
|
|
15
15
|
auditsService: {
|
|
16
16
|
findAll: vi.fn(),
|
|
17
17
|
},
|
|
18
18
|
}))
|
|
19
19
|
|
|
20
|
-
import { auditsService } from '
|
|
20
|
+
import { auditsService } from '@server/services/audits'
|
|
21
21
|
|
|
22
22
|
describe('Audits Routes', () => {
|
|
23
23
|
let mockEnv: ReturnType<typeof createMockEnv>
|
|
@@ -149,7 +149,7 @@ describe('Audits Routes', () => {
|
|
|
149
149
|
|
|
150
150
|
expect(res.status).toBe(200)
|
|
151
151
|
expect(auditsService.findAll).toHaveBeenCalledWith(
|
|
152
|
-
|
|
152
|
+
mockEnv.DB,
|
|
153
153
|
expect.objectContaining({
|
|
154
154
|
accountId: testAccount.id,
|
|
155
155
|
}),
|
|
@@ -192,7 +192,7 @@ describe('Audits Routes', () => {
|
|
|
192
192
|
|
|
193
193
|
expect(res.status).toBe(200)
|
|
194
194
|
expect(auditsService.findAll).toHaveBeenCalledWith(
|
|
195
|
-
|
|
195
|
+
mockEnv.DB,
|
|
196
196
|
expect.objectContaining({
|
|
197
197
|
accountId: testAccount.id,
|
|
198
198
|
}),
|
|
@@ -230,7 +230,7 @@ describe('Audits Routes', () => {
|
|
|
230
230
|
|
|
231
231
|
expect(res.status).toBe(200)
|
|
232
232
|
expect(auditsService.findAll).toHaveBeenCalledWith(
|
|
233
|
-
|
|
233
|
+
mockEnv.DB,
|
|
234
234
|
expect.anything(),
|
|
235
235
|
expect.objectContaining({
|
|
236
236
|
page: 1,
|
|
@@ -263,7 +263,7 @@ describe('Audits Routes', () => {
|
|
|
263
263
|
|
|
264
264
|
expect(res.status).toBe(200)
|
|
265
265
|
expect(auditsService.findAll).toHaveBeenCalledWith(
|
|
266
|
-
|
|
266
|
+
mockEnv.DB,
|
|
267
267
|
expect.anything(),
|
|
268
268
|
expect.objectContaining({
|
|
269
269
|
page: 2,
|
|
@@ -310,7 +310,7 @@ describe('Audits Routes', () => {
|
|
|
310
310
|
|
|
311
311
|
expect(res.status).toBe(200)
|
|
312
312
|
expect(auditsService.findAll).toHaveBeenCalledWith(
|
|
313
|
-
|
|
313
|
+
mockEnv.DB,
|
|
314
314
|
expect.objectContaining({
|
|
315
315
|
accountId: testAccount.id,
|
|
316
316
|
}),
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
// src/server/routes/auth/__tests__/handlers.test.ts
|
|
2
2
|
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
3
3
|
import { Hono } from 'hono'
|
|
4
|
-
import type { HonoEnv } from '
|
|
5
|
-
import { auth } from '
|
|
6
|
-
import { createMockEnv } from '
|
|
4
|
+
import type { HonoEnv } from '@server/types'
|
|
5
|
+
import { auth } from '@server/routes/index'
|
|
6
|
+
import { createMockEnv } from '@tests/helpers/server'
|
|
7
7
|
import {
|
|
8
8
|
createUserFixture,
|
|
9
9
|
createSessionFixture,
|
|
10
|
-
} from '
|
|
10
|
+
} from '@tests/fixtures/server'
|
|
11
11
|
|
|
12
12
|
// Mock the session module
|
|
13
|
-
vi.mock('
|
|
13
|
+
vi.mock('@server/lib/session', async (importOriginal) => {
|
|
14
14
|
const original = await importOriginal<typeof import('../../../lib/session')>()
|
|
15
15
|
return {
|
|
16
16
|
...original,
|
|
@@ -21,7 +21,7 @@ vi.mock('../../../lib/session', async (importOriginal) => {
|
|
|
21
21
|
})
|
|
22
22
|
|
|
23
23
|
// Mock the oauth module
|
|
24
|
-
vi.mock('
|
|
24
|
+
vi.mock('@server/lib/oauth', () => ({
|
|
25
25
|
generateCodeVerifier: vi.fn(() => 'test-code-verifier'),
|
|
26
26
|
generateCodeChallenge: vi.fn(async () => 'test-code-challenge'),
|
|
27
27
|
generateState: vi.fn(() => 'test-state'),
|
|
@@ -31,12 +31,12 @@ vi.mock('../../../lib/oauth', () => ({
|
|
|
31
31
|
}))
|
|
32
32
|
|
|
33
33
|
// Mock audit module
|
|
34
|
-
vi.mock('
|
|
34
|
+
vi.mock('@server/lib/audit', () => ({
|
|
35
35
|
logAuthEvent: vi.fn().mockResolvedValue(),
|
|
36
36
|
}))
|
|
37
37
|
|
|
38
38
|
// Mock auth service
|
|
39
|
-
vi.mock('
|
|
39
|
+
vi.mock('@server/services/auth', () => ({
|
|
40
40
|
authService: {
|
|
41
41
|
findOrCreateUser: vi.fn(),
|
|
42
42
|
refreshAccessToken: vi.fn(),
|
|
@@ -44,20 +44,20 @@ vi.mock('../../../services/auth', () => ({
|
|
|
44
44
|
}))
|
|
45
45
|
|
|
46
46
|
// Mock invitations service
|
|
47
|
-
vi.mock('
|
|
47
|
+
vi.mock('@server/services/invitations', () => ({
|
|
48
48
|
invitationsService: {
|
|
49
49
|
getByToken: vi.fn(),
|
|
50
50
|
accept: vi.fn(),
|
|
51
51
|
},
|
|
52
52
|
}))
|
|
53
53
|
|
|
54
|
-
import { getSession, destroySession } from '
|
|
55
|
-
import { authService } from '
|
|
56
|
-
import { invitationsService } from '
|
|
54
|
+
import { getSession, destroySession } from '@server/lib/session'
|
|
55
|
+
import { authService } from '@server/services/auth'
|
|
56
|
+
import { invitationsService } from '@server/services/invitations'
|
|
57
57
|
import {
|
|
58
58
|
exchangeCodeForTokens,
|
|
59
59
|
decodeIdToken,
|
|
60
|
-
} from '
|
|
60
|
+
} from '@server/lib/oauth'
|
|
61
61
|
|
|
62
62
|
describe('Auth Routes', () => {
|
|
63
63
|
let mockEnv: ReturnType<typeof createMockEnv>
|