@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
|
@@ -10,6 +10,7 @@ export default defineConfig({
|
|
|
10
10
|
alias: {
|
|
11
11
|
'@server': `${projectRoot}/src/server`,
|
|
12
12
|
'@shared': `${projectRoot}/src/shared`,
|
|
13
|
+
'@tests': `${projectRoot}/tests`,
|
|
13
14
|
},
|
|
14
15
|
},
|
|
15
16
|
test: {
|
|
@@ -49,17 +50,10 @@ export default defineConfig({
|
|
|
49
50
|
// Database setup (not business logic)
|
|
50
51
|
'src/server/db/client.ts',
|
|
51
52
|
'src/server/db/seed.ts',
|
|
53
|
+
'src/server/db/records.ts',
|
|
52
54
|
// Barrel exports (just re-exports, no logic)
|
|
53
|
-
'src/server/db/schema/index.ts',
|
|
54
55
|
'src/server/services/index.ts',
|
|
55
56
|
'src/server/middleware/index.ts',
|
|
56
|
-
// Drizzle schema definitions (table structures, not business logic)
|
|
57
|
-
'src/server/db/schema/users.ts',
|
|
58
|
-
'src/server/db/schema/accounts.ts',
|
|
59
|
-
'src/server/db/schema/user-accounts.ts',
|
|
60
|
-
'src/server/db/schema/audit-logs.ts',
|
|
61
|
-
'src/server/db/schema/refresh-tokens.ts',
|
|
62
|
-
'src/server/db/schema/invitations.ts',
|
|
63
57
|
// API documentation (not testable)
|
|
64
58
|
'src/server/routes/api.ts',
|
|
65
59
|
// Dev-only endpoint (tested via E2E)
|
|
@@ -67,7 +61,6 @@ export default defineConfig({
|
|
|
67
61
|
// Hard to test in isolation (require external services/mocking)
|
|
68
62
|
'src/server/lib/providers.ts',
|
|
69
63
|
'src/server/lib/transaction.ts',
|
|
70
|
-
'src/server/lib/schema-helpers.ts',
|
|
71
64
|
],
|
|
72
65
|
thresholds: {
|
|
73
66
|
statements: 90,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Mock } from "vitest";
|
|
2
2
|
import { describe, it, expect, vi, beforeEach } from "vitest"
|
|
3
|
-
import { render, screen } from "
|
|
3
|
+
import { render, screen } from "@tests/helpers/client-test-utils"
|
|
4
4
|
import userEvent from "@testing-library/user-event"
|
|
5
5
|
import { Sidebar } from "../sidebar"
|
|
6
6
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect, vi } from "vitest"
|
|
2
|
-
import { render, screen, fireEvent, waitFor } from "
|
|
2
|
+
import { render, screen, fireEvent, waitFor } from "@tests/helpers/client-test-utils"
|
|
3
3
|
import { createRef } from "react"
|
|
4
4
|
import { Avatar, AvatarImage, AvatarFallback } from "../avatar"
|
|
5
5
|
|
package/templates/base/{src/client/__tests__ → tests/unit/client/components/ui}/button.test.tsx
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect, vi } from "vitest"
|
|
2
|
-
import { render, screen } from "
|
|
2
|
+
import { render, screen } from "@tests/helpers/client-test-utils"
|
|
3
3
|
import userEvent from "@testing-library/user-event"
|
|
4
4
|
import { Button } from "@/components/ui/button"
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect, vi } from "vitest"
|
|
2
|
-
import { render, screen, waitFor } from "
|
|
2
|
+
import { render, screen, waitFor } from "@tests/helpers/client-test-utils"
|
|
3
3
|
import userEvent from "@testing-library/user-event"
|
|
4
4
|
import {
|
|
5
5
|
Dialog,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect, vi } from "vitest"
|
|
2
|
-
import { render, screen } from "
|
|
2
|
+
import { render, screen } from "@tests/helpers/client-test-utils"
|
|
3
3
|
import userEvent from "@testing-library/user-event"
|
|
4
4
|
import { createRef } from "react"
|
|
5
5
|
import { Input } from "../input"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect, vi } from "vitest"
|
|
2
|
-
import { render, screen } from "
|
|
2
|
+
import { render, screen } from "@tests/helpers/client-test-utils"
|
|
3
3
|
import userEvent from "@testing-library/user-event"
|
|
4
4
|
import { Tabs, TabsList, TabsTrigger, TabsContent } from "../tabs"
|
|
5
5
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
2
2
|
import { screen, waitFor, fireEvent } from '@testing-library/react'
|
|
3
3
|
import userEvent from '@testing-library/user-event'
|
|
4
|
-
import { renderRoute } from '
|
|
4
|
+
import { renderRoute } from '@tests/helpers/client-test-utils'
|
|
5
5
|
|
|
6
6
|
// Mock user for authenticated tests
|
|
7
7
|
const mockUser = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
2
2
|
import { screen, waitFor } from '@testing-library/react'
|
|
3
3
|
import userEvent from '@testing-library/user-event'
|
|
4
|
-
import { renderRoute } from '
|
|
4
|
+
import { renderRoute } from '@tests/helpers/client-test-utils'
|
|
5
5
|
|
|
6
6
|
// Mock user for authenticated tests
|
|
7
7
|
const mockUser = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
2
2
|
import { screen, waitFor } from '@testing-library/react'
|
|
3
3
|
import userEvent from '@testing-library/user-event'
|
|
4
|
-
import { renderRoute } from '
|
|
4
|
+
import { renderRoute } from '@tests/helpers/client-test-utils'
|
|
5
5
|
|
|
6
6
|
// Mock user for authenticated tests
|
|
7
7
|
const mockUser = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
2
2
|
import { screen, waitFor } from '@testing-library/react'
|
|
3
3
|
import userEvent from '@testing-library/user-event'
|
|
4
|
-
import { renderRoute } from '
|
|
4
|
+
import { renderRoute } from '@tests/helpers/client-test-utils'
|
|
5
5
|
|
|
6
6
|
// Mock user for authenticated tests
|
|
7
7
|
const mockUser = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
|
|
2
2
|
import { screen, waitFor, act } from '@testing-library/react'
|
|
3
|
-
import { renderRoute } from '
|
|
3
|
+
import { renderRoute } from '@tests/helpers/client-test-utils'
|
|
4
4
|
|
|
5
5
|
// Mock user for authenticated tests
|
|
6
6
|
const mockUser = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
2
2
|
import { screen, waitFor } from '@testing-library/react'
|
|
3
|
-
import { renderRoute } from '
|
|
3
|
+
import { renderRoute } from '@tests/helpers/client-test-utils'
|
|
4
4
|
|
|
5
5
|
// Mock user for authenticated tests
|
|
6
6
|
const mockUser = {
|
package/templates/base/{src/client/routes/__tests__ → tests/unit/client/routes}/invite.test.tsx
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
|
|
2
2
|
import { screen, waitFor } from '@testing-library/react'
|
|
3
3
|
import userEvent from '@testing-library/user-event'
|
|
4
|
-
import { renderRoute } from '
|
|
4
|
+
import { renderRoute } from '@tests/helpers/client-test-utils'
|
|
5
5
|
|
|
6
6
|
describe('Invite Token Page', () => {
|
|
7
7
|
beforeEach(() => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
2
2
|
import { screen, waitFor } from '@testing-library/react'
|
|
3
3
|
import userEvent from '@testing-library/user-event'
|
|
4
|
-
import { renderRoute } from '
|
|
4
|
+
import { renderRoute } from '@tests/helpers/client-test-utils'
|
|
5
5
|
|
|
6
6
|
describe('Login Page', () => {
|
|
7
7
|
beforeEach(() => {
|
package/templates/base/{src/client/__tests__ → tests/unit/client}/routes/navigation.test.tsx
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
2
2
|
import { screen, waitFor } from '@testing-library/react'
|
|
3
3
|
import userEvent from '@testing-library/user-event'
|
|
4
|
-
import { renderRoute } from '
|
|
4
|
+
import { renderRoute } from '@tests/helpers/client-test-utils'
|
|
5
5
|
|
|
6
6
|
// Mock user for authenticated tests
|
|
7
7
|
const mockUser = {
|
package/templates/base/{src/client/__tests__ → tests/unit/client}/routes/root-layout.test.tsx
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
|
|
2
2
|
import { screen, waitFor } from '@testing-library/react'
|
|
3
|
-
import { renderRoute } from '
|
|
3
|
+
import { renderRoute } from '@tests/helpers/client-test-utils'
|
|
4
4
|
|
|
5
5
|
describe('Root Layout', () => {
|
|
6
6
|
beforeEach(() => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest'
|
|
2
2
|
import { Hono } from 'hono'
|
|
3
|
-
import { requireRole, requirePermission } from '
|
|
4
|
-
import type { HonoEnv } from '
|
|
3
|
+
import { requireRole, requirePermission } from '@server/guards'
|
|
4
|
+
import type { HonoEnv } from '@server/types'
|
|
5
5
|
|
|
6
6
|
describe('guards', () => {
|
|
7
7
|
describe('requireRole', () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/auth/permissions.test.ts
|
|
2
2
|
import { describe, it, expect } from 'vitest'
|
|
3
|
-
import { Permission, hasPermission, hasAnyPermission, hasAllPermissions } from '
|
|
3
|
+
import { Permission, hasPermission, hasAnyPermission, hasAllPermissions } from '@server/auth/permissions'
|
|
4
4
|
|
|
5
5
|
describe('permissions', () => {
|
|
6
6
|
describe('hasPermission', () => {
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { createMockEnv, setMockQueryResult } from '@tests/helpers/server'
|
|
3
|
+
import { queryAll, queryOne, queryValue, execute } from '@server/db/sql'
|
|
4
|
+
|
|
5
|
+
describe('sql helper', () => {
|
|
6
|
+
it('returns all rows with optional mapper', async () => {
|
|
7
|
+
const env = createMockEnv()
|
|
8
|
+
const mockDb = env.DB._mock
|
|
9
|
+
|
|
10
|
+
setMockQueryResult(mockDb, [1], [
|
|
11
|
+
{ id: '1', name: 'Alice' },
|
|
12
|
+
{ id: '2', name: 'Bob' },
|
|
13
|
+
])
|
|
14
|
+
|
|
15
|
+
const rows = await queryAll(env.DB, 'SELECT id, name FROM users WHERE id = ?', [1])
|
|
16
|
+
expect(rows).toEqual([
|
|
17
|
+
{ id: '1', name: 'Alice' },
|
|
18
|
+
{ id: '2', name: 'Bob' },
|
|
19
|
+
])
|
|
20
|
+
|
|
21
|
+
const mapped = await queryAll(env.DB, 'SELECT id FROM users WHERE id = ?', [1], (row) => ({
|
|
22
|
+
id: String(row.id),
|
|
23
|
+
}))
|
|
24
|
+
expect(mapped).toEqual([{ id: '1' }, { id: '2' }])
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it('returns one row or null', async () => {
|
|
28
|
+
const env = createMockEnv()
|
|
29
|
+
const mockDb = env.DB._mock
|
|
30
|
+
|
|
31
|
+
setMockQueryResult(mockDb, [], [{ ok: 1 }])
|
|
32
|
+
|
|
33
|
+
const row = await queryOne(env.DB, 'SELECT 1 AS ok')
|
|
34
|
+
expect(row).toEqual({ ok: 1 })
|
|
35
|
+
|
|
36
|
+
const empty = await queryOne(env.DB, 'SELECT 1 AS ok', [999])
|
|
37
|
+
expect(empty).toBeNull()
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
it('returns a single value', async () => {
|
|
41
|
+
const env = createMockEnv()
|
|
42
|
+
const mockDb = env.DB._mock
|
|
43
|
+
|
|
44
|
+
setMockQueryResult(mockDb, [], [{ count: 42 }])
|
|
45
|
+
|
|
46
|
+
const value = await queryValue<number>(env.DB, 'SELECT count(*) AS count FROM users')
|
|
47
|
+
expect(value).toBe(42)
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it('normalizes params (boolean/date/undefined)', async () => {
|
|
51
|
+
const env = createMockEnv()
|
|
52
|
+
const mockDb = env.DB._mock
|
|
53
|
+
const date = new Date('2025-01-01T00:00:00.000Z')
|
|
54
|
+
|
|
55
|
+
setMockQueryResult(mockDb, [1, date.toISOString(), null], [{ ok: 1 }])
|
|
56
|
+
|
|
57
|
+
const row = await queryOne(env.DB, 'SELECT 1 AS ok WHERE a = ? AND b = ? AND c IS ?', [true, date, undefined])
|
|
58
|
+
expect(row).toEqual({ ok: 1 })
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
it('executes statements and returns meta', async () => {
|
|
62
|
+
const env = createMockEnv()
|
|
63
|
+
|
|
64
|
+
const result = await execute(env.DB, 'UPDATE users SET name = ? WHERE id = ?', ['Alice', '1'])
|
|
65
|
+
expect(result).toHaveProperty('meta')
|
|
66
|
+
expect(result.meta.changes).toBe(1)
|
|
67
|
+
})
|
|
68
|
+
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest'
|
|
2
|
-
import { getEnv, type Env } from '
|
|
2
|
+
import { getEnv, type Env } from '@server/env'
|
|
3
3
|
|
|
4
4
|
// Note: The old process.env-based tests were removed as the env module
|
|
5
5
|
// now uses Cloudflare Workers bindings (passed to getEnv function)
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// src/server/lib/audited-db.test.ts
|
|
2
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
3
|
+
import { auditedInsert, auditedUpdate, auditedDelete } from '@server/lib/audited-db'
|
|
4
|
+
import type { ServiceContext } from '@server/types'
|
|
5
|
+
import { createMockEnv, setMockQueryResult } from '@tests/helpers/server'
|
|
6
|
+
|
|
7
|
+
const mockCtx: ServiceContext = {
|
|
8
|
+
accountId: 'account-123',
|
|
9
|
+
user: {
|
|
10
|
+
id: 'user-123',
|
|
11
|
+
email: 'test@example.com',
|
|
12
|
+
name: 'Test User',
|
|
13
|
+
status: 'active',
|
|
14
|
+
providerIds: [],
|
|
15
|
+
isSuperAdmin: false,
|
|
16
|
+
createdAt: '2024-01-01',
|
|
17
|
+
updatedAt: '2024-01-01',
|
|
18
|
+
deletedAt: null,
|
|
19
|
+
},
|
|
20
|
+
transactionId: 'tx-123',
|
|
21
|
+
ip: '127.0.0.1',
|
|
22
|
+
userAgent: 'test-agent',
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
describe('audited-db (sql)', () => {
|
|
26
|
+
beforeEach(() => {
|
|
27
|
+
vi.clearAllMocks()
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
it('auditedInsert inserts and returns rows with SQL', async () => {
|
|
31
|
+
const env = createMockEnv()
|
|
32
|
+
const mockDb = env.DB._mock
|
|
33
|
+
|
|
34
|
+
setMockQueryResult(mockDb, ['user-1', 'Alice'], [{ id: 'user-1', name: 'Alice' }])
|
|
35
|
+
|
|
36
|
+
const result = await auditedInsert(env.DB, mockCtx, 'users', { id: 'user-1', name: 'Alice' })
|
|
37
|
+
|
|
38
|
+
expect(result).toEqual([{ id: 'user-1', name: 'Alice' }])
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('auditedUpdate updates and returns rows with SQL', async () => {
|
|
42
|
+
const env = createMockEnv()
|
|
43
|
+
const mockDb = env.DB._mock
|
|
44
|
+
|
|
45
|
+
setMockQueryResult(mockDb, ['user-1'], [{ id: 'user-1', name: 'Old' }])
|
|
46
|
+
setMockQueryResult(mockDb, ['Updated', 'user-1'], [{ id: 'user-1', name: 'Updated' }])
|
|
47
|
+
|
|
48
|
+
const result = await auditedUpdate(
|
|
49
|
+
env.DB,
|
|
50
|
+
mockCtx,
|
|
51
|
+
'users',
|
|
52
|
+
{ name: 'Updated' },
|
|
53
|
+
{ clause: 'id = ?', params: ['user-1'] }
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
expect(result).toEqual([{ id: 'user-1', name: 'Updated' }])
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
it('auditedDelete soft deletes and logs with SQL', async () => {
|
|
60
|
+
const env = createMockEnv()
|
|
61
|
+
const mockDb = env.DB._mock
|
|
62
|
+
const fixedNow = '2025-01-01T00:00:00.000Z'
|
|
63
|
+
|
|
64
|
+
setMockQueryResult(
|
|
65
|
+
mockDb,
|
|
66
|
+
[fixedNow, mockCtx.user.id, fixedNow, mockCtx.user.id, 'user-1'],
|
|
67
|
+
[{ id: 'user-1', name: 'Alice' }]
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
await auditedDelete(
|
|
71
|
+
env.DB,
|
|
72
|
+
mockCtx,
|
|
73
|
+
'users',
|
|
74
|
+
{ clause: 'id = ?', params: ['user-1'] },
|
|
75
|
+
{ now: () => fixedNow }
|
|
76
|
+
)
|
|
77
|
+
})
|
|
78
|
+
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest'
|
|
2
|
-
import { createPaginationMeta, PaginationQuerySchema } from '
|
|
2
|
+
import { createPaginationMeta, PaginationQuerySchema } from '@server/lib/pagination'
|
|
3
3
|
|
|
4
4
|
describe('pagination', () => {
|
|
5
5
|
describe('createPaginationMeta', () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
|
|
2
|
-
import { generateStrongPassword, isStrongPassword } from '
|
|
2
|
+
import { generateStrongPassword, isStrongPassword } from '@server/lib/password'
|
|
3
3
|
|
|
4
4
|
// Store original crypto.getRandomValues
|
|
5
5
|
const originalGetRandomValues = crypto.getRandomValues.bind(crypto)
|
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
deleteFile,
|
|
7
7
|
getFileMetadata,
|
|
8
8
|
listFiles,
|
|
9
|
-
} from '
|
|
10
|
-
import { createMockR2, type MockR2Bucket } from '
|
|
9
|
+
} from '@server/lib/r2-storage'
|
|
10
|
+
import { createMockR2, type MockR2Bucket } from '@tests/mocks/r2'
|
|
11
11
|
|
|
12
12
|
describe('r2-storage', () => {
|
|
13
13
|
let mockR2: MockR2Bucket
|
|
@@ -7,8 +7,8 @@ import {
|
|
|
7
7
|
isAuthenticated,
|
|
8
8
|
sessionMiddleware,
|
|
9
9
|
type SessionData,
|
|
10
|
-
} from '
|
|
11
|
-
import { createMockKV, type MockKVNamespace } from '
|
|
10
|
+
} from '@server/lib/session'
|
|
11
|
+
import { createMockKV, type MockKVNamespace } from '@tests/mocks/kv'
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Create a mock Hono context for testing session functions
|
|
@@ -1,25 +1,19 @@
|
|
|
1
1
|
import { describe, it, expect, vi } from 'vitest'
|
|
2
|
-
import { withTransaction } from '
|
|
2
|
+
import { withTransaction } from '@server/lib/transaction'
|
|
3
3
|
|
|
4
4
|
describe('withTransaction', () => {
|
|
5
5
|
it('returns result from successful callback', async () => {
|
|
6
|
-
const
|
|
7
|
-
const mockDb = {
|
|
8
|
-
transaction: vi.fn(async (cb) => cb(mockTx)),
|
|
9
|
-
}
|
|
6
|
+
const mockDb = { prepare: vi.fn() }
|
|
10
7
|
|
|
11
8
|
const result = await withTransaction(mockDb as any, async (tx) => {
|
|
12
9
|
return { id: '123', name: 'Test' }
|
|
13
10
|
})
|
|
14
11
|
|
|
15
12
|
expect(result).toEqual({ id: '123', name: 'Test' })
|
|
16
|
-
expect(mockDb.transaction).toHaveBeenCalledTimes(1)
|
|
17
13
|
})
|
|
18
14
|
|
|
19
15
|
it('propagates errors from callback', async () => {
|
|
20
|
-
const mockDb = {
|
|
21
|
-
transaction: vi.fn(async (cb) => cb({})),
|
|
22
|
-
}
|
|
16
|
+
const mockDb = { prepare: vi.fn() }
|
|
23
17
|
|
|
24
18
|
await expect(
|
|
25
19
|
withTransaction(mockDb as any, async () => {
|
|
@@ -29,10 +23,7 @@ describe('withTransaction', () => {
|
|
|
29
23
|
})
|
|
30
24
|
|
|
31
25
|
it('passes transaction to callback', async () => {
|
|
32
|
-
const
|
|
33
|
-
const mockDb = {
|
|
34
|
-
transaction: vi.fn(async (cb) => cb(mockTx)),
|
|
35
|
-
}
|
|
26
|
+
const mockDb = { prepare: vi.fn() }
|
|
36
27
|
|
|
37
28
|
let receivedTx: any
|
|
38
29
|
await withTransaction(mockDb as any, async (tx) => {
|
|
@@ -40,6 +31,6 @@ describe('withTransaction', () => {
|
|
|
40
31
|
return null
|
|
41
32
|
})
|
|
42
33
|
|
|
43
|
-
expect(receivedTx).toBe(
|
|
34
|
+
expect(receivedTx).toBe(mockDb)
|
|
44
35
|
})
|
|
45
36
|
})
|