@etus/bhono-app 0.1.1
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/cli.d.ts +13 -0
- package/dist/cli.js +46 -0
- package/dist/cli.js.map +1 -0
- package/dist/cli.test.d.ts +1 -0
- package/dist/cli.test.js +26 -0
- package/dist/cli.test.js.map +1 -0
- package/dist/generator.d.ts +14 -0
- package/dist/generator.js +142 -0
- package/dist/generator.js.map +1 -0
- package/dist/generator.test.d.ts +1 -0
- package/dist/generator.test.js +127 -0
- package/dist/generator.test.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +97 -0
- package/dist/index.js.map +1 -0
- package/dist/prompts.d.ts +25 -0
- package/dist/prompts.js +83 -0
- package/dist/prompts.js.map +1 -0
- package/dist/prompts.test.d.ts +1 -0
- package/dist/prompts.test.js +24 -0
- package/dist/prompts.test.js.map +1 -0
- package/dist/providers/cloudflare.d.ts +37 -0
- package/dist/providers/cloudflare.js +61 -0
- package/dist/providers/cloudflare.js.map +1 -0
- package/dist/providers/cloudflare.test.d.ts +1 -0
- package/dist/providers/cloudflare.test.js +29 -0
- package/dist/providers/cloudflare.test.js.map +1 -0
- package/dist/providers/github.d.ts +16 -0
- package/dist/providers/github.js +57 -0
- package/dist/providers/github.js.map +1 -0
- package/dist/providers/github.test.d.ts +1 -0
- package/dist/providers/github.test.js +16 -0
- package/dist/providers/github.test.js.map +1 -0
- package/dist/templates.d.ts +8 -0
- package/dist/templates.js +88 -0
- package/dist/templates.js.map +1 -0
- package/dist/templates.test.d.ts +1 -0
- package/dist/templates.test.js +26 -0
- package/dist/templates.test.js.map +1 -0
- package/package.json +36 -0
- package/templates/base/.claude/agents/architect-review.md +160 -0
- package/templates/base/.claude/agents/backend-architect.md +308 -0
- package/templates/base/.claude/agents/code-reviewer.md +170 -0
- package/templates/base/.claude/agents/performance-engineer.md +166 -0
- package/templates/base/.claude/agents/test-automator.md +219 -0
- package/templates/base/.claude/commands/check-skill-rules.md +53 -0
- package/templates/base/.claude/commands/claude-md.md +250 -0
- package/templates/base/.claude/commands/code-prompt.md +212 -0
- package/templates/base/.claude/commands/explain-code.md +194 -0
- package/templates/base/.claude/commands/init-projec.md +89 -0
- package/templates/base/.claude/commands/linear/README.md +297 -0
- package/templates/base/.claude/commands/linear/create-issue.md +190 -0
- package/templates/base/.claude/commands/linear/implement-issue.md +248 -0
- package/templates/base/.claude/commands/linear/process-triage.md +399 -0
- package/templates/base/.claude/commands/linear/setup.md +180 -0
- package/templates/base/.claude/commands/prime.md +9 -0
- package/templates/base/.claude/commands/review-gap.md +10 -0
- package/templates/base/.claude/commands/setup-aa.md +311 -0
- package/templates/base/.claude/commands/ship.md +262 -0
- package/templates/base/.claude/commands/tools.md +3 -0
- package/templates/base/.claude/docs/claude-progress.txt +107 -0
- package/templates/base/.claude/hooks/package-lock.json +556 -0
- package/templates/base/.claude/hooks/package.json +16 -0
- package/templates/base/.claude/hooks/skill-activation-prompt.sh +7 -0
- package/templates/base/.claude/hooks/skill-activation-prompt.ts +142 -0
- package/templates/base/.claude/hooks/tsconfig.json +19 -0
- package/templates/base/.claude/scripts/check-updates.sh +85 -0
- package/templates/base/.claude/scripts/install_pkgs.sh +66 -0
- package/templates/base/.claude/scripts/setup-project.sh +177 -0
- package/templates/base/.claude/scripts/validate-skill-rules.sh +94 -0
- package/templates/base/.claude/settings.json +113 -0
- package/templates/base/.claude/settings.local.json +11 -0
- package/templates/base/.claude/skills/architecture-analyzer/SKILL.md +531 -0
- package/templates/base/.claude/skills/architecture-analyzer/assets/report-template.md +215 -0
- package/templates/base/.claude/skills/architecture-analyzer/references/c4-templates.md +234 -0
- package/templates/base/.claude/skills/architecture-analyzer/references/confidence-levels.md +203 -0
- package/templates/base/.claude/skills/architecture-analyzer/scripts/analyze_structure.py +266 -0
- package/templates/base/.claude/skills/architecture-analyzer/scripts/analyze_tech_debt.py +776 -0
- package/templates/base/.claude/skills/architecture-analyzer/scripts/extract_apis.py +338 -0
- package/templates/base/.claude/skills/architecture-analyzer/scripts/generate_c4.py +283 -0
- package/templates/base/.claude/skills/architecture-analyzer/scripts/generate_erd.py +935 -0
- package/templates/base/.claude/skills/architecture-analyzer/scripts/map_dependencies.py +555 -0
- package/templates/base/.claude/skills/dev-browser/SKILL.md +318 -0
- package/templates/base/.claude/skills/dev-browser/bun.lock +443 -0
- package/templates/base/.claude/skills/dev-browser/package-lock.json +2927 -0
- package/templates/base/.claude/skills/dev-browser/package.json +27 -0
- package/templates/base/.claude/skills/dev-browser/scripts/start-server.ts +117 -0
- package/templates/base/.claude/skills/dev-browser/server.sh +24 -0
- package/templates/base/.claude/skills/dev-browser/src/client.ts +403 -0
- package/templates/base/.claude/skills/dev-browser/src/index.ts +281 -0
- package/templates/base/.claude/skills/dev-browser/src/snapshot/__tests__/snapshot.test.ts +223 -0
- package/templates/base/.claude/skills/dev-browser/src/snapshot/browser-script.ts +877 -0
- package/templates/base/.claude/skills/dev-browser/src/snapshot/index.ts +14 -0
- package/templates/base/.claude/skills/dev-browser/src/snapshot/inject.ts +13 -0
- package/templates/base/.claude/skills/dev-browser/src/types.ts +27 -0
- package/templates/base/.claude/skills/dev-browser/tsconfig.json +36 -0
- package/templates/base/.claude/skills/dev-browser/vitest.config.ts +12 -0
- package/templates/base/.claude/skills/linear/SKILL.md +440 -0
- package/templates/base/.claude/skills/linear/examples.md +262 -0
- package/templates/base/.claude/skills/linear/lib/client.ts +51 -0
- package/templates/base/.claude/skills/linear/lib/config.ts +106 -0
- package/templates/base/.claude/skills/linear/lib/output.ts +34 -0
- package/templates/base/.claude/skills/linear/package-lock.json +698 -0
- package/templates/base/.claude/skills/linear/package.json +27 -0
- package/templates/base/.claude/skills/linear/reference.md +263 -0
- package/templates/base/.claude/skills/linear/scripts/comments/create.ts +47 -0
- package/templates/base/.claude/skills/linear/scripts/comments/list.ts +47 -0
- package/templates/base/.claude/skills/linear/scripts/issues/archive.ts +30 -0
- package/templates/base/.claude/skills/linear/scripts/issues/create.ts +279 -0
- package/templates/base/.claude/skills/linear/scripts/issues/get.ts +68 -0
- package/templates/base/.claude/skills/linear/scripts/issues/list.ts +67 -0
- package/templates/base/.claude/skills/linear/scripts/issues/update.ts +281 -0
- package/templates/base/.claude/skills/linear/scripts/labels/add-to-issue.ts +63 -0
- package/templates/base/.claude/skills/linear/scripts/labels/create.ts +45 -0
- package/templates/base/.claude/skills/linear/scripts/labels/list.ts +30 -0
- package/templates/base/.claude/skills/linear/scripts/list-teams.ts +52 -0
- package/templates/base/.claude/skills/linear/scripts/setup/setup-credentials.ts +96 -0
- package/templates/base/.claude/skills/linear/scripts/status/list.ts +31 -0
- package/templates/base/.claude/skills/linear/scripts/status/set-by-name.ts +78 -0
- package/templates/base/.claude/skills/linear/scripts/status/update.ts +44 -0
- package/templates/base/.claude/skills/linear/scripts/users/list.ts +59 -0
- package/templates/base/.claude/skills/linear/scripts/users/me.ts +20 -0
- package/templates/base/.claude/skills/linear/templates/README.md +203 -0
- package/templates/base/.claude/skills/linear/templates/api-reference.md +258 -0
- package/templates/base/.claude/skills/linear/templates/bug-report.md +99 -0
- package/templates/base/.claude/skills/linear/templates/feature-request.md +118 -0
- package/templates/base/.claude/skills/linear/templates/security-issue.md +162 -0
- package/templates/base/.claude/skills/linear/templates/sprint-task.md +175 -0
- package/templates/base/.claude/skills/linear/templates/tech-debt.md +137 -0
- package/templates/base/.claude/skills/linear/tsconfig.json +17 -0
- package/templates/base/.claude/skills/linear/workflows/issue-lifecycle.md +317 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/SKILL.md +113 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/assets/global-setup.template.js +97 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/assets/playwright.config.template.js +171 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/assets/test-template.spec.js +163 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/examples/README.md +26 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/examples/ads.email-deeplink.spec.ts +12 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/examples/mobile.realism.spec.ts +16 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/examples/smoke.home.spec.ts +6 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/references/architecture.md +578 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/references/best-practices.md +260 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/references/ci-reporting.md +86 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/references/debugging.md +629 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/references/mobile-realism.md +50 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/references/optimization.md +488 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/references/patterns.md +513 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/references/resources.md +44 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/references/visual-a11y.md +66 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/scripts/auth-setup.js +202 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/scripts/performance-analyzer.js +240 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/scripts/trace-url.js +132 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/templates/ci/github-actions.playwright.yml +78 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/templates/fixtures.ts +44 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/templates/global-setup.template.js +97 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/templates/global.setup.ts +35 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/templates/helpers/ad-gpt-observer.ts +80 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/templates/helpers/chromium-mobile-profile.ts +93 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/templates/playwright.config.template.js +171 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/templates/playwright.config.ts +126 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/templates/test-template.spec.js +163 -0
- package/templates/base/.claude/skills/playwright-e2e-testing/templates/tests/email-deeplink.ads.spec.ts +44 -0
- package/templates/base/.claude/skills/skill-rules.json +184 -0
- package/templates/base/.claude/skills/wrangler/SKILL.md +209 -0
- package/templates/base/.claude/skills/wrangler/resources/api.md +494 -0
- package/templates/base/.claude/skills/wrangler/resources/bundling.md +83 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/cert.md +64 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/check.md +66 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/containers.md +157 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/d1.md +843 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/delete.md +27 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/deploy.md +139 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/deployments.md +56 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/dev.md +157 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/dispatch-namespace.md +69 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/docs.md +61 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/how-to-run.md +62 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/hyperdrive.md +425 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/init.md +31 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/kv-bulk.md +265 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/kv-key.md +353 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/kv-namespace.md +265 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/login.md +23 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/logout.md +19 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/mtls-certificate.md +69 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/pages.md +175 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/pipelines.md +76 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/queues.md +132 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/r2-bucket.md +342 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/r2-object.md +267 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/r2-sql.md +65 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/rollback.md +40 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/secret.md +308 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/secrets-store-secret.md +100 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/secrets-store-store.md +60 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/setup.md +67 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/tail.md +37 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/telemetry.md +64 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/triggers.md +39 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/types.md +73 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/vectorize.md +941 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/versions.md +95 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/whoami.md +49 -0
- package/templates/base/.claude/skills/wrangler/resources/commands/workflows.md +117 -0
- package/templates/base/.claude/skills/wrangler/resources/commands.md +138 -0
- package/templates/base/.claude/skills/wrangler/resources/configuration.md +2176 -0
- package/templates/base/.claude/skills/wrangler/resources/custom-builds.md +55 -0
- package/templates/base/.claude/skills/wrangler/resources/deprecations.md +279 -0
- package/templates/base/.claude/skills/wrangler/resources/enviroments.md +416 -0
- package/templates/base/.claude/skills/wrangler/resources/extract_sections.py +119 -0
- package/templates/base/.claude/skills/wrangler/resources/process_content.py +94 -0
- package/templates/base/.claude/skills/wrangler/resources/system-enviroments-variables.md +120 -0
- package/templates/base/.dev.vars.example +15 -0
- package/templates/base/.env.example +29 -0
- package/templates/base/.github/workflows/test.yml +127 -0
- package/templates/base/.nycrc.json +16 -0
- package/templates/base/CLAUDE.md +218 -0
- package/templates/base/README.md +670 -0
- package/templates/base/auth-setup-error.png +0 -0
- package/templates/base/config/drizzle.config.ts +10 -0
- package/templates/base/config/eslint.config.js +364 -0
- package/templates/base/config/wrangler.json +76 -0
- package/templates/base/docs/app_spec.txt +879 -0
- package/templates/base/docs/app_spec_template.md +681 -0
- package/templates/base/docs/architecture/README.md +8 -0
- package/templates/base/docs/architecture/data-requirements.md +109 -0
- package/templates/base/docs/architecture/erd.md +91 -0
- package/templates/base/docs/features/feature_list.json +3128 -0
- package/templates/base/docs/hono-boilerplate-plan.md +1774 -0
- package/templates/base/docs/test-coverage-gap-analysis.md +242 -0
- package/templates/base/docs/testing.md +188 -0
- package/templates/base/index.html +16 -0
- package/templates/base/package.json +115 -0
- package/templates/base/playwright.config.ts +158 -0
- package/templates/base/pnpm-lock.yaml +8175 -0
- package/templates/base/scripts/capture-prod-session.ts +250 -0
- package/templates/base/scripts/generate-openapi.ts +23 -0
- package/templates/base/scripts/init.sh +121 -0
- package/templates/base/src/client/__tests__/button.test.tsx +30 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/dashboard.test.tsx/Dashboard-Page-when-authenticated-should-display-dashboard-stats-cards-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/dashboard.test.tsx/Dashboard-Page-when-authenticated-should-display-quick-action-cards-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/dashboard.test.tsx/Dashboard-Page-when-authenticated-should-display-recent-activity-section-1.png +0 -0
- package/templates/base/src/client/__tests__/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__/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__/routes/__screenshots__/dashboard.test.tsx/Dashboard-Page-when-authenticated-should-render-dashboard-when-authenticated-1.png +0 -0
- package/templates/base/src/client/__tests__/routes/__screenshots__/dashboard.test.tsx/Dashboard-Page-when-authenticated-should-show-navigation-sidebar-1.png +0 -0
- package/templates/base/src/client/__tests__/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/__tests__/routes/__screenshots__/login.test.tsx/Login-Page-should-display-Google-OAuth-login-button-1.png +0 -0
- package/templates/base/src/client/__tests__/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__/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__/routes/__screenshots__/login.test.tsx/Login-Page-should-render-login-page-at--login-route-1.png +0 -0
- package/templates/base/src/client/__tests__/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__/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__/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__/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__/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__/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__/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__/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__/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__/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__/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__/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__/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__/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__/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__/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/__tests__/routes/authenticated-layout.test.tsx +252 -0
- package/templates/base/src/client/__tests__/routes/dashboard.test.tsx +136 -0
- package/templates/base/src/client/__tests__/routes/error-components.test.tsx +186 -0
- package/templates/base/src/client/__tests__/routes/login.test.tsx +112 -0
- package/templates/base/src/client/__tests__/routes/navigation.test.tsx +272 -0
- package/templates/base/src/client/__tests__/routes/root-layout.test.tsx +65 -0
- package/templates/base/src/client/__tests__/setup-browser.ts +15 -0
- package/templates/base/src/client/__tests__/setup.ts +32 -0
- package/templates/base/src/client/__tests__/test-utils.tsx +135 -0
- package/templates/base/src/client/api/.gitkeep +0 -0
- package/templates/base/src/client/components/__tests__/__screenshots__/sidebar.test.tsx/Sidebar-can-be-collapsed-by-default-1.png +0 -0
- package/templates/base/src/client/components/__tests__/__screenshots__/sidebar.test.tsx/Sidebar-expands-when-collapsed-and-expand-button-is-clicked-1.png +0 -0
- package/templates/base/src/client/components/__tests__/__screenshots__/sidebar.test.tsx/Sidebar-handles-logout-button-click-1.png +0 -0
- package/templates/base/src/client/components/__tests__/__screenshots__/sidebar.test.tsx/Sidebar-handles-navigation-clicks-1.png +0 -0
- package/templates/base/src/client/components/__tests__/__screenshots__/sidebar.test.tsx/Sidebar-hides-navigation-labels-when-collapsed-1.png +0 -0
- package/templates/base/src/client/components/__tests__/__screenshots__/sidebar.test.tsx/Sidebar-highlights-active-route-1.png +0 -0
- package/templates/base/src/client/components/__tests__/__screenshots__/sidebar.test.tsx/Sidebar-renders-sidebar-navigation-items-1.png +0 -0
- package/templates/base/src/client/components/__tests__/__screenshots__/sidebar.test.tsx/Sidebar-shows-keyboard-shortcut-hint-when-expanded-1.png +0 -0
- package/templates/base/src/client/components/__tests__/__screenshots__/sidebar.test.tsx/Sidebar-shows-user-info-when-authenticated-1.png +0 -0
- package/templates/base/src/client/components/__tests__/__screenshots__/sidebar.test.tsx/Sidebar-shows-user-initials-in-avatar-fallback-1.png +0 -0
- package/templates/base/src/client/components/__tests__/error-boundary.test.tsx +97 -0
- package/templates/base/src/client/components/__tests__/sidebar.test.tsx +281 -0
- package/templates/base/src/client/components/error-boundary.tsx +68 -0
- package/templates/base/src/client/components/icons.tsx +106 -0
- package/templates/base/src/client/components/layout/.gitkeep +0 -0
- package/templates/base/src/client/components/sidebar.tsx +267 -0
- package/templates/base/src/client/components/ui/.gitkeep +0 -0
- package/templates/base/src/client/components/ui/__tests__/avatar.test.tsx +308 -0
- package/templates/base/src/client/components/ui/__tests__/card.test.tsx +214 -0
- package/templates/base/src/client/components/ui/__tests__/dialog.test.tsx +297 -0
- package/templates/base/src/client/components/ui/__tests__/error-fallback.test.tsx +145 -0
- package/templates/base/src/client/components/ui/__tests__/input.test.tsx +98 -0
- package/templates/base/src/client/components/ui/__tests__/loading-skeleton.test.tsx +139 -0
- package/templates/base/src/client/components/ui/__tests__/skeleton.test.tsx +44 -0
- package/templates/base/src/client/components/ui/__tests__/sonner.test.tsx +28 -0
- package/templates/base/src/client/components/ui/__tests__/tabs.test.tsx +233 -0
- package/templates/base/src/client/components/ui/avatar.tsx +101 -0
- package/templates/base/src/client/components/ui/badge.tsx +46 -0
- package/templates/base/src/client/components/ui/button.tsx +72 -0
- package/templates/base/src/client/components/ui/card.tsx +86 -0
- package/templates/base/src/client/components/ui/dialog.tsx +140 -0
- package/templates/base/src/client/components/ui/error-fallback.tsx +179 -0
- package/templates/base/src/client/components/ui/form.tsx +172 -0
- package/templates/base/src/client/components/ui/input.tsx +24 -0
- package/templates/base/src/client/components/ui/label.tsx +22 -0
- package/templates/base/src/client/components/ui/loading-skeleton.tsx +154 -0
- package/templates/base/src/client/components/ui/separator.tsx +33 -0
- package/templates/base/src/client/components/ui/skeleton.tsx +16 -0
- package/templates/base/src/client/components/ui/sonner.tsx +29 -0
- package/templates/base/src/client/components/ui/tabs.tsx +121 -0
- package/templates/base/src/client/hooks/.gitkeep +0 -0
- package/templates/base/src/client/hooks/__tests__/use-auth.test.tsx +306 -0
- package/templates/base/src/client/hooks/__tests__/use-theme.test.tsx +172 -0
- package/templates/base/src/client/hooks/use-auth.ts +53 -0
- package/templates/base/src/client/hooks/use-theme.tsx +78 -0
- package/templates/base/src/client/index.css +881 -0
- package/templates/base/src/client/lib/query-client.ts +11 -0
- package/templates/base/src/client/lib/utils.ts +7 -0
- package/templates/base/src/client/main.tsx +26 -0
- package/templates/base/src/client/routeTree.gen.ts +258 -0
- package/templates/base/src/client/router.ts +15 -0
- package/templates/base/src/client/routes/$.tsx +77 -0
- package/templates/base/src/client/routes/.gitkeep +0 -0
- package/templates/base/src/client/routes/__root.tsx +34 -0
- package/templates/base/src/client/routes/__tests__/__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__/__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__/__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__/__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__/__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__/__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/routes/__tests__/invite.test.tsx +138 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__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__/__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__/__screenshots__/account.test.tsx/Account-Page-should-show-API-Access-section-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__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__/__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__/__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__/__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__/__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__/__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__/__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__/__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__/__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__/__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__/__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__/__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__/__screenshots__/integrations.test.tsx/Integrations-Page-page-rendering-should-display-Webhooks-section-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-page-rendering-should-display-connected-count-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-page-rendering-should-display-page-description-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-page-rendering-should-display-search-input-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__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__/__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__/__screenshots__/integrations.test.tsx/Integrations-Page-search-functionality-should-search-by-description-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__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__/__screenshots__/integrations.test.tsx/Integrations-Page-webhooks-section-should-display-existing-webhook-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__screenshots__/integrations.test.tsx/Integrations-Page-webhooks-section-should-display-webhook-events-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__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__/__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__/__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__/__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__/__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__/__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__/__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__/__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__/__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__/__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__/__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__/__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__/__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__/__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__/__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__/__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__/__screenshots__/settings.test.tsx/Settings-Page-page-rendering-should-display-page-description-1.png +0 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/__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__/__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__/__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__/__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__/__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__/__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__/__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__/__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__/__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__/__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/routes/_authenticated/__tests__/account.test.tsx +324 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/integrations.test.tsx +520 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/settings.test.tsx +414 -0
- package/templates/base/src/client/routes/_authenticated/__tests__/team.test.tsx +374 -0
- package/templates/base/src/client/routes/_authenticated/account.tsx +416 -0
- package/templates/base/src/client/routes/_authenticated/dashboard.tsx +151 -0
- package/templates/base/src/client/routes/_authenticated/integrations.tsx +553 -0
- package/templates/base/src/client/routes/_authenticated/settings.tsx +310 -0
- package/templates/base/src/client/routes/_authenticated/team.tsx +395 -0
- package/templates/base/src/client/routes/_authenticated.tsx +69 -0
- package/templates/base/src/client/routes/index.tsx +155 -0
- package/templates/base/src/client/routes/invite.$token.tsx +191 -0
- package/templates/base/src/client/routes/login.tsx +92 -0
- package/templates/base/src/server/__tests__/fixtures.ts +461 -0
- package/templates/base/src/server/__tests__/mocks/__tests__/db.test.ts +239 -0
- package/templates/base/src/server/__tests__/mocks/__tests__/kv.test.ts +293 -0
- package/templates/base/src/server/__tests__/mocks/__tests__/r2.test.ts +363 -0
- package/templates/base/src/server/__tests__/mocks/db.ts +186 -0
- package/templates/base/src/server/__tests__/mocks/index.ts +33 -0
- package/templates/base/src/server/__tests__/mocks/kv.ts +286 -0
- package/templates/base/src/server/__tests__/mocks/r2.ts +397 -0
- package/templates/base/src/server/__tests__/setup.ts +281 -0
- package/templates/base/src/server/auth/__tests__/guards.test.ts +162 -0
- package/templates/base/src/server/auth/guards.ts +92 -0
- package/templates/base/src/server/auth/permissions.test.ts +45 -0
- package/templates/base/src/server/auth/permissions.ts +139 -0
- package/templates/base/src/server/auth/roles.test.ts +169 -0
- package/templates/base/src/server/auth/roles.ts +141 -0
- package/templates/base/src/server/db/client.ts +12 -0
- package/templates/base/src/server/db/schema/accounts.ts +20 -0
- package/templates/base/src/server/db/schema/audit-logs.ts +26 -0
- package/templates/base/src/server/db/schema/index.ts +7 -0
- package/templates/base/src/server/db/schema/invitations.ts +30 -0
- package/templates/base/src/server/db/schema/refresh-tokens.ts +22 -0
- package/templates/base/src/server/db/schema/user-accounts.ts +25 -0
- package/templates/base/src/server/db/schema/users.ts +33 -0
- package/templates/base/src/server/db/seed.ts +267 -0
- package/templates/base/src/server/env.test.ts +84 -0
- package/templates/base/src/server/env.ts +78 -0
- package/templates/base/src/server/index.ts +82 -0
- package/templates/base/src/server/lib/audit.ts +73 -0
- package/templates/base/src/server/lib/audited-db.test.ts +107 -0
- package/templates/base/src/server/lib/audited-db.ts +154 -0
- package/templates/base/src/server/lib/email.test.ts +116 -0
- package/templates/base/src/server/lib/email.ts +82 -0
- package/templates/base/src/server/lib/errors.test.ts +49 -0
- package/templates/base/src/server/lib/errors.ts +64 -0
- package/templates/base/src/server/lib/oauth.test.ts +238 -0
- package/templates/base/src/server/lib/oauth.ts +113 -0
- package/templates/base/src/server/lib/pagination.test.ts +52 -0
- package/templates/base/src/server/lib/pagination.ts +32 -0
- package/templates/base/src/server/lib/password.test.ts +151 -0
- package/templates/base/src/server/lib/password.ts +151 -0
- package/templates/base/src/server/lib/providers.test.ts +105 -0
- package/templates/base/src/server/lib/providers.ts +62 -0
- package/templates/base/src/server/lib/r2-storage.test.ts +202 -0
- package/templates/base/src/server/lib/r2-storage.ts +107 -0
- package/templates/base/src/server/lib/schema-helpers.ts +16 -0
- package/templates/base/src/server/lib/session.test.ts +758 -0
- package/templates/base/src/server/lib/session.ts +267 -0
- package/templates/base/src/server/lib/tokens.test.ts +208 -0
- package/templates/base/src/server/lib/tokens.ts +65 -0
- package/templates/base/src/server/lib/transaction.test.ts +45 -0
- package/templates/base/src/server/lib/transaction.ts +24 -0
- package/templates/base/src/server/middleware/account.test.ts +201 -0
- package/templates/base/src/server/middleware/account.ts +66 -0
- package/templates/base/src/server/middleware/auth.test.ts +345 -0
- package/templates/base/src/server/middleware/auth.ts +146 -0
- package/templates/base/src/server/middleware/cors.test.ts +88 -0
- package/templates/base/src/server/middleware/cors.ts +26 -0
- package/templates/base/src/server/middleware/error-handler.test.ts +69 -0
- package/templates/base/src/server/middleware/error-handler.ts +43 -0
- package/templates/base/src/server/middleware/index.ts +8 -0
- package/templates/base/src/server/middleware/rate-limit.test.ts +472 -0
- package/templates/base/src/server/middleware/rate-limit.ts +294 -0
- package/templates/base/src/server/middleware/request-context.test.ts +175 -0
- package/templates/base/src/server/middleware/request-context.ts +28 -0
- package/templates/base/src/server/middleware/request-logger.test.ts +92 -0
- package/templates/base/src/server/middleware/request-logger.ts +50 -0
- package/templates/base/src/server/routes/accounts/__tests__/handlers.test.ts +460 -0
- package/templates/base/src/server/routes/accounts/handlers.ts +179 -0
- package/templates/base/src/server/routes/accounts/index.ts +55 -0
- package/templates/base/src/server/routes/accounts/routes.ts +205 -0
- package/templates/base/src/server/routes/accounts/schemas.ts +31 -0
- package/templates/base/src/server/routes/api.ts +37 -0
- package/templates/base/src/server/routes/audits/__tests__/handlers.test.ts +349 -0
- package/templates/base/src/server/routes/audits/handlers.ts +37 -0
- package/templates/base/src/server/routes/audits/index.ts +14 -0
- package/templates/base/src/server/routes/audits/routes.ts +29 -0
- package/templates/base/src/server/routes/audits/schemas.ts +43 -0
- package/templates/base/src/server/routes/auth/__tests__/handlers.test.ts +381 -0
- package/templates/base/src/server/routes/auth/handlers.ts +222 -0
- package/templates/base/src/server/routes/auth/index.ts +37 -0
- package/templates/base/src/server/routes/auth/routes.ts +136 -0
- package/templates/base/src/server/routes/auth/schemas.ts +48 -0
- package/templates/base/src/server/routes/auth/test-login.ts +156 -0
- package/templates/base/src/server/routes/health/__tests__/handlers.test.ts +237 -0
- package/templates/base/src/server/routes/health/handlers.ts +83 -0
- package/templates/base/src/server/routes/health/index.ts +13 -0
- package/templates/base/src/server/routes/health/routes.ts +90 -0
- package/templates/base/src/server/routes/index.ts +53 -0
- package/templates/base/src/server/routes/invitations/__tests__/handlers.test.ts +473 -0
- package/templates/base/src/server/routes/invitations/handlers.ts +71 -0
- package/templates/base/src/server/routes/invitations/index.ts +25 -0
- package/templates/base/src/server/routes/invitations/routes.ts +69 -0
- package/templates/base/src/server/routes/invitations/schemas.ts +39 -0
- package/templates/base/src/server/routes/openapi.ts +14 -0
- package/templates/base/src/server/routes/schemas.ts +53 -0
- package/templates/base/src/server/routes/storage/__tests__/handlers.test.ts +408 -0
- package/templates/base/src/server/routes/storage/handlers.ts +100 -0
- package/templates/base/src/server/routes/storage/index.ts +42 -0
- package/templates/base/src/server/routes/storage/routes.ts +91 -0
- package/templates/base/src/server/routes/storage/schemas.ts +56 -0
- package/templates/base/src/server/routes/users/__tests__/handlers.test.ts +526 -0
- package/templates/base/src/server/routes/users/handlers.ts +228 -0
- package/templates/base/src/server/routes/users/index.ts +67 -0
- package/templates/base/src/server/routes/users/routes.ts +265 -0
- package/templates/base/src/server/routes/users/schemas.ts +67 -0
- package/templates/base/src/server/services/__tests__/accounts.test.ts +764 -0
- package/templates/base/src/server/services/__tests__/audits.test.ts +235 -0
- package/templates/base/src/server/services/__tests__/auth.test.ts +765 -0
- package/templates/base/src/server/services/__tests__/invitations.test.ts +704 -0
- package/templates/base/src/server/services/__tests__/users.test.ts +755 -0
- package/templates/base/src/server/services/accounts.ts +269 -0
- package/templates/base/src/server/services/audits.ts +82 -0
- package/templates/base/src/server/services/auth.ts +225 -0
- package/templates/base/src/server/services/index.ts +6 -0
- package/templates/base/src/server/services/invitations.ts +306 -0
- package/templates/base/src/server/services/users.ts +350 -0
- package/templates/base/src/server/types/auth.ts +36 -0
- package/templates/base/src/server/types/index.ts +117 -0
- package/templates/base/src/shared/schemas/.gitkeep +0 -0
- package/templates/base/src/shared/schemas/__tests__/schemas.test.ts +547 -0
- package/templates/base/src/shared/schemas/account.ts +15 -0
- package/templates/base/src/shared/schemas/index.ts +6 -0
- package/templates/base/src/shared/schemas/invitation.ts +9 -0
- package/templates/base/src/shared/schemas/profile.ts +10 -0
- package/templates/base/src/shared/schemas/user.ts +16 -0
- package/templates/base/src/shared/schemas/webhook.ts +12 -0
- package/templates/base/src/shared/types/.gitkeep +0 -0
- package/templates/base/src/shared/types/account.ts +12 -0
- package/templates/base/src/shared/types/api.ts +1399 -0
- package/templates/base/src/shared/types/auth.ts +24 -0
- package/templates/base/src/shared/types/index.ts +5 -0
- package/templates/base/src/shared/types/user.ts +31 -0
- package/templates/base/src/test/vitest-zod-matcher.ts +37 -0
- package/templates/base/src/test/vitest.d.ts +19 -0
- package/templates/base/tests/e2e/README.md +141 -0
- package/templates/base/tests/e2e/a11y/accessibility.spec.ts +925 -0
- package/templates/base/tests/e2e/a11y/keyboard-navigation.spec.ts +610 -0
- package/templates/base/tests/e2e/api/accounts.spec.ts +148 -0
- package/templates/base/tests/e2e/api/audit-logs.spec.ts +130 -0
- package/templates/base/tests/e2e/api/authenticated-api.spec.ts +311 -0
- package/templates/base/tests/e2e/api/storage.spec.ts +109 -0
- package/templates/base/tests/e2e/auth-flows.unauth.spec.ts +117 -0
- package/templates/base/tests/e2e/auth-logout.unauth.spec.ts +103 -0
- package/templates/base/tests/e2e/auth.setup.ts +115 -0
- package/templates/base/tests/e2e/auth.spec.ts +146 -0
- package/templates/base/tests/e2e/compatibility/cross-browser.spec.ts +152 -0
- package/templates/base/tests/e2e/compatibility/cross-browser.spec.ts-snapshots/login-chromium-chromium-darwin.png +0 -0
- package/templates/base/tests/e2e/crud/account.spec.ts +356 -0
- package/templates/base/tests/e2e/crud/integrations.spec.ts +419 -0
- package/templates/base/tests/e2e/crud/team.spec.ts +287 -0
- package/templates/base/tests/e2e/crud/users.spec.ts +239 -0
- package/templates/base/tests/e2e/errors/error-boundary.spec.ts +428 -0
- package/templates/base/tests/e2e/errors/error-handling.spec.ts +47 -0
- package/templates/base/tests/e2e/errors/error-handling.unauth.spec.ts +205 -0
- package/templates/base/tests/e2e/fixtures.ts +266 -0
- package/templates/base/tests/e2e/forms/validation.spec.ts +569 -0
- package/templates/base/tests/e2e/invitations/invite-flow.unauth.spec.ts +204 -0
- package/templates/base/tests/e2e/journeys/account-lifecycle.spec.ts +314 -0
- package/templates/base/tests/e2e/journeys/audit-investigation.spec.ts +299 -0
- package/templates/base/tests/e2e/journeys/auth-onboarding.spec.ts +232 -0
- package/templates/base/tests/e2e/journeys/critical-flows.spec.ts +281 -0
- package/templates/base/tests/e2e/journeys/error-recovery.spec.ts +354 -0
- package/templates/base/tests/e2e/journeys/file-management.spec.ts +307 -0
- package/templates/base/tests/e2e/journeys/integrations.spec.ts +372 -0
- package/templates/base/tests/e2e/journeys/multi-account.spec.ts +317 -0
- package/templates/base/tests/e2e/journeys/rbac-enforcement.spec.ts +389 -0
- package/templates/base/tests/e2e/journeys/settings-profile.spec.ts +400 -0
- package/templates/base/tests/e2e/journeys/team-collaboration.spec.ts +410 -0
- package/templates/base/tests/e2e/mobile/responsive.spec.ts +178 -0
- package/templates/base/tests/e2e/navigation/routing.spec.ts +371 -0
- package/templates/base/tests/e2e/navigation/sidebar.spec.ts +425 -0
- package/templates/base/tests/e2e/pages/ui-features.spec.ts +393 -0
- package/templates/base/tests/e2e/performance/baselines.spec.ts +162 -0
- package/templates/base/tests/e2e/performance/benchmarks.spec.ts +371 -0
- package/templates/base/tests/e2e/smoke.unauth.spec.ts +196 -0
- package/templates/base/tests/e2e/visual/components.spec.ts +650 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/confirmation-dialog-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/dark-mode-background-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/dark-mode-card-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/dark-mode-sidebar-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/dashboard-card-single-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/dialog-content-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/dialog-with-backdrop-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/empty-search-results-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/input-default-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/input-focus-ring-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/primary-button-focus-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/primary-button-hover-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/primary-button-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/sidebar-active-nav-item-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/sidebar-collapsed-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/components.spec.ts-snapshots/sidebar-navigation-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/core-components.spec.ts +192 -0
- package/templates/base/tests/e2e/visual/core-components.spec.ts-snapshots/account-page-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/core-components.spec.ts-snapshots/create-webhook-dialog-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/core-components.spec.ts-snapshots/dashboard-page-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/core-components.spec.ts-snapshots/delete-account-dialog-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/core-components.spec.ts-snapshots/integrations-page-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/core-components.spec.ts-snapshots/invite-member-dialog-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/core-components.spec.ts-snapshots/login-page-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/core-components.spec.ts-snapshots/settings-account-tab-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/core-components.spec.ts-snapshots/settings-profile-tab-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/core-components.spec.ts-snapshots/sidebar-navigation-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/core-components.spec.ts-snapshots/team-page-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/screenshots.spec.ts +230 -0
- package/templates/base/tests/e2e/visual/screenshots.spec.ts-snapshots/404-page-chromium-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/screenshots.spec.ts-snapshots/404-page-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/screenshots.spec.ts-snapshots/account-page-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/screenshots.spec.ts-snapshots/login-page-chromium-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/screenshots.spec.ts-snapshots/login-page-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/screenshots.spec.ts-snapshots/settings-page-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/screenshots.spec.ts-snapshots/team-invite-dialog-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/screenshots.spec.ts-snapshots/team-page-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/screenshots.spec.ts-snapshots/webhook-create-dialog-visual-darwin.png +0 -0
- package/templates/base/tests/e2e/visual/theme-colors.spec.ts +293 -0
- package/templates/base/tests/e2e/visual/ui-components.spec.ts +502 -0
- package/templates/base/tests/integration/accounts/crud.test.ts +1402 -0
- package/templates/base/tests/integration/audits/list.test.ts +1133 -0
- package/templates/base/tests/integration/auth/auth-service.test.ts +415 -0
- package/templates/base/tests/integration/auth/invitation-token.test.ts +529 -0
- package/templates/base/tests/integration/auth/logout.test.ts +524 -0
- package/templates/base/tests/integration/auth/oauth.test.ts +768 -0
- package/templates/base/tests/integration/auth/refresh-token.test.ts +364 -0
- package/templates/base/tests/integration/auth/session-expiry.test.ts +569 -0
- package/templates/base/tests/integration/auth/session.test.ts +520 -0
- package/templates/base/tests/integration/auth/super-admin.test.ts +451 -0
- package/templates/base/tests/integration/authorization/analytics-role.test.ts +1026 -0
- package/templates/base/tests/integration/authorization/billing-role.test.ts +776 -0
- package/templates/base/tests/integration/authorization/guards-roles.test.ts +539 -0
- package/templates/base/tests/integration/authorization/multi-tenancy.test.ts +1112 -0
- package/templates/base/tests/integration/authorization/role-hierarchy.test.ts +931 -0
- package/templates/base/tests/integration/authorization/roles.test.ts +1347 -0
- package/templates/base/tests/integration/config/production-behavior.test.ts +536 -0
- package/templates/base/tests/integration/db/constraints.test.ts +695 -0
- package/templates/base/tests/integration/fixtures/accounts.ts +136 -0
- package/templates/base/tests/integration/fixtures/index.ts +232 -0
- package/templates/base/tests/integration/fixtures/invitations.ts +195 -0
- package/templates/base/tests/integration/fixtures/users.ts +144 -0
- package/templates/base/tests/integration/health/health.test.ts +351 -0
- package/templates/base/tests/integration/invitations/crud.test.ts +1457 -0
- package/templates/base/tests/integration/invitations/email.test.ts +506 -0
- package/templates/base/tests/integration/lib/email.test.ts +174 -0
- package/templates/base/tests/integration/lib/oauth.test.ts +368 -0
- package/templates/base/tests/integration/lib/password.test.ts +192 -0
- package/templates/base/tests/integration/lib/schema-helpers.test.ts +129 -0
- package/templates/base/tests/integration/lib/tokens.test.ts +304 -0
- package/templates/base/tests/integration/middleware/auth.test.ts +499 -0
- package/templates/base/tests/integration/middleware/cors.test.ts +334 -0
- package/templates/base/tests/integration/middleware/request-context.test.ts +156 -0
- package/templates/base/tests/integration/middleware/request-logger.test.ts +313 -0
- package/templates/base/tests/integration/performance/response-times.test.ts +509 -0
- package/templates/base/tests/integration/security/cookie-security.test.ts +567 -0
- package/templates/base/tests/integration/security/csrf-protection.test.ts +542 -0
- package/templates/base/tests/integration/security/jwt-validation.test.ts +209 -0
- package/templates/base/tests/integration/security/log-sanitization.test.ts +658 -0
- package/templates/base/tests/integration/security/rate-limiting.test.ts +1251 -0
- package/templates/base/tests/integration/security/sql-injection.test.ts +663 -0
- package/templates/base/tests/integration/security/token-hashing.test.ts +371 -0
- package/templates/base/tests/integration/security/xss-prevention.test.ts +541 -0
- package/templates/base/tests/integration/setup.ts +834 -0
- package/templates/base/tests/integration/smoke.test.ts +288 -0
- package/templates/base/tests/integration/storage/upload.test.ts +1162 -0
- package/templates/base/tests/integration/storage/validation.test.ts +746 -0
- package/templates/base/tests/integration/users/crud.test.ts +1297 -0
- package/templates/base/tests/integration/users/list.test.ts +698 -0
- package/templates/base/tests/integration/vitest.config.ts +80 -0
- package/templates/base/tsconfig.app.json +18 -0
- package/templates/base/tsconfig.json +39 -0
- package/templates/base/tsconfig.node.json +16 -0
- package/templates/base/tsconfig.server.json +26 -0
- package/templates/base/tsconfig.tsbuildinfo +1 -0
- package/templates/base/vite.config.ts +46 -0
- package/templates/base/vitest.config.browser.ts +47 -0
- package/templates/base/vitest.config.frontend.ts +47 -0
- package/templates/base/vitest.config.ts +82 -0
- package/templates/base/vitest.workspace.ts +22 -0
- package/templates/modules/audit-logs/.gitkeep +0 -0
- package/templates/modules/billing/.gitkeep +0 -0
- package/templates/modules/invitations/.gitkeep +0 -0
- package/templates/modules/storage/.gitkeep +0 -0
- package/templates/modules/webhooks/.gitkeep +0 -0
- package/templates/providers/auth-email/.gitkeep +0 -0
- package/templates/providers/auth-github/.gitkeep +0 -0
- package/templates/providers/auth-google/.gitkeep +0 -0
- package/templates/providers/email-resend/.gitkeep +0 -0
- package/templates/providers/email-sendgrid/.gitkeep +0 -0
|
@@ -0,0 +1,1162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storage Integration Tests
|
|
3
|
+
*
|
|
4
|
+
* Tests the storage operations for file upload, download, and deletion:
|
|
5
|
+
* - POST /api/storage/upload-url - Generate presigned upload URL (requires AUTHOR role)
|
|
6
|
+
* - PUT /api/storage/upload/{key} - Upload file (requires AUTHOR role)
|
|
7
|
+
* - DELETE /api/storage/{key} - Delete file (requires EDITOR role)
|
|
8
|
+
*
|
|
9
|
+
* Permission Matrix:
|
|
10
|
+
* | Operation | ADMIN | MANAGER | EDITOR | AUTHOR | VIEWER |
|
|
11
|
+
* |-------------------------|-------|---------|--------|--------|--------|
|
|
12
|
+
* | Generate upload URL | Y | Y | Y | Y | N |
|
|
13
|
+
* | Upload file | Y | Y | Y | Y | N |
|
|
14
|
+
* | Delete file | Y | Y | Y | N | N |
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { describe, it, expect, beforeAll } from 'vitest'
|
|
18
|
+
import { Hono } from 'hono'
|
|
19
|
+
import { getEnv, getDb, getR2, type TestEnv, type MockR2Store } from '../setup'
|
|
20
|
+
import {
|
|
21
|
+
createUser,
|
|
22
|
+
createUserSession,
|
|
23
|
+
createAccount,
|
|
24
|
+
addUserToAccount,
|
|
25
|
+
type Role,
|
|
26
|
+
} from '../fixtures'
|
|
27
|
+
import type { HonoEnv } from '../../../src/server/types'
|
|
28
|
+
import { api } from '../../../src/server/routes'
|
|
29
|
+
import { errorHandler } from '../../../src/server/middleware/error-handler'
|
|
30
|
+
import { sessionMiddleware } from '../../../src/server/lib/session'
|
|
31
|
+
|
|
32
|
+
// ============================================================================
|
|
33
|
+
// TEST SETUP
|
|
34
|
+
// ============================================================================
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Creates a database wrapper that adds the `execute` method
|
|
38
|
+
* The better-sqlite3 drizzle doesn't have execute, but D1 does
|
|
39
|
+
*/
|
|
40
|
+
function createTestDb() {
|
|
41
|
+
const db = getDb()
|
|
42
|
+
return new Proxy(db, {
|
|
43
|
+
get(target, prop) {
|
|
44
|
+
if (prop === 'execute') {
|
|
45
|
+
return target.run.bind(target)
|
|
46
|
+
}
|
|
47
|
+
return (target as any)[prop]
|
|
48
|
+
},
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Helper to create a user with a specific role in an account
|
|
54
|
+
*/
|
|
55
|
+
async function createUserWithRole(
|
|
56
|
+
accountId: string,
|
|
57
|
+
role: Role,
|
|
58
|
+
options?: { email?: string; name?: string }
|
|
59
|
+
): Promise<{
|
|
60
|
+
user: Awaited<ReturnType<typeof createUser>>
|
|
61
|
+
sessionId: string
|
|
62
|
+
headers: Record<string, string>
|
|
63
|
+
}> {
|
|
64
|
+
const user = await createUser({
|
|
65
|
+
email: options?.email ?? `${role.toLowerCase()}-user-${crypto.randomUUID().slice(0, 8)}@example.com`,
|
|
66
|
+
name: options?.name ?? `${role} User`,
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
await addUserToAccount(user.id, accountId, role)
|
|
70
|
+
|
|
71
|
+
const { sessionId, headers } = await createUserSession(user.id, {
|
|
72
|
+
email: user.email,
|
|
73
|
+
name: user.name,
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
return { user, sessionId, headers }
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// ============================================================================
|
|
80
|
+
// TESTS
|
|
81
|
+
// ============================================================================
|
|
82
|
+
|
|
83
|
+
describe('Storage Integration', () => {
|
|
84
|
+
let app: Hono<HonoEnv>
|
|
85
|
+
let env: TestEnv
|
|
86
|
+
|
|
87
|
+
beforeAll(() => {
|
|
88
|
+
env = getEnv()
|
|
89
|
+
app = new Hono<HonoEnv>()
|
|
90
|
+
|
|
91
|
+
// Set up error handler
|
|
92
|
+
app.onError(errorHandler)
|
|
93
|
+
|
|
94
|
+
// Set up middleware to inject test environment
|
|
95
|
+
app.use('*', async (c, next) => {
|
|
96
|
+
// Inject environment bindings
|
|
97
|
+
;(c as any).env = env
|
|
98
|
+
|
|
99
|
+
// Set up database
|
|
100
|
+
const db = createTestDb()
|
|
101
|
+
c.set('db', db)
|
|
102
|
+
|
|
103
|
+
// Set up request context variables
|
|
104
|
+
c.set('transactionId', crypto.randomUUID())
|
|
105
|
+
c.set('ip', '127.0.0.1')
|
|
106
|
+
c.set('userAgent', 'IntegrationTest/1.0')
|
|
107
|
+
|
|
108
|
+
await next()
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
// Session middleware - reads session from KV and sets sessionData in context
|
|
112
|
+
app.use('*', sessionMiddleware())
|
|
113
|
+
|
|
114
|
+
// Mount API routes (includes sessionAuth and accountMiddleware)
|
|
115
|
+
app.route('/api', api)
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
// ============================================================================
|
|
119
|
+
// POST /api/storage/upload-url - Generate Upload URL
|
|
120
|
+
// ============================================================================
|
|
121
|
+
|
|
122
|
+
describe('POST /api/storage/upload-url', () => {
|
|
123
|
+
describe('Authentication (401)', () => {
|
|
124
|
+
it('should return 401 without session cookie', async () => {
|
|
125
|
+
const res = await app.request('/api/storage/upload-url', {
|
|
126
|
+
method: 'POST',
|
|
127
|
+
headers: {
|
|
128
|
+
'Content-Type': 'application/json',
|
|
129
|
+
},
|
|
130
|
+
body: JSON.stringify({
|
|
131
|
+
filename: 'test.txt',
|
|
132
|
+
contentType: 'text/plain',
|
|
133
|
+
}),
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
expect(res.status).toBe(401)
|
|
137
|
+
|
|
138
|
+
const body = await res.json()
|
|
139
|
+
expect(body).toHaveProperty('error')
|
|
140
|
+
expect(body.error.message).toBe('Not authenticated')
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
it('should return 401 with invalid session ID', async () => {
|
|
144
|
+
const res = await app.request('/api/storage/upload-url', {
|
|
145
|
+
method: 'POST',
|
|
146
|
+
headers: {
|
|
147
|
+
Cookie: 'sid=invalid-session-id-that-does-not-exist',
|
|
148
|
+
'account-id': crypto.randomUUID(),
|
|
149
|
+
'Content-Type': 'application/json',
|
|
150
|
+
},
|
|
151
|
+
body: JSON.stringify({
|
|
152
|
+
filename: 'test.txt',
|
|
153
|
+
contentType: 'text/plain',
|
|
154
|
+
}),
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
expect(res.status).toBe(401)
|
|
158
|
+
|
|
159
|
+
const body = await res.json()
|
|
160
|
+
expect(body.error.message).toBe('Not authenticated')
|
|
161
|
+
})
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
describe('Authorization (403)', () => {
|
|
165
|
+
it('should return 403 if user lacks upload permission (VIEWER role)', async () => {
|
|
166
|
+
const account = await createAccount({ name: 'Storage Viewer Test' })
|
|
167
|
+
const { headers } = await createUserWithRole(account.id, 'VIEWER')
|
|
168
|
+
|
|
169
|
+
const res = await app.request('/api/storage/upload-url', {
|
|
170
|
+
method: 'POST',
|
|
171
|
+
headers: {
|
|
172
|
+
...headers,
|
|
173
|
+
'User-Agent': 'IntegrationTest/1.0',
|
|
174
|
+
'account-id': account.id,
|
|
175
|
+
'Content-Type': 'application/json',
|
|
176
|
+
},
|
|
177
|
+
body: JSON.stringify({
|
|
178
|
+
filename: 'test.txt',
|
|
179
|
+
contentType: 'text/plain',
|
|
180
|
+
}),
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
expect(res.status).toBe(403)
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
it('should return 403 if BILLING role tries to upload', async () => {
|
|
187
|
+
const account = await createAccount({ name: 'Storage Billing Test' })
|
|
188
|
+
const { headers } = await createUserWithRole(account.id, 'BILLING')
|
|
189
|
+
|
|
190
|
+
const res = await app.request('/api/storage/upload-url', {
|
|
191
|
+
method: 'POST',
|
|
192
|
+
headers: {
|
|
193
|
+
...headers,
|
|
194
|
+
'User-Agent': 'IntegrationTest/1.0',
|
|
195
|
+
'account-id': account.id,
|
|
196
|
+
'Content-Type': 'application/json',
|
|
197
|
+
},
|
|
198
|
+
body: JSON.stringify({
|
|
199
|
+
filename: 'test.txt',
|
|
200
|
+
contentType: 'text/plain',
|
|
201
|
+
}),
|
|
202
|
+
})
|
|
203
|
+
|
|
204
|
+
expect(res.status).toBe(403)
|
|
205
|
+
})
|
|
206
|
+
|
|
207
|
+
it('should return 403 if ANALYTICS role tries to upload', async () => {
|
|
208
|
+
const account = await createAccount({ name: 'Storage Analytics Test' })
|
|
209
|
+
const { headers } = await createUserWithRole(account.id, 'ANALYTICS')
|
|
210
|
+
|
|
211
|
+
const res = await app.request('/api/storage/upload-url', {
|
|
212
|
+
method: 'POST',
|
|
213
|
+
headers: {
|
|
214
|
+
...headers,
|
|
215
|
+
'User-Agent': 'IntegrationTest/1.0',
|
|
216
|
+
'account-id': account.id,
|
|
217
|
+
'Content-Type': 'application/json',
|
|
218
|
+
},
|
|
219
|
+
body: JSON.stringify({
|
|
220
|
+
filename: 'test.txt',
|
|
221
|
+
contentType: 'text/plain',
|
|
222
|
+
}),
|
|
223
|
+
})
|
|
224
|
+
|
|
225
|
+
expect(res.status).toBe(403)
|
|
226
|
+
})
|
|
227
|
+
})
|
|
228
|
+
|
|
229
|
+
describe('Validation (400)', () => {
|
|
230
|
+
it('should return 400 for missing filename', async () => {
|
|
231
|
+
const account = await createAccount({ name: 'Storage Validation Test' })
|
|
232
|
+
const { headers } = await createUserWithRole(account.id, 'AUTHOR')
|
|
233
|
+
|
|
234
|
+
const res = await app.request('/api/storage/upload-url', {
|
|
235
|
+
method: 'POST',
|
|
236
|
+
headers: {
|
|
237
|
+
...headers,
|
|
238
|
+
'User-Agent': 'IntegrationTest/1.0',
|
|
239
|
+
'account-id': account.id,
|
|
240
|
+
'Content-Type': 'application/json',
|
|
241
|
+
},
|
|
242
|
+
body: JSON.stringify({
|
|
243
|
+
contentType: 'text/plain',
|
|
244
|
+
}),
|
|
245
|
+
})
|
|
246
|
+
|
|
247
|
+
expect(res.status).toBe(400)
|
|
248
|
+
})
|
|
249
|
+
|
|
250
|
+
it('should return 400 for missing contentType', async () => {
|
|
251
|
+
const account = await createAccount({ name: 'Storage ContentType Test' })
|
|
252
|
+
const { headers } = await createUserWithRole(account.id, 'AUTHOR')
|
|
253
|
+
|
|
254
|
+
const res = await app.request('/api/storage/upload-url', {
|
|
255
|
+
method: 'POST',
|
|
256
|
+
headers: {
|
|
257
|
+
...headers,
|
|
258
|
+
'User-Agent': 'IntegrationTest/1.0',
|
|
259
|
+
'account-id': account.id,
|
|
260
|
+
'Content-Type': 'application/json',
|
|
261
|
+
},
|
|
262
|
+
body: JSON.stringify({
|
|
263
|
+
filename: 'test.txt',
|
|
264
|
+
}),
|
|
265
|
+
})
|
|
266
|
+
|
|
267
|
+
expect(res.status).toBe(400)
|
|
268
|
+
})
|
|
269
|
+
|
|
270
|
+
it('should return 400 for empty filename', async () => {
|
|
271
|
+
const account = await createAccount({ name: 'Storage Empty Filename Test' })
|
|
272
|
+
const { headers } = await createUserWithRole(account.id, 'AUTHOR')
|
|
273
|
+
|
|
274
|
+
const res = await app.request('/api/storage/upload-url', {
|
|
275
|
+
method: 'POST',
|
|
276
|
+
headers: {
|
|
277
|
+
...headers,
|
|
278
|
+
'User-Agent': 'IntegrationTest/1.0',
|
|
279
|
+
'account-id': account.id,
|
|
280
|
+
'Content-Type': 'application/json',
|
|
281
|
+
},
|
|
282
|
+
body: JSON.stringify({
|
|
283
|
+
filename: '',
|
|
284
|
+
contentType: 'text/plain',
|
|
285
|
+
}),
|
|
286
|
+
})
|
|
287
|
+
|
|
288
|
+
expect(res.status).toBe(400)
|
|
289
|
+
})
|
|
290
|
+
|
|
291
|
+
it('should return 400 for empty contentType', async () => {
|
|
292
|
+
const account = await createAccount({ name: 'Storage Empty ContentType Test' })
|
|
293
|
+
const { headers } = await createUserWithRole(account.id, 'AUTHOR')
|
|
294
|
+
|
|
295
|
+
const res = await app.request('/api/storage/upload-url', {
|
|
296
|
+
method: 'POST',
|
|
297
|
+
headers: {
|
|
298
|
+
...headers,
|
|
299
|
+
'User-Agent': 'IntegrationTest/1.0',
|
|
300
|
+
'account-id': account.id,
|
|
301
|
+
'Content-Type': 'application/json',
|
|
302
|
+
},
|
|
303
|
+
body: JSON.stringify({
|
|
304
|
+
filename: 'test.txt',
|
|
305
|
+
contentType: '',
|
|
306
|
+
}),
|
|
307
|
+
})
|
|
308
|
+
|
|
309
|
+
expect(res.status).toBe(400)
|
|
310
|
+
})
|
|
311
|
+
})
|
|
312
|
+
|
|
313
|
+
describe('Successful Upload URL Generation (200)', () => {
|
|
314
|
+
it('should return 200 with upload URL for AUTHOR role', async () => {
|
|
315
|
+
const account = await createAccount({ name: 'Storage Author Upload URL Test' })
|
|
316
|
+
const { headers } = await createUserWithRole(account.id, 'AUTHOR')
|
|
317
|
+
|
|
318
|
+
const res = await app.request('/api/storage/upload-url', {
|
|
319
|
+
method: 'POST',
|
|
320
|
+
headers: {
|
|
321
|
+
...headers,
|
|
322
|
+
'User-Agent': 'IntegrationTest/1.0',
|
|
323
|
+
'account-id': account.id,
|
|
324
|
+
'Content-Type': 'application/json',
|
|
325
|
+
},
|
|
326
|
+
body: JSON.stringify({
|
|
327
|
+
filename: 'test-file.txt',
|
|
328
|
+
contentType: 'text/plain',
|
|
329
|
+
}),
|
|
330
|
+
})
|
|
331
|
+
|
|
332
|
+
expect(res.status).toBe(200)
|
|
333
|
+
|
|
334
|
+
const body = await res.json()
|
|
335
|
+
expect(body).toHaveProperty('url')
|
|
336
|
+
expect(body).toHaveProperty('name')
|
|
337
|
+
expect(body).toHaveProperty('publicUrl')
|
|
338
|
+
expect(body.url).toContain('/api/storage/upload/')
|
|
339
|
+
expect(body.name).toContain('test-file.txt')
|
|
340
|
+
expect(body.publicUrl).toContain('test-file.txt')
|
|
341
|
+
})
|
|
342
|
+
|
|
343
|
+
it('should return 200 with upload URL for EDITOR role', async () => {
|
|
344
|
+
const account = await createAccount({ name: 'Storage Editor Upload URL Test' })
|
|
345
|
+
const { headers } = await createUserWithRole(account.id, 'EDITOR')
|
|
346
|
+
|
|
347
|
+
const res = await app.request('/api/storage/upload-url', {
|
|
348
|
+
method: 'POST',
|
|
349
|
+
headers: {
|
|
350
|
+
...headers,
|
|
351
|
+
'User-Agent': 'IntegrationTest/1.0',
|
|
352
|
+
'account-id': account.id,
|
|
353
|
+
'Content-Type': 'application/json',
|
|
354
|
+
},
|
|
355
|
+
body: JSON.stringify({
|
|
356
|
+
filename: 'test-file.txt',
|
|
357
|
+
contentType: 'text/plain',
|
|
358
|
+
}),
|
|
359
|
+
})
|
|
360
|
+
|
|
361
|
+
expect(res.status).toBe(200)
|
|
362
|
+
})
|
|
363
|
+
|
|
364
|
+
it('should return 200 with upload URL for MANAGER role', async () => {
|
|
365
|
+
const account = await createAccount({ name: 'Storage Manager Upload URL Test' })
|
|
366
|
+
const { headers } = await createUserWithRole(account.id, 'MANAGER')
|
|
367
|
+
|
|
368
|
+
const res = await app.request('/api/storage/upload-url', {
|
|
369
|
+
method: 'POST',
|
|
370
|
+
headers: {
|
|
371
|
+
...headers,
|
|
372
|
+
'User-Agent': 'IntegrationTest/1.0',
|
|
373
|
+
'account-id': account.id,
|
|
374
|
+
'Content-Type': 'application/json',
|
|
375
|
+
},
|
|
376
|
+
body: JSON.stringify({
|
|
377
|
+
filename: 'test-file.txt',
|
|
378
|
+
contentType: 'text/plain',
|
|
379
|
+
}),
|
|
380
|
+
})
|
|
381
|
+
|
|
382
|
+
expect(res.status).toBe(200)
|
|
383
|
+
})
|
|
384
|
+
|
|
385
|
+
it('should return 200 with upload URL for ADMIN role', async () => {
|
|
386
|
+
const account = await createAccount({ name: 'Storage Admin Upload URL Test' })
|
|
387
|
+
const { headers } = await createUserWithRole(account.id, 'ADMIN')
|
|
388
|
+
|
|
389
|
+
const res = await app.request('/api/storage/upload-url', {
|
|
390
|
+
method: 'POST',
|
|
391
|
+
headers: {
|
|
392
|
+
...headers,
|
|
393
|
+
'User-Agent': 'IntegrationTest/1.0',
|
|
394
|
+
'account-id': account.id,
|
|
395
|
+
'Content-Type': 'application/json',
|
|
396
|
+
},
|
|
397
|
+
body: JSON.stringify({
|
|
398
|
+
filename: 'test-file.txt',
|
|
399
|
+
contentType: 'text/plain',
|
|
400
|
+
}),
|
|
401
|
+
})
|
|
402
|
+
|
|
403
|
+
expect(res.status).toBe(200)
|
|
404
|
+
})
|
|
405
|
+
|
|
406
|
+
it('should preserve folder structure in filename', async () => {
|
|
407
|
+
const account = await createAccount({ name: 'Storage Folder Structure Test' })
|
|
408
|
+
const { headers } = await createUserWithRole(account.id, 'AUTHOR')
|
|
409
|
+
|
|
410
|
+
const res = await app.request('/api/storage/upload-url', {
|
|
411
|
+
method: 'POST',
|
|
412
|
+
headers: {
|
|
413
|
+
...headers,
|
|
414
|
+
'User-Agent': 'IntegrationTest/1.0',
|
|
415
|
+
'account-id': account.id,
|
|
416
|
+
'Content-Type': 'application/json',
|
|
417
|
+
},
|
|
418
|
+
body: JSON.stringify({
|
|
419
|
+
filename: 'images/photos/my-photo.jpg',
|
|
420
|
+
contentType: 'image/jpeg',
|
|
421
|
+
}),
|
|
422
|
+
})
|
|
423
|
+
|
|
424
|
+
expect(res.status).toBe(200)
|
|
425
|
+
|
|
426
|
+
const body = await res.json()
|
|
427
|
+
expect(body.name).toContain('images/')
|
|
428
|
+
expect(body.name).toContain('my-photo.jpg')
|
|
429
|
+
expect(body.publicUrl).toContain('images/')
|
|
430
|
+
})
|
|
431
|
+
|
|
432
|
+
it('should generate unique filename with timestamp', async () => {
|
|
433
|
+
const account = await createAccount({ name: 'Storage Unique Filename Test' })
|
|
434
|
+
const { headers } = await createUserWithRole(account.id, 'AUTHOR')
|
|
435
|
+
|
|
436
|
+
// Make two requests with the same filename
|
|
437
|
+
const res1 = await app.request('/api/storage/upload-url', {
|
|
438
|
+
method: 'POST',
|
|
439
|
+
headers: {
|
|
440
|
+
...headers,
|
|
441
|
+
'User-Agent': 'IntegrationTest/1.0',
|
|
442
|
+
'account-id': account.id,
|
|
443
|
+
'Content-Type': 'application/json',
|
|
444
|
+
},
|
|
445
|
+
body: JSON.stringify({
|
|
446
|
+
filename: 'duplicate.txt',
|
|
447
|
+
contentType: 'text/plain',
|
|
448
|
+
}),
|
|
449
|
+
})
|
|
450
|
+
|
|
451
|
+
// Add a small delay to ensure different timestamp
|
|
452
|
+
await new Promise((resolve) => setTimeout(resolve, 2))
|
|
453
|
+
|
|
454
|
+
const res2 = await app.request('/api/storage/upload-url', {
|
|
455
|
+
method: 'POST',
|
|
456
|
+
headers: {
|
|
457
|
+
...headers,
|
|
458
|
+
'User-Agent': 'IntegrationTest/1.0',
|
|
459
|
+
'account-id': account.id,
|
|
460
|
+
'Content-Type': 'application/json',
|
|
461
|
+
},
|
|
462
|
+
body: JSON.stringify({
|
|
463
|
+
filename: 'duplicate.txt',
|
|
464
|
+
contentType: 'text/plain',
|
|
465
|
+
}),
|
|
466
|
+
})
|
|
467
|
+
|
|
468
|
+
expect(res1.status).toBe(200)
|
|
469
|
+
expect(res2.status).toBe(200)
|
|
470
|
+
|
|
471
|
+
const body1 = await res1.json()
|
|
472
|
+
const body2 = await res2.json()
|
|
473
|
+
|
|
474
|
+
// Filenames should be different (unique with timestamp)
|
|
475
|
+
expect(body1.name).not.toBe(body2.name)
|
|
476
|
+
})
|
|
477
|
+
})
|
|
478
|
+
})
|
|
479
|
+
|
|
480
|
+
// ============================================================================
|
|
481
|
+
// PUT /api/storage/upload/{key} - Upload File
|
|
482
|
+
// ============================================================================
|
|
483
|
+
|
|
484
|
+
describe('PUT /api/storage/upload/{key}', () => {
|
|
485
|
+
describe('Authentication (401)', () => {
|
|
486
|
+
it('should return 401 without session cookie', async () => {
|
|
487
|
+
const res = await app.request('/api/storage/upload/test-key.txt', {
|
|
488
|
+
method: 'PUT',
|
|
489
|
+
headers: {
|
|
490
|
+
'Content-Type': 'text/plain',
|
|
491
|
+
},
|
|
492
|
+
body: 'test content',
|
|
493
|
+
})
|
|
494
|
+
|
|
495
|
+
expect(res.status).toBe(401)
|
|
496
|
+
|
|
497
|
+
const body = await res.json()
|
|
498
|
+
expect(body.error.message).toBe('Not authenticated')
|
|
499
|
+
})
|
|
500
|
+
})
|
|
501
|
+
|
|
502
|
+
describe('Authorization (403)', () => {
|
|
503
|
+
it('should return 403 if user lacks upload permission (VIEWER role)', async () => {
|
|
504
|
+
const account = await createAccount({ name: 'Storage Viewer Upload Test' })
|
|
505
|
+
const { headers } = await createUserWithRole(account.id, 'VIEWER')
|
|
506
|
+
|
|
507
|
+
const res = await app.request('/api/storage/upload/test-key.txt', {
|
|
508
|
+
method: 'PUT',
|
|
509
|
+
headers: {
|
|
510
|
+
...headers,
|
|
511
|
+
'User-Agent': 'IntegrationTest/1.0',
|
|
512
|
+
'account-id': account.id,
|
|
513
|
+
'Content-Type': 'text/plain',
|
|
514
|
+
},
|
|
515
|
+
body: 'test content',
|
|
516
|
+
})
|
|
517
|
+
|
|
518
|
+
expect(res.status).toBe(403)
|
|
519
|
+
})
|
|
520
|
+
})
|
|
521
|
+
|
|
522
|
+
describe('Validation (400)', () => {
|
|
523
|
+
it('should return 400 for empty request body', async () => {
|
|
524
|
+
const account = await createAccount({ name: 'Storage Empty Body Test' })
|
|
525
|
+
const { headers } = await createUserWithRole(account.id, 'AUTHOR')
|
|
526
|
+
|
|
527
|
+
const res = await app.request('/api/storage/upload/test-key.txt', {
|
|
528
|
+
method: 'PUT',
|
|
529
|
+
headers: {
|
|
530
|
+
...headers,
|
|
531
|
+
'User-Agent': 'IntegrationTest/1.0',
|
|
532
|
+
'account-id': account.id,
|
|
533
|
+
'Content-Type': 'text/plain',
|
|
534
|
+
},
|
|
535
|
+
body: '',
|
|
536
|
+
})
|
|
537
|
+
|
|
538
|
+
expect(res.status).toBe(400)
|
|
539
|
+
|
|
540
|
+
const body = await res.json()
|
|
541
|
+
expect(body.error.message).toContain('empty')
|
|
542
|
+
})
|
|
543
|
+
})
|
|
544
|
+
|
|
545
|
+
describe('Successful Upload (200)', () => {
|
|
546
|
+
it('should return 200 on successful text file upload', async () => {
|
|
547
|
+
const account = await createAccount({ name: 'Storage Text Upload Test' })
|
|
548
|
+
const { headers } = await createUserWithRole(account.id, 'AUTHOR')
|
|
549
|
+
const r2 = getR2()
|
|
550
|
+
|
|
551
|
+
const fileKey = `test-${Date.now()}.txt`
|
|
552
|
+
const fileContent = 'Hello, World!'
|
|
553
|
+
|
|
554
|
+
const res = await app.request(`/api/storage/upload/${encodeURIComponent(fileKey)}`, {
|
|
555
|
+
method: 'PUT',
|
|
556
|
+
headers: {
|
|
557
|
+
...headers,
|
|
558
|
+
'User-Agent': 'IntegrationTest/1.0',
|
|
559
|
+
'account-id': account.id,
|
|
560
|
+
'Content-Type': 'text/plain',
|
|
561
|
+
},
|
|
562
|
+
body: fileContent,
|
|
563
|
+
})
|
|
564
|
+
|
|
565
|
+
expect(res.status).toBe(200)
|
|
566
|
+
|
|
567
|
+
const body = await res.json()
|
|
568
|
+
expect(body).toHaveProperty('success', true)
|
|
569
|
+
expect(body).toHaveProperty('key', fileKey)
|
|
570
|
+
expect(body).toHaveProperty('publicUrl')
|
|
571
|
+
|
|
572
|
+
// Verify file is stored in R2 bucket
|
|
573
|
+
const stored = await r2.get(fileKey)
|
|
574
|
+
expect(stored).not.toBeNull()
|
|
575
|
+
if (stored) {
|
|
576
|
+
const storedContent = await stored.text()
|
|
577
|
+
expect(storedContent).toBe(fileContent)
|
|
578
|
+
}
|
|
579
|
+
})
|
|
580
|
+
|
|
581
|
+
it('should return 200 on successful binary file upload', async () => {
|
|
582
|
+
const account = await createAccount({ name: 'Storage Binary Upload Test' })
|
|
583
|
+
const { headers } = await createUserWithRole(account.id, 'AUTHOR')
|
|
584
|
+
const r2 = getR2()
|
|
585
|
+
|
|
586
|
+
const fileKey = `test-${Date.now()}.bin`
|
|
587
|
+
const binaryContent = new Uint8Array([0x00, 0x01, 0x02, 0x03, 0xff])
|
|
588
|
+
|
|
589
|
+
const res = await app.request(`/api/storage/upload/${encodeURIComponent(fileKey)}`, {
|
|
590
|
+
method: 'PUT',
|
|
591
|
+
headers: {
|
|
592
|
+
...headers,
|
|
593
|
+
'User-Agent': 'IntegrationTest/1.0',
|
|
594
|
+
'account-id': account.id,
|
|
595
|
+
'Content-Type': 'application/octet-stream',
|
|
596
|
+
},
|
|
597
|
+
body: binaryContent,
|
|
598
|
+
})
|
|
599
|
+
|
|
600
|
+
expect(res.status).toBe(200)
|
|
601
|
+
|
|
602
|
+
// Verify file is stored in R2 bucket
|
|
603
|
+
const stored = await r2.get(fileKey)
|
|
604
|
+
expect(stored).not.toBeNull()
|
|
605
|
+
if (stored) {
|
|
606
|
+
const storedBuffer = await stored.arrayBuffer()
|
|
607
|
+
const storedContent = new Uint8Array(storedBuffer)
|
|
608
|
+
expect(storedContent).toEqual(binaryContent)
|
|
609
|
+
}
|
|
610
|
+
})
|
|
611
|
+
|
|
612
|
+
it('should handle URL-encoded file keys', async () => {
|
|
613
|
+
const account = await createAccount({ name: 'Storage Encoded Key Test' })
|
|
614
|
+
const { headers } = await createUserWithRole(account.id, 'AUTHOR')
|
|
615
|
+
const r2 = getR2()
|
|
616
|
+
|
|
617
|
+
const fileKey = `folder/subfolder/test-${Date.now()}.txt`
|
|
618
|
+
const fileContent = 'Nested file content'
|
|
619
|
+
|
|
620
|
+
const res = await app.request(`/api/storage/upload/${encodeURIComponent(fileKey)}`, {
|
|
621
|
+
method: 'PUT',
|
|
622
|
+
headers: {
|
|
623
|
+
...headers,
|
|
624
|
+
'User-Agent': 'IntegrationTest/1.0',
|
|
625
|
+
'account-id': account.id,
|
|
626
|
+
'Content-Type': 'text/plain',
|
|
627
|
+
},
|
|
628
|
+
body: fileContent,
|
|
629
|
+
})
|
|
630
|
+
|
|
631
|
+
expect(res.status).toBe(200)
|
|
632
|
+
|
|
633
|
+
const body = await res.json()
|
|
634
|
+
expect(body.key).toBe(fileKey)
|
|
635
|
+
|
|
636
|
+
// Verify file is stored with correct key
|
|
637
|
+
const stored = await r2.get(fileKey)
|
|
638
|
+
expect(stored).not.toBeNull()
|
|
639
|
+
})
|
|
640
|
+
|
|
641
|
+
it('should return correct public URL in response', async () => {
|
|
642
|
+
const account = await createAccount({ name: 'Storage Public URL Test' })
|
|
643
|
+
const { headers } = await createUserWithRole(account.id, 'AUTHOR')
|
|
644
|
+
|
|
645
|
+
const fileKey = `test-${Date.now()}.txt`
|
|
646
|
+
|
|
647
|
+
const res = await app.request(`/api/storage/upload/${encodeURIComponent(fileKey)}`, {
|
|
648
|
+
method: 'PUT',
|
|
649
|
+
headers: {
|
|
650
|
+
...headers,
|
|
651
|
+
'User-Agent': 'IntegrationTest/1.0',
|
|
652
|
+
'account-id': account.id,
|
|
653
|
+
'Content-Type': 'text/plain',
|
|
654
|
+
},
|
|
655
|
+
body: 'test content',
|
|
656
|
+
})
|
|
657
|
+
|
|
658
|
+
expect(res.status).toBe(200)
|
|
659
|
+
|
|
660
|
+
const body = await res.json()
|
|
661
|
+
expect(body.publicUrl).toContain('r2-test.example.com')
|
|
662
|
+
expect(body.publicUrl).toContain(fileKey)
|
|
663
|
+
})
|
|
664
|
+
})
|
|
665
|
+
})
|
|
666
|
+
|
|
667
|
+
// ============================================================================
|
|
668
|
+
// DELETE /api/storage/{key} - Delete File
|
|
669
|
+
// ============================================================================
|
|
670
|
+
|
|
671
|
+
describe('DELETE /api/storage/{key}', () => {
|
|
672
|
+
describe('Authentication (401)', () => {
|
|
673
|
+
it('should return 401 without session cookie', async () => {
|
|
674
|
+
const res = await app.request('/api/storage/test-key.txt', {
|
|
675
|
+
method: 'DELETE',
|
|
676
|
+
})
|
|
677
|
+
|
|
678
|
+
expect(res.status).toBe(401)
|
|
679
|
+
|
|
680
|
+
const body = await res.json()
|
|
681
|
+
expect(body.error.message).toBe('Not authenticated')
|
|
682
|
+
})
|
|
683
|
+
})
|
|
684
|
+
|
|
685
|
+
describe('Authorization (403)', () => {
|
|
686
|
+
it('should return 403 if user lacks delete permission (VIEWER role)', async () => {
|
|
687
|
+
const account = await createAccount({ name: 'Storage Viewer Delete Test' })
|
|
688
|
+
const { headers } = await createUserWithRole(account.id, 'VIEWER')
|
|
689
|
+
const r2 = getR2()
|
|
690
|
+
|
|
691
|
+
// First, create a file to delete
|
|
692
|
+
const fileKey = `delete-test-viewer-${Date.now()}.txt`
|
|
693
|
+
await r2.put(fileKey, 'test content')
|
|
694
|
+
|
|
695
|
+
const res = await app.request(`/api/storage/${encodeURIComponent(fileKey)}`, {
|
|
696
|
+
method: 'DELETE',
|
|
697
|
+
headers: {
|
|
698
|
+
...headers,
|
|
699
|
+
'User-Agent': 'IntegrationTest/1.0',
|
|
700
|
+
'account-id': account.id,
|
|
701
|
+
},
|
|
702
|
+
})
|
|
703
|
+
|
|
704
|
+
expect(res.status).toBe(403)
|
|
705
|
+
|
|
706
|
+
// Verify file still exists
|
|
707
|
+
const stored = await r2.get(fileKey)
|
|
708
|
+
expect(stored).not.toBeNull()
|
|
709
|
+
})
|
|
710
|
+
|
|
711
|
+
it('should return 403 if user lacks delete permission (AUTHOR role)', async () => {
|
|
712
|
+
const account = await createAccount({ name: 'Storage Author Delete Test' })
|
|
713
|
+
const { headers } = await createUserWithRole(account.id, 'AUTHOR')
|
|
714
|
+
const r2 = getR2()
|
|
715
|
+
|
|
716
|
+
// First, create a file to delete
|
|
717
|
+
const fileKey = `delete-test-author-${Date.now()}.txt`
|
|
718
|
+
await r2.put(fileKey, 'test content')
|
|
719
|
+
|
|
720
|
+
const res = await app.request(`/api/storage/${encodeURIComponent(fileKey)}`, {
|
|
721
|
+
method: 'DELETE',
|
|
722
|
+
headers: {
|
|
723
|
+
...headers,
|
|
724
|
+
'User-Agent': 'IntegrationTest/1.0',
|
|
725
|
+
'account-id': account.id,
|
|
726
|
+
},
|
|
727
|
+
})
|
|
728
|
+
|
|
729
|
+
expect(res.status).toBe(403)
|
|
730
|
+
|
|
731
|
+
// Verify file still exists
|
|
732
|
+
const stored = await r2.get(fileKey)
|
|
733
|
+
expect(stored).not.toBeNull()
|
|
734
|
+
})
|
|
735
|
+
})
|
|
736
|
+
|
|
737
|
+
describe('Not Found (404)', () => {
|
|
738
|
+
it('should return 404 for non-existent file', async () => {
|
|
739
|
+
const account = await createAccount({ name: 'Storage Not Found Test' })
|
|
740
|
+
const { headers } = await createUserWithRole(account.id, 'EDITOR')
|
|
741
|
+
|
|
742
|
+
const res = await app.request('/api/storage/non-existent-file.txt', {
|
|
743
|
+
method: 'DELETE',
|
|
744
|
+
headers: {
|
|
745
|
+
...headers,
|
|
746
|
+
'User-Agent': 'IntegrationTest/1.0',
|
|
747
|
+
'account-id': account.id,
|
|
748
|
+
},
|
|
749
|
+
})
|
|
750
|
+
|
|
751
|
+
expect(res.status).toBe(404)
|
|
752
|
+
|
|
753
|
+
const body = await res.json()
|
|
754
|
+
expect(body.error.message).toContain('File')
|
|
755
|
+
})
|
|
756
|
+
})
|
|
757
|
+
|
|
758
|
+
describe('Successful Delete (204)', () => {
|
|
759
|
+
it('should return 204 on successful delete for EDITOR role', async () => {
|
|
760
|
+
const account = await createAccount({ name: 'Storage Editor Delete Test' })
|
|
761
|
+
const { headers } = await createUserWithRole(account.id, 'EDITOR')
|
|
762
|
+
const r2 = getR2()
|
|
763
|
+
|
|
764
|
+
// First, create a file to delete
|
|
765
|
+
const fileKey = `delete-test-editor-${Date.now()}.txt`
|
|
766
|
+
await r2.put(fileKey, 'test content')
|
|
767
|
+
|
|
768
|
+
const res = await app.request(`/api/storage/${encodeURIComponent(fileKey)}`, {
|
|
769
|
+
method: 'DELETE',
|
|
770
|
+
headers: {
|
|
771
|
+
...headers,
|
|
772
|
+
'User-Agent': 'IntegrationTest/1.0',
|
|
773
|
+
'account-id': account.id,
|
|
774
|
+
},
|
|
775
|
+
})
|
|
776
|
+
|
|
777
|
+
expect(res.status).toBe(204)
|
|
778
|
+
|
|
779
|
+
// Verify file is removed from R2
|
|
780
|
+
const stored = await r2.get(fileKey)
|
|
781
|
+
expect(stored).toBeNull()
|
|
782
|
+
})
|
|
783
|
+
|
|
784
|
+
it('should return 204 on successful delete for MANAGER role', async () => {
|
|
785
|
+
const account = await createAccount({ name: 'Storage Manager Delete Test' })
|
|
786
|
+
const { headers } = await createUserWithRole(account.id, 'MANAGER')
|
|
787
|
+
const r2 = getR2()
|
|
788
|
+
|
|
789
|
+
// First, create a file to delete
|
|
790
|
+
const fileKey = `delete-test-manager-${Date.now()}.txt`
|
|
791
|
+
await r2.put(fileKey, 'test content')
|
|
792
|
+
|
|
793
|
+
const res = await app.request(`/api/storage/${encodeURIComponent(fileKey)}`, {
|
|
794
|
+
method: 'DELETE',
|
|
795
|
+
headers: {
|
|
796
|
+
...headers,
|
|
797
|
+
'User-Agent': 'IntegrationTest/1.0',
|
|
798
|
+
'account-id': account.id,
|
|
799
|
+
},
|
|
800
|
+
})
|
|
801
|
+
|
|
802
|
+
expect(res.status).toBe(204)
|
|
803
|
+
|
|
804
|
+
// Verify file is removed from R2
|
|
805
|
+
const stored = await r2.get(fileKey)
|
|
806
|
+
expect(stored).toBeNull()
|
|
807
|
+
})
|
|
808
|
+
|
|
809
|
+
it('should return 204 on successful delete for ADMIN role', async () => {
|
|
810
|
+
const account = await createAccount({ name: 'Storage Admin Delete Test' })
|
|
811
|
+
const { headers } = await createUserWithRole(account.id, 'ADMIN')
|
|
812
|
+
const r2 = getR2()
|
|
813
|
+
|
|
814
|
+
// First, create a file to delete
|
|
815
|
+
const fileKey = `delete-test-admin-${Date.now()}.txt`
|
|
816
|
+
await r2.put(fileKey, 'test content')
|
|
817
|
+
|
|
818
|
+
const res = await app.request(`/api/storage/${encodeURIComponent(fileKey)}`, {
|
|
819
|
+
method: 'DELETE',
|
|
820
|
+
headers: {
|
|
821
|
+
...headers,
|
|
822
|
+
'User-Agent': 'IntegrationTest/1.0',
|
|
823
|
+
'account-id': account.id,
|
|
824
|
+
},
|
|
825
|
+
})
|
|
826
|
+
|
|
827
|
+
expect(res.status).toBe(204)
|
|
828
|
+
|
|
829
|
+
// Verify file is removed from R2
|
|
830
|
+
const stored = await r2.get(fileKey)
|
|
831
|
+
expect(stored).toBeNull()
|
|
832
|
+
})
|
|
833
|
+
|
|
834
|
+
it('should handle URL-encoded file keys in delete', async () => {
|
|
835
|
+
const account = await createAccount({ name: 'Storage Encoded Delete Test' })
|
|
836
|
+
const { headers } = await createUserWithRole(account.id, 'EDITOR')
|
|
837
|
+
const r2 = getR2()
|
|
838
|
+
|
|
839
|
+
// First, create a file with nested path
|
|
840
|
+
const fileKey = `folder/subfolder/delete-test-${Date.now()}.txt`
|
|
841
|
+
await r2.put(fileKey, 'nested file content')
|
|
842
|
+
|
|
843
|
+
const res = await app.request(`/api/storage/${encodeURIComponent(fileKey)}`, {
|
|
844
|
+
method: 'DELETE',
|
|
845
|
+
headers: {
|
|
846
|
+
...headers,
|
|
847
|
+
'User-Agent': 'IntegrationTest/1.0',
|
|
848
|
+
'account-id': account.id,
|
|
849
|
+
},
|
|
850
|
+
})
|
|
851
|
+
|
|
852
|
+
expect(res.status).toBe(204)
|
|
853
|
+
|
|
854
|
+
// Verify file is removed from R2
|
|
855
|
+
const stored = await r2.get(fileKey)
|
|
856
|
+
expect(stored).toBeNull()
|
|
857
|
+
})
|
|
858
|
+
})
|
|
859
|
+
})
|
|
860
|
+
|
|
861
|
+
// ============================================================================
|
|
862
|
+
// END-TO-END WORKFLOW TESTS
|
|
863
|
+
// ============================================================================
|
|
864
|
+
|
|
865
|
+
describe('End-to-end workflow', () => {
|
|
866
|
+
it('should complete full upload workflow: generate URL -> upload -> verify', async () => {
|
|
867
|
+
const account = await createAccount({ name: 'Storage E2E Test' })
|
|
868
|
+
const { headers } = await createUserWithRole(account.id, 'AUTHOR')
|
|
869
|
+
const r2 = getR2()
|
|
870
|
+
|
|
871
|
+
// Step 1: Generate upload URL
|
|
872
|
+
const urlRes = await app.request('/api/storage/upload-url', {
|
|
873
|
+
method: 'POST',
|
|
874
|
+
headers: {
|
|
875
|
+
...headers,
|
|
876
|
+
'User-Agent': 'IntegrationTest/1.0',
|
|
877
|
+
'account-id': account.id,
|
|
878
|
+
'Content-Type': 'application/json',
|
|
879
|
+
},
|
|
880
|
+
body: JSON.stringify({
|
|
881
|
+
filename: 'e2e-test.txt',
|
|
882
|
+
contentType: 'text/plain',
|
|
883
|
+
}),
|
|
884
|
+
})
|
|
885
|
+
|
|
886
|
+
expect(urlRes.status).toBe(200)
|
|
887
|
+
const urlBody = await urlRes.json()
|
|
888
|
+
|
|
889
|
+
// Step 2: Upload file using the generated URL
|
|
890
|
+
const fileContent = 'End-to-end test content'
|
|
891
|
+
const uploadRes = await app.request(urlBody.url, {
|
|
892
|
+
method: 'PUT',
|
|
893
|
+
headers: {
|
|
894
|
+
...headers,
|
|
895
|
+
'User-Agent': 'IntegrationTest/1.0',
|
|
896
|
+
'account-id': account.id,
|
|
897
|
+
'Content-Type': 'text/plain',
|
|
898
|
+
},
|
|
899
|
+
body: fileContent,
|
|
900
|
+
})
|
|
901
|
+
|
|
902
|
+
expect(uploadRes.status).toBe(200)
|
|
903
|
+
const uploadBody = await uploadRes.json()
|
|
904
|
+
expect(uploadBody.success).toBe(true)
|
|
905
|
+
expect(uploadBody.key).toBe(urlBody.name)
|
|
906
|
+
|
|
907
|
+
// Step 3: Verify file is stored
|
|
908
|
+
const stored = await r2.get(urlBody.name)
|
|
909
|
+
expect(stored).not.toBeNull()
|
|
910
|
+
if (stored) {
|
|
911
|
+
const storedContent = await stored.text()
|
|
912
|
+
expect(storedContent).toBe(fileContent)
|
|
913
|
+
}
|
|
914
|
+
})
|
|
915
|
+
|
|
916
|
+
it('should complete full lifecycle: upload -> verify -> delete -> verify deleted', async () => {
|
|
917
|
+
const account = await createAccount({ name: 'Storage Lifecycle Test' })
|
|
918
|
+
const { headers } = await createUserWithRole(account.id, 'EDITOR') // EDITOR can both upload and delete
|
|
919
|
+
const r2 = getR2()
|
|
920
|
+
|
|
921
|
+
const fileKey = `lifecycle-test-${Date.now()}.txt`
|
|
922
|
+
const fileContent = 'Lifecycle test content'
|
|
923
|
+
|
|
924
|
+
// Step 1: Upload file
|
|
925
|
+
const uploadRes = await app.request(`/api/storage/upload/${encodeURIComponent(fileKey)}`, {
|
|
926
|
+
method: 'PUT',
|
|
927
|
+
headers: {
|
|
928
|
+
...headers,
|
|
929
|
+
'User-Agent': 'IntegrationTest/1.0',
|
|
930
|
+
'account-id': account.id,
|
|
931
|
+
'Content-Type': 'text/plain',
|
|
932
|
+
},
|
|
933
|
+
body: fileContent,
|
|
934
|
+
})
|
|
935
|
+
|
|
936
|
+
expect(uploadRes.status).toBe(200)
|
|
937
|
+
|
|
938
|
+
// Step 2: Verify file exists
|
|
939
|
+
let stored = await r2.get(fileKey)
|
|
940
|
+
expect(stored).not.toBeNull()
|
|
941
|
+
|
|
942
|
+
// Step 3: Delete file
|
|
943
|
+
const deleteRes = await app.request(`/api/storage/${encodeURIComponent(fileKey)}`, {
|
|
944
|
+
method: 'DELETE',
|
|
945
|
+
headers: {
|
|
946
|
+
...headers,
|
|
947
|
+
'User-Agent': 'IntegrationTest/1.0',
|
|
948
|
+
'account-id': account.id,
|
|
949
|
+
},
|
|
950
|
+
})
|
|
951
|
+
|
|
952
|
+
expect(deleteRes.status).toBe(204)
|
|
953
|
+
|
|
954
|
+
// Step 4: Verify file is deleted
|
|
955
|
+
stored = await r2.get(fileKey)
|
|
956
|
+
expect(stored).toBeNull()
|
|
957
|
+
})
|
|
958
|
+
})
|
|
959
|
+
|
|
960
|
+
// ============================================================================
|
|
961
|
+
// ROLE PERMISSION MATRIX TESTS
|
|
962
|
+
// ============================================================================
|
|
963
|
+
|
|
964
|
+
describe('Role permission matrix for storage', () => {
|
|
965
|
+
const storagePermissionTests: {
|
|
966
|
+
role: Role
|
|
967
|
+
operation: string
|
|
968
|
+
endpoint: string
|
|
969
|
+
method: 'POST' | 'PUT' | 'DELETE'
|
|
970
|
+
shouldSucceed: boolean
|
|
971
|
+
body?: string | Record<string, unknown>
|
|
972
|
+
contentType?: string
|
|
973
|
+
}[] = [
|
|
974
|
+
// ADMIN - full access
|
|
975
|
+
{ role: 'ADMIN', operation: 'Generate upload URL', endpoint: '/api/storage/upload-url', method: 'POST', shouldSucceed: true, body: { filename: 'test.txt', contentType: 'text/plain' }, contentType: 'application/json' },
|
|
976
|
+
|
|
977
|
+
// MANAGER - full access
|
|
978
|
+
{ role: 'MANAGER', operation: 'Generate upload URL', endpoint: '/api/storage/upload-url', method: 'POST', shouldSucceed: true, body: { filename: 'test.txt', contentType: 'text/plain' }, contentType: 'application/json' },
|
|
979
|
+
|
|
980
|
+
// EDITOR - full access
|
|
981
|
+
{ role: 'EDITOR', operation: 'Generate upload URL', endpoint: '/api/storage/upload-url', method: 'POST', shouldSucceed: true, body: { filename: 'test.txt', contentType: 'text/plain' }, contentType: 'application/json' },
|
|
982
|
+
|
|
983
|
+
// AUTHOR - can upload, cannot delete
|
|
984
|
+
{ role: 'AUTHOR', operation: 'Generate upload URL', endpoint: '/api/storage/upload-url', method: 'POST', shouldSucceed: true, body: { filename: 'test.txt', contentType: 'text/plain' }, contentType: 'application/json' },
|
|
985
|
+
|
|
986
|
+
// VIEWER - no storage access
|
|
987
|
+
{ role: 'VIEWER', operation: 'Generate upload URL', endpoint: '/api/storage/upload-url', method: 'POST', shouldSucceed: false, body: { filename: 'test.txt', contentType: 'text/plain' }, contentType: 'application/json' },
|
|
988
|
+
|
|
989
|
+
// BILLING - no storage access
|
|
990
|
+
{ role: 'BILLING', operation: 'Generate upload URL', endpoint: '/api/storage/upload-url', method: 'POST', shouldSucceed: false, body: { filename: 'test.txt', contentType: 'text/plain' }, contentType: 'application/json' },
|
|
991
|
+
|
|
992
|
+
// ANALYTICS - no storage access
|
|
993
|
+
{ role: 'ANALYTICS', operation: 'Generate upload URL', endpoint: '/api/storage/upload-url', method: 'POST', shouldSucceed: false, body: { filename: 'test.txt', contentType: 'text/plain' }, contentType: 'application/json' },
|
|
994
|
+
]
|
|
995
|
+
|
|
996
|
+
for (const testCase of storagePermissionTests) {
|
|
997
|
+
it(`${testCase.role} ${testCase.shouldSucceed ? 'CAN' : 'CANNOT'} ${testCase.operation}`, async () => {
|
|
998
|
+
const account = await createAccount({ name: `Storage Matrix ${testCase.role} ${testCase.operation}` })
|
|
999
|
+
const { headers } = await createUserWithRole(account.id, testCase.role)
|
|
1000
|
+
|
|
1001
|
+
const requestInit: RequestInit = {
|
|
1002
|
+
method: testCase.method,
|
|
1003
|
+
headers: {
|
|
1004
|
+
...headers,
|
|
1005
|
+
'User-Agent': 'IntegrationTest/1.0',
|
|
1006
|
+
'account-id': account.id,
|
|
1007
|
+
},
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
if (testCase.body) {
|
|
1011
|
+
requestInit.headers = {
|
|
1012
|
+
...requestInit.headers,
|
|
1013
|
+
'Content-Type': testCase.contentType || 'application/json',
|
|
1014
|
+
}
|
|
1015
|
+
requestInit.body = typeof testCase.body === 'string' ? testCase.body : JSON.stringify(testCase.body)
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
const res = await app.request(testCase.endpoint, requestInit)
|
|
1019
|
+
|
|
1020
|
+
if (testCase.shouldSucceed) {
|
|
1021
|
+
expect(res.status).toBe(200)
|
|
1022
|
+
} else {
|
|
1023
|
+
expect(res.status).toBe(403)
|
|
1024
|
+
}
|
|
1025
|
+
})
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
// Delete permission tests (need to create files first)
|
|
1029
|
+
const deletePermissionTests: {
|
|
1030
|
+
role: Role
|
|
1031
|
+
shouldSucceed: boolean
|
|
1032
|
+
}[] = [
|
|
1033
|
+
{ role: 'ADMIN', shouldSucceed: true },
|
|
1034
|
+
{ role: 'MANAGER', shouldSucceed: true },
|
|
1035
|
+
{ role: 'EDITOR', shouldSucceed: true },
|
|
1036
|
+
{ role: 'AUTHOR', shouldSucceed: false },
|
|
1037
|
+
{ role: 'VIEWER', shouldSucceed: false },
|
|
1038
|
+
{ role: 'BILLING', shouldSucceed: false },
|
|
1039
|
+
{ role: 'ANALYTICS', shouldSucceed: false },
|
|
1040
|
+
]
|
|
1041
|
+
|
|
1042
|
+
for (const testCase of deletePermissionTests) {
|
|
1043
|
+
it(`${testCase.role} ${testCase.shouldSucceed ? 'CAN' : 'CANNOT'} delete files`, async () => {
|
|
1044
|
+
const account = await createAccount({ name: `Storage Delete Matrix ${testCase.role}` })
|
|
1045
|
+
const { headers } = await createUserWithRole(account.id, testCase.role)
|
|
1046
|
+
const r2 = getR2()
|
|
1047
|
+
|
|
1048
|
+
// Create a file to delete
|
|
1049
|
+
const fileKey = `delete-matrix-${testCase.role}-${Date.now()}.txt`
|
|
1050
|
+
await r2.put(fileKey, 'test content')
|
|
1051
|
+
|
|
1052
|
+
const res = await app.request(`/api/storage/${encodeURIComponent(fileKey)}`, {
|
|
1053
|
+
method: 'DELETE',
|
|
1054
|
+
headers: {
|
|
1055
|
+
...headers,
|
|
1056
|
+
'User-Agent': 'IntegrationTest/1.0',
|
|
1057
|
+
'account-id': account.id,
|
|
1058
|
+
},
|
|
1059
|
+
})
|
|
1060
|
+
|
|
1061
|
+
if (testCase.shouldSucceed) {
|
|
1062
|
+
expect(res.status).toBe(204)
|
|
1063
|
+
// Verify file is deleted
|
|
1064
|
+
const stored = await r2.get(fileKey)
|
|
1065
|
+
expect(stored).toBeNull()
|
|
1066
|
+
} else {
|
|
1067
|
+
expect(res.status).toBe(403)
|
|
1068
|
+
// Verify file still exists
|
|
1069
|
+
const stored = await r2.get(fileKey)
|
|
1070
|
+
expect(stored).not.toBeNull()
|
|
1071
|
+
}
|
|
1072
|
+
})
|
|
1073
|
+
}
|
|
1074
|
+
})
|
|
1075
|
+
|
|
1076
|
+
// ============================================================================
|
|
1077
|
+
// CONTENT TYPE TESTS
|
|
1078
|
+
// ============================================================================
|
|
1079
|
+
|
|
1080
|
+
describe('Content type handling', () => {
|
|
1081
|
+
it('should handle image upload (image/jpeg)', async () => {
|
|
1082
|
+
const account = await createAccount({ name: 'Storage Image Upload Test' })
|
|
1083
|
+
const { headers } = await createUserWithRole(account.id, 'AUTHOR')
|
|
1084
|
+
const r2 = getR2()
|
|
1085
|
+
|
|
1086
|
+
const fileKey = `image-test-${Date.now()}.jpg`
|
|
1087
|
+
// Create a minimal JPEG-like binary content
|
|
1088
|
+
const binaryContent = new Uint8Array([0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10])
|
|
1089
|
+
|
|
1090
|
+
const res = await app.request(`/api/storage/upload/${encodeURIComponent(fileKey)}`, {
|
|
1091
|
+
method: 'PUT',
|
|
1092
|
+
headers: {
|
|
1093
|
+
...headers,
|
|
1094
|
+
'User-Agent': 'IntegrationTest/1.0',
|
|
1095
|
+
'account-id': account.id,
|
|
1096
|
+
'Content-Type': 'image/jpeg',
|
|
1097
|
+
},
|
|
1098
|
+
body: binaryContent,
|
|
1099
|
+
})
|
|
1100
|
+
|
|
1101
|
+
expect(res.status).toBe(200)
|
|
1102
|
+
|
|
1103
|
+
const stored = await r2.get(fileKey)
|
|
1104
|
+
expect(stored).not.toBeNull()
|
|
1105
|
+
})
|
|
1106
|
+
|
|
1107
|
+
it('should handle JSON upload (application/json)', async () => {
|
|
1108
|
+
const account = await createAccount({ name: 'Storage JSON Upload Test' })
|
|
1109
|
+
const { headers } = await createUserWithRole(account.id, 'AUTHOR')
|
|
1110
|
+
const r2 = getR2()
|
|
1111
|
+
|
|
1112
|
+
const fileKey = `data-test-${Date.now()}.json`
|
|
1113
|
+
const jsonContent = JSON.stringify({ test: 'data', number: 123 })
|
|
1114
|
+
|
|
1115
|
+
const res = await app.request(`/api/storage/upload/${encodeURIComponent(fileKey)}`, {
|
|
1116
|
+
method: 'PUT',
|
|
1117
|
+
headers: {
|
|
1118
|
+
...headers,
|
|
1119
|
+
'User-Agent': 'IntegrationTest/1.0',
|
|
1120
|
+
'account-id': account.id,
|
|
1121
|
+
'Content-Type': 'application/json',
|
|
1122
|
+
},
|
|
1123
|
+
body: jsonContent,
|
|
1124
|
+
})
|
|
1125
|
+
|
|
1126
|
+
expect(res.status).toBe(200)
|
|
1127
|
+
|
|
1128
|
+
const stored = await r2.get(fileKey)
|
|
1129
|
+
expect(stored).not.toBeNull()
|
|
1130
|
+
if (stored) {
|
|
1131
|
+
const storedContent = await stored.text()
|
|
1132
|
+
expect(storedContent).toBe(jsonContent)
|
|
1133
|
+
}
|
|
1134
|
+
})
|
|
1135
|
+
|
|
1136
|
+
it('should handle PDF upload (application/pdf)', async () => {
|
|
1137
|
+
const account = await createAccount({ name: 'Storage PDF Upload Test' })
|
|
1138
|
+
const { headers } = await createUserWithRole(account.id, 'AUTHOR')
|
|
1139
|
+
const r2 = getR2()
|
|
1140
|
+
|
|
1141
|
+
const fileKey = `document-test-${Date.now()}.pdf`
|
|
1142
|
+
// Create minimal PDF-like binary content
|
|
1143
|
+
const pdfContent = new TextEncoder().encode('%PDF-1.4 mock content')
|
|
1144
|
+
|
|
1145
|
+
const res = await app.request(`/api/storage/upload/${encodeURIComponent(fileKey)}`, {
|
|
1146
|
+
method: 'PUT',
|
|
1147
|
+
headers: {
|
|
1148
|
+
...headers,
|
|
1149
|
+
'User-Agent': 'IntegrationTest/1.0',
|
|
1150
|
+
'account-id': account.id,
|
|
1151
|
+
'Content-Type': 'application/pdf',
|
|
1152
|
+
},
|
|
1153
|
+
body: pdfContent,
|
|
1154
|
+
})
|
|
1155
|
+
|
|
1156
|
+
expect(res.status).toBe(200)
|
|
1157
|
+
|
|
1158
|
+
const stored = await r2.get(fileKey)
|
|
1159
|
+
expect(stored).not.toBeNull()
|
|
1160
|
+
})
|
|
1161
|
+
})
|
|
1162
|
+
})
|