create-huenei-template 0.2.7 → 0.2.9
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/config/templates.js +14 -0
- package/dist/core/file-operations.js +15 -0
- package/dist/core/prompts.js +77 -135
- package/dist/index.js +55 -11
- package/dist/templates/README.md +7 -1
- package/dist/templates/backend/README.md +19 -9
- package/dist/templates/backend/nestjs-api-mysql/.cursor/agents/nestjs-code-reviewer.md +54 -0
- package/dist/templates/backend/nestjs-api-mysql/.cursor/agents/prisma-guardian.md +67 -0
- package/dist/templates/backend/nestjs-api-mysql/.cursor/agents/test-runner.md +57 -0
- package/dist/templates/backend/nestjs-api-mysql/.cursor/hooks/autoTestOnStop.ts +127 -0
- package/dist/templates/backend/nestjs-api-mysql/.cursor/hooks/blockDangerous.ts +98 -0
- package/dist/templates/backend/nestjs-api-mysql/.cursor/hooks/ensureTestsExist.ts +405 -0
- package/dist/templates/backend/nestjs-api-mysql/.cursor/hooks/formatOnEdit.ts +70 -0
- package/dist/templates/backend/nestjs-api-mysql/.cursor/hooks/protectSecrets.ts +101 -0
- package/dist/templates/backend/nestjs-api-mysql/.cursor/hooks/sessionInit.ts +104 -0
- package/dist/templates/backend/nestjs-api-mysql/.cursor/hooks/validatePrisma.ts +121 -0
- package/dist/templates/backend/nestjs-api-mysql/.cursor/hooks.json +46 -0
- package/dist/templates/backend/nestjs-api-mysql/README.md +26 -0
- package/dist/templates/backend/nestjs-api-mysql/eslint.config.mjs +1 -1
- package/dist/templates/backend/nestjs-api-mysql/package.json +7 -7
- package/dist/templates/backend/nestjs-api-postgres/.cursor/agents/nestjs-code-reviewer.md +54 -0
- package/dist/templates/backend/nestjs-api-postgres/.cursor/agents/prisma-guardian.md +62 -0
- package/dist/templates/backend/nestjs-api-postgres/.cursor/agents/security-auditor.md +71 -0
- package/dist/templates/backend/nestjs-api-postgres/.cursor/agents/test-runner.md +58 -0
- package/dist/templates/backend/nestjs-api-postgres/.cursor/hooks/auto-retry.ts +62 -0
- package/dist/templates/backend/nestjs-api-postgres/.cursor/hooks/block-dangerous.ts +202 -0
- package/dist/templates/backend/nestjs-api-postgres/.cursor/hooks/format-and-validate.ts +124 -0
- package/dist/templates/backend/nestjs-api-postgres/.cursor/hooks/protect-secrets.ts +105 -0
- package/dist/templates/backend/nestjs-api-postgres/.cursor/hooks/session-context.ts +130 -0
- package/dist/templates/backend/nestjs-api-postgres/.cursor/hooks.json +36 -0
- package/dist/templates/backend/nestjs-api-postgres/eslint.config.mjs +1 -1
- package/dist/templates/backend/nestjs-api-postgres/package.json +6 -6
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/agents/code-reviewer.md +153 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/agents/nestjs-architect.md +138 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/agents/prisma-analyst.md +164 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/agents/security-auditor.md +150 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/agents/test-engineer.md +290 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/hooks/auto-format.ts +80 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/hooks/block-dangerous-commands.ts +144 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/hooks/prisma-schema-watcher.ts +64 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/hooks/protect-sensitive-files.ts +122 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/hooks/session-context.ts +105 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/hooks.json +18 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/skills/conventional-commits/SKILL.md +318 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/skills/docker/SKILL.md +82 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/skills/jest/SKILL.md +72 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/skills/logging-best-practices/SKILL.md +127 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/skills/prisma-database-setup/SKILL.md +186 -0
- package/dist/templates/backend/nestjs-api-sqlite/.cursor/skills/quality-gates-enforcer/SKILL.md +301 -0
- package/dist/templates/backend/nestjs-api-sqlite/README.md +34 -1
- package/dist/templates/backend/nestjs-api-sqlite/eslint.config.mjs +1 -1
- package/dist/templates/backend/nestjs-api-sqlite/package.json +6 -6
- package/dist/templates/backend/nestjs-api-sqlite/prisma/schema.prisma +1 -0
- package/dist/templates/backend/nestjs-api-sqlite/prisma/seed.ts +2 -2
- package/dist/templates/backend/nestjs-api-sqlite/src/posts/dto/post-response.dto.ts +5 -1
- package/dist/templates/backend/nestjs-api-sqlite/src/users/dto/profile-response.dto.ts +1 -1
- package/dist/templates/backend/nestjs-api-sqlite/src/users/dto/update-profile.dto.ts +1 -1
- package/dist/templates/backend/nestjs-api-sqlite/src/users/dto/user-response.dto.ts +4 -0
- package/dist/templates/backend/nestjs-api-sqlite/src/users/profile.service.ts +24 -8
- package/dist/templates/backend/nestjs-api-sqlite/src/users/users.service.ts +1 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/agents/nestjs-code-reviewer.md +54 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/agents/prisma-guardian.md +67 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/agents/test-runner.md +57 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/commands/new-endpoint.md +209 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/commands/new-model.md +201 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/hooks/autoTestOnStop.ts +127 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/hooks/blockDangerous.ts +98 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/hooks/ensureTestsExist.ts +405 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/hooks/formatOnEdit.ts +70 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/hooks/protectSecrets.ts +101 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/hooks/sessionInit.ts +104 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/hooks/validatePrisma.ts +121 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/hooks.json +46 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/rules/api-rest.mdc +126 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/rules/authentication-security.mdc +86 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/rules/dto-validation.mdc +93 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/rules/general-rules.mdc +126 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/rules/nestjs-architecture.mdc +83 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/rules/prisma-standards.mdc +111 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/rules/swagger-documentation.mdc +90 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/skills/api-security-best-practices/SKILL.md +907 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/skills/docker-expert/SKILL.md +409 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/skills/nestjs-expert/SKILL.md +552 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/skills/nestjs-the-best-practices/AGENTS.md +5958 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/skills/nestjs-the-best-practices/SKILL.md +130 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/skills/nodejs-best-practices/SKILL.md +333 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/skills/prisma-expert/SKILL.md +355 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.cursor/skills/sqlserver-table-design/SKILL.md +125 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.dockerignore +50 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.env.example +17 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.env.test +17 -0
- package/dist/templates/backend/nestjs-api-sqlserver/.prettierrc +4 -0
- package/dist/templates/backend/nestjs-api-sqlserver/README.md +587 -0
- package/dist/templates/backend/nestjs-api-sqlserver/docker-compose.yml +24 -0
- package/dist/templates/backend/nestjs-api-sqlserver/eslint.config.mjs +41 -0
- package/dist/templates/backend/nestjs-api-sqlserver/nest-cli.json +8 -0
- package/dist/templates/backend/nestjs-api-sqlserver/package.json +107 -0
- package/dist/templates/backend/nestjs-api-sqlserver/prisma/schema.prisma +70 -0
- package/dist/templates/backend/nestjs-api-sqlserver/prisma/seed.ts +215 -0
- package/dist/templates/backend/nestjs-api-sqlserver/prisma.config.ts +12 -0
- package/dist/templates/backend/nestjs-api-sqlserver/scripts/check-docker.js +64 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/app.module.ts +39 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/app.service.ts +8 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/auth/auth.controller.ts +36 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/auth/auth.module.ts +22 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/auth/auth.service.ts +64 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/auth/decorators/roles.decorator.ts +5 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/auth/dto/login-response.dto.ts +23 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/auth/dto/login.dto.ts +27 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/auth/enums/role.enum.ts +5 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/auth/guards/jwt-auth.guard.ts +20 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/auth/guards/roles.guard.ts +23 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/auth/strategies/jwt.strategy.ts +32 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/auth/types.ts +18 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/common/dto/paginated-response.dto.ts +16 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/common/dto/pagination.dto.ts +31 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/common/filters/http-exception.filter.ts +53 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/config/env.validation.ts +41 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/health/health.controller.ts +35 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/health/health.module.ts +7 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/main.ts +87 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/posts/dto/create-post.dto.ts +32 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/posts/dto/post-response.dto.ts +41 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/posts/dto/update-post.dto.ts +31 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/posts/posts.controller.ts +161 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/posts/posts.module.ts +12 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/posts/posts.service.ts +171 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/prisma/prisma.module.ts +9 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/prisma/prisma.service.ts +62 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/users/constants/settings.constants.ts +9 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/users/dto/profile-response.dto.ts +39 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/users/dto/settings-response.dto.ts +18 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/users/dto/update-profile.dto.ts +48 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/users/dto/update-settings.dto.ts +40 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/users/dto/user-response.dto.ts +18 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/users/profile.service.ts +67 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/users/settings.service.ts +77 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/users/users.controller.ts +102 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/users/users.module.ts +14 -0
- package/dist/templates/backend/nestjs-api-sqlserver/src/users/users.service.ts +27 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/README.md +412 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/e2e/auth.e2e-spec.ts +147 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/e2e/health.e2e-spec.ts +62 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/e2e/posts.e2e-spec.ts +407 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/e2e/users.e2e-spec.ts +287 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/fixtures/test-data.ts +109 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/helpers/auth.helper.ts +54 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/helpers/db.helper.ts +68 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/jest-e2e.json +12 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/setup-e2e.ts +8 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/app.service.spec.ts +24 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/auth.controller.spec.ts +91 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/auth.service.spec.ts +161 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/health.controller.spec.ts +78 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/http-exception.filter.spec.ts +150 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/jwt-auth.guard.spec.ts +50 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/jwt.strategy.spec.ts +41 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/posts.controller.spec.ts +249 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/posts.service.spec.ts +328 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/profile.service.spec.ts +146 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/settings.service.spec.ts +242 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/users.controller.spec.ts +178 -0
- package/dist/templates/backend/nestjs-api-sqlserver/test/unit/users.service.spec.ts +96 -0
- package/dist/templates/backend/nestjs-api-sqlserver/tsconfig.build.json +4 -0
- package/dist/templates/backend/nestjs-api-sqlserver/tsconfig.json +28 -0
- package/dist/templates/cursor/.cursor/commands/configurar-cursor.md +763 -0
- package/dist/templates/cursor/.cursor/skills/create-huenei-subagent/SKILL.md +223 -0
- package/dist/templates/cursor/.cursor/skills/create-huenei-subagent/examples.md +236 -0
- package/dist/templates/cursor/.cursor/skills/cursor-hooks/SKILL.md +1100 -0
- package/dist/templates/cursor/.cursor/skills/find-skills/SKILL.md +133 -0
- package/dist/templates/frontend/angular-base/.cursor/agents/accessibility-reviewer.md +67 -0
- package/dist/templates/frontend/angular-base/.cursor/agents/angular-code-reviewer.md +60 -0
- package/dist/templates/frontend/angular-base/.cursor/agents/qa-test-expert.md +70 -0
- package/dist/templates/frontend/angular-base/.cursor/agents/security-auditor.md +58 -0
- package/dist/templates/frontend/angular-base/.cursor/hooks/auto-format.ts +70 -0
- package/dist/templates/frontend/angular-base/.cursor/hooks/auto-test-on-stop.ts +113 -0
- package/dist/templates/frontend/angular-base/.cursor/hooks/block-dangerous-commands.ts +160 -0
- package/dist/templates/frontend/angular-base/.cursor/hooks/ensure-tests-exist.ts +363 -0
- package/dist/templates/frontend/angular-base/.cursor/hooks/protect-sensitive-files.ts +118 -0
- package/dist/templates/frontend/angular-base/.cursor/hooks/session-context.ts +110 -0
- package/dist/templates/frontend/angular-base/.cursor/hooks.json +41 -0
- package/dist/templates/frontend/angular-nx/.cursor/agents/angular-code-reviewer.md +64 -0
- package/dist/templates/frontend/angular-nx/.cursor/agents/nx-architecture-guardian.md +69 -0
- package/dist/templates/frontend/angular-nx/.cursor/agents/qa-test-expert.md +75 -0
- package/dist/templates/frontend/angular-nx/.cursor/agents/security-auditor.md +61 -0
- package/dist/templates/frontend/angular-nx/.cursor/hooks/auto-format.ts +70 -0
- package/dist/templates/frontend/angular-nx/.cursor/hooks/auto-test-on-stop.ts +115 -0
- package/dist/templates/frontend/angular-nx/.cursor/hooks/block-dangerous-commands.ts +188 -0
- package/dist/templates/frontend/angular-nx/.cursor/hooks/ensure-tests-exist.ts +399 -0
- package/dist/templates/frontend/angular-nx/.cursor/hooks/protect-sensitive-files.ts +128 -0
- package/dist/templates/frontend/angular-nx/.cursor/hooks/session-context.ts +121 -0
- package/dist/templates/frontend/angular-nx/.cursor/hooks.json +41 -0
- package/dist/templates/frontend/react-vite/.cursor/agents/frontend-senior.agent.md +49 -49
- package/dist/templates/frontend/react-vite/.cursor/agents/qa-test-expert.agent.md +126 -49
- package/dist/templates/frontend/react-vite/.cursor/agents/security-expert.agent.md +39 -39
- package/dist/templates/frontend/react-vite/.cursor/agents/ux-ui-expert.agent.md +45 -45
- package/dist/templates/frontend/react-vite/.cursor/hooks/autoTestOnStop.ts +117 -0
- package/dist/templates/frontend/react-vite/.cursor/hooks/blockDangerous.ts +75 -0
- package/dist/templates/frontend/react-vite/.cursor/hooks/ensureTestsExist.ts +306 -220
- package/dist/templates/frontend/react-vite/.cursor/hooks/formatOnEdit.ts +49 -0
- package/dist/templates/frontend/react-vite/.cursor/hooks/protectSecrets.ts +88 -0
- package/dist/templates/frontend/react-vite/.cursor/hooks/sessionInit.ts +77 -0
- package/dist/templates/frontend/react-vite/.cursor/hooks.json +41 -10
- package/dist/templates/frontend/react-vite/.cursor/settings.json +13 -13
- package/dist/templates/frontend/react-vite/.vscode/settings.json +31 -31
- package/dist/templates/frontend/react-vite/README.md +34 -34
- package/dist/templates/frontend/react-vite/package.json +82 -82
- package/dist/templates/frontend/react-vite/pnpm-lock.yaml +6575 -6575
- package/dist/templates/frontend/react-vite/src/__tests__/components/layout/navbar.test.tsx +63 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/avatar.test.tsx +74 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/badge.test.tsx +55 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/breadcrumb.test.tsx +140 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/button.test.tsx +121 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/card.test.tsx +144 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/dialog.test.tsx +121 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/form.test.tsx +165 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/input.test.tsx +52 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/label.test.tsx +40 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/password-input.test.tsx +59 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/separator.test.tsx +40 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/table.test.tsx +254 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/tabs.test.tsx +82 -0
- package/dist/templates/frontend/react-vite/src/__tests__/components/ui/textarea.test.tsx +47 -0
- package/dist/templates/frontend/react-vite/src/__tests__/helpers/render.tsx +114 -0
- package/dist/templates/frontend/react-vite/src/__tests__/hooks/useLocalStorage.test.ts +95 -0
- package/dist/templates/frontend/react-vite/src/__tests__/lib/queryClient.test.ts +24 -0
- package/dist/templates/frontend/react-vite/src/__tests__/lib/utils.test.ts +43 -0
- package/dist/templates/frontend/react-vite/src/__tests__/routes/index.test.tsx +111 -0
- package/dist/templates/frontend/react-vite/src/__tests__/routes/otra-ruta.test.tsx +126 -0
- package/dist/templates/frontend/react-vite/src/__tests__/routes/root.test.tsx +78 -0
- package/dist/templates/frontend/react-vite/src/__tests__/routes/ui-components.test.tsx +286 -0
- package/dist/templates/frontend/react-vite/src/components/layout/navbar.tsx +38 -38
- package/dist/templates/frontend/react-vite/src/components/ui/avatar.tsx +42 -42
- package/dist/templates/frontend/react-vite/src/components/ui/dialog.tsx +122 -122
- package/dist/templates/frontend/react-vite/src/components/ui/table.tsx +229 -244
- package/dist/templates/frontend/react-vite/src/hooks/useLocalStorage.ts +32 -32
- package/dist/templates/frontend/react-vite/src/routes/__root.tsx +48 -48
- package/dist/templates/frontend/react-vite/src/routes/ui-components.tsx +359 -85
- package/dist/templates/frontend/react-vite/src/test/setup.ts +24 -24
- package/dist/templates/frontend/react-vite/vite.config.ts +2 -2
- package/dist/templates/frontend/react-vite/vitest.config.ts +13 -2
- package/dist/templates/frontend/react-vite-help/.cursor/RECONSTRUCTION-PROMPT.md +738 -0
- package/package.json +1 -1
- package/templates/README.md +7 -1
- package/templates/backend/README.md +19 -9
- package/templates/backend/nestjs-api-mysql/.cursor/agents/nestjs-code-reviewer.md +54 -0
- package/templates/backend/nestjs-api-mysql/.cursor/agents/prisma-guardian.md +67 -0
- package/templates/backend/nestjs-api-mysql/.cursor/agents/test-runner.md +57 -0
- package/templates/backend/nestjs-api-mysql/.cursor/hooks/autoTestOnStop.ts +127 -0
- package/templates/backend/nestjs-api-mysql/.cursor/hooks/blockDangerous.ts +98 -0
- package/templates/backend/nestjs-api-mysql/.cursor/hooks/ensureTestsExist.ts +405 -0
- package/templates/backend/nestjs-api-mysql/.cursor/hooks/formatOnEdit.ts +70 -0
- package/templates/backend/nestjs-api-mysql/.cursor/hooks/protectSecrets.ts +101 -0
- package/templates/backend/nestjs-api-mysql/.cursor/hooks/sessionInit.ts +104 -0
- package/templates/backend/nestjs-api-mysql/.cursor/hooks/validatePrisma.ts +121 -0
- package/templates/backend/nestjs-api-mysql/.cursor/hooks.json +46 -0
- package/templates/backend/nestjs-api-mysql/README.md +26 -0
- package/templates/backend/nestjs-api-mysql/dist/tsconfig.build.tsbuildinfo +1 -1
- package/templates/backend/nestjs-api-mysql/eslint.config.mjs +1 -1
- package/templates/backend/nestjs-api-mysql/package.json +7 -7
- package/templates/backend/nestjs-api-postgres/.cursor/agents/nestjs-code-reviewer.md +54 -0
- package/templates/backend/nestjs-api-postgres/.cursor/agents/prisma-guardian.md +62 -0
- package/templates/backend/nestjs-api-postgres/.cursor/agents/security-auditor.md +71 -0
- package/templates/backend/nestjs-api-postgres/.cursor/agents/test-runner.md +58 -0
- package/templates/backend/nestjs-api-postgres/.cursor/hooks/auto-retry.ts +62 -0
- package/templates/backend/nestjs-api-postgres/.cursor/hooks/block-dangerous.ts +202 -0
- package/templates/backend/nestjs-api-postgres/.cursor/hooks/format-and-validate.ts +124 -0
- package/templates/backend/nestjs-api-postgres/.cursor/hooks/protect-secrets.ts +105 -0
- package/templates/backend/nestjs-api-postgres/.cursor/hooks/session-context.ts +130 -0
- package/templates/backend/nestjs-api-postgres/.cursor/hooks.json +36 -0
- package/templates/backend/nestjs-api-postgres/eslint.config.mjs +1 -1
- package/templates/backend/nestjs-api-postgres/package.json +6 -6
- package/templates/backend/nestjs-api-sqlite/.cursor/agents/code-reviewer.md +153 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/agents/nestjs-architect.md +138 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/agents/prisma-analyst.md +164 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/agents/security-auditor.md +150 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/agents/test-engineer.md +290 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/hooks/auto-format.ts +80 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/hooks/block-dangerous-commands.ts +144 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/hooks/prisma-schema-watcher.ts +64 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/hooks/protect-sensitive-files.ts +122 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/hooks/session-context.ts +105 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/hooks.json +18 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/skills/conventional-commits/SKILL.md +318 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/skills/docker/SKILL.md +82 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/skills/jest/SKILL.md +72 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/skills/logging-best-practices/SKILL.md +127 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/skills/prisma-database-setup/SKILL.md +186 -0
- package/templates/backend/nestjs-api-sqlite/.cursor/skills/quality-gates-enforcer/SKILL.md +301 -0
- package/templates/backend/nestjs-api-sqlite/README.md +34 -1
- package/templates/backend/nestjs-api-sqlite/eslint.config.mjs +1 -1
- package/templates/backend/nestjs-api-sqlite/package.json +6 -6
- package/templates/backend/nestjs-api-sqlite/prisma/schema.prisma +1 -0
- package/templates/backend/nestjs-api-sqlite/prisma/seed.ts +2 -2
- package/templates/backend/nestjs-api-sqlite/src/posts/dto/post-response.dto.ts +5 -1
- package/templates/backend/nestjs-api-sqlite/src/users/dto/profile-response.dto.ts +1 -1
- package/templates/backend/nestjs-api-sqlite/src/users/dto/update-profile.dto.ts +1 -1
- package/templates/backend/nestjs-api-sqlite/src/users/dto/user-response.dto.ts +4 -0
- package/templates/backend/nestjs-api-sqlite/src/users/profile.service.ts +24 -8
- package/templates/backend/nestjs-api-sqlite/src/users/users.service.ts +1 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/agents/nestjs-code-reviewer.md +54 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/agents/prisma-guardian.md +67 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/agents/test-runner.md +57 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/commands/new-endpoint.md +209 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/commands/new-model.md +201 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/hooks/autoTestOnStop.ts +127 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/hooks/blockDangerous.ts +98 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/hooks/ensureTestsExist.ts +405 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/hooks/formatOnEdit.ts +70 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/hooks/protectSecrets.ts +101 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/hooks/sessionInit.ts +104 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/hooks/validatePrisma.ts +121 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/hooks.json +46 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/rules/api-rest.mdc +126 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/rules/authentication-security.mdc +86 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/rules/dto-validation.mdc +93 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/rules/general-rules.mdc +126 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/rules/nestjs-architecture.mdc +83 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/rules/prisma-standards.mdc +111 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/rules/swagger-documentation.mdc +90 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/skills/api-security-best-practices/SKILL.md +907 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/skills/docker-expert/SKILL.md +409 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/skills/nestjs-expert/SKILL.md +552 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/skills/nestjs-the-best-practices/AGENTS.md +5958 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/skills/nestjs-the-best-practices/SKILL.md +130 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/skills/nodejs-best-practices/SKILL.md +333 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/skills/prisma-expert/SKILL.md +355 -0
- package/templates/backend/nestjs-api-sqlserver/.cursor/skills/sqlserver-table-design/SKILL.md +125 -0
- package/templates/backend/nestjs-api-sqlserver/.dockerignore +50 -0
- package/templates/backend/nestjs-api-sqlserver/.env.example +17 -0
- package/templates/backend/nestjs-api-sqlserver/.env.test +17 -0
- package/templates/backend/nestjs-api-sqlserver/.prettierrc +4 -0
- package/templates/backend/nestjs-api-sqlserver/README.md +587 -0
- package/templates/backend/nestjs-api-sqlserver/docker-compose.yml +24 -0
- package/templates/backend/nestjs-api-sqlserver/eslint.config.mjs +41 -0
- package/templates/backend/nestjs-api-sqlserver/nest-cli.json +8 -0
- package/templates/backend/nestjs-api-sqlserver/package.json +107 -0
- package/templates/backend/nestjs-api-sqlserver/prisma/schema.prisma +70 -0
- package/templates/backend/nestjs-api-sqlserver/prisma/seed.ts +215 -0
- package/templates/backend/nestjs-api-sqlserver/prisma.config.ts +12 -0
- package/templates/backend/nestjs-api-sqlserver/scripts/check-docker.js +64 -0
- package/templates/backend/nestjs-api-sqlserver/src/app.module.ts +39 -0
- package/templates/backend/nestjs-api-sqlserver/src/app.service.ts +8 -0
- package/templates/backend/nestjs-api-sqlserver/src/auth/auth.controller.ts +36 -0
- package/templates/backend/nestjs-api-sqlserver/src/auth/auth.module.ts +22 -0
- package/templates/backend/nestjs-api-sqlserver/src/auth/auth.service.ts +64 -0
- package/templates/backend/nestjs-api-sqlserver/src/auth/decorators/roles.decorator.ts +5 -0
- package/templates/backend/nestjs-api-sqlserver/src/auth/dto/login-response.dto.ts +23 -0
- package/templates/backend/nestjs-api-sqlserver/src/auth/dto/login.dto.ts +27 -0
- package/templates/backend/nestjs-api-sqlserver/src/auth/enums/role.enum.ts +5 -0
- package/templates/backend/nestjs-api-sqlserver/src/auth/guards/jwt-auth.guard.ts +20 -0
- package/templates/backend/nestjs-api-sqlserver/src/auth/guards/roles.guard.ts +23 -0
- package/templates/backend/nestjs-api-sqlserver/src/auth/strategies/jwt.strategy.ts +32 -0
- package/templates/backend/nestjs-api-sqlserver/src/auth/types.ts +18 -0
- package/templates/backend/nestjs-api-sqlserver/src/common/dto/paginated-response.dto.ts +16 -0
- package/templates/backend/nestjs-api-sqlserver/src/common/dto/pagination.dto.ts +31 -0
- package/templates/backend/nestjs-api-sqlserver/src/common/filters/http-exception.filter.ts +53 -0
- package/templates/backend/nestjs-api-sqlserver/src/config/env.validation.ts +41 -0
- package/templates/backend/nestjs-api-sqlserver/src/health/health.controller.ts +35 -0
- package/templates/backend/nestjs-api-sqlserver/src/health/health.module.ts +7 -0
- package/templates/backend/nestjs-api-sqlserver/src/main.ts +87 -0
- package/templates/backend/nestjs-api-sqlserver/src/posts/dto/create-post.dto.ts +32 -0
- package/templates/backend/nestjs-api-sqlserver/src/posts/dto/post-response.dto.ts +41 -0
- package/templates/backend/nestjs-api-sqlserver/src/posts/dto/update-post.dto.ts +31 -0
- package/templates/backend/nestjs-api-sqlserver/src/posts/posts.controller.ts +161 -0
- package/templates/backend/nestjs-api-sqlserver/src/posts/posts.module.ts +12 -0
- package/templates/backend/nestjs-api-sqlserver/src/posts/posts.service.ts +171 -0
- package/templates/backend/nestjs-api-sqlserver/src/prisma/prisma.module.ts +9 -0
- package/templates/backend/nestjs-api-sqlserver/src/prisma/prisma.service.ts +62 -0
- package/templates/backend/nestjs-api-sqlserver/src/users/constants/settings.constants.ts +9 -0
- package/templates/backend/nestjs-api-sqlserver/src/users/dto/profile-response.dto.ts +39 -0
- package/templates/backend/nestjs-api-sqlserver/src/users/dto/settings-response.dto.ts +18 -0
- package/templates/backend/nestjs-api-sqlserver/src/users/dto/update-profile.dto.ts +48 -0
- package/templates/backend/nestjs-api-sqlserver/src/users/dto/update-settings.dto.ts +40 -0
- package/templates/backend/nestjs-api-sqlserver/src/users/dto/user-response.dto.ts +18 -0
- package/templates/backend/nestjs-api-sqlserver/src/users/profile.service.ts +67 -0
- package/templates/backend/nestjs-api-sqlserver/src/users/settings.service.ts +77 -0
- package/templates/backend/nestjs-api-sqlserver/src/users/users.controller.ts +102 -0
- package/templates/backend/nestjs-api-sqlserver/src/users/users.module.ts +14 -0
- package/templates/backend/nestjs-api-sqlserver/src/users/users.service.ts +27 -0
- package/templates/backend/nestjs-api-sqlserver/test/README.md +412 -0
- package/templates/backend/nestjs-api-sqlserver/test/e2e/auth.e2e-spec.ts +147 -0
- package/templates/backend/nestjs-api-sqlserver/test/e2e/health.e2e-spec.ts +62 -0
- package/templates/backend/nestjs-api-sqlserver/test/e2e/posts.e2e-spec.ts +407 -0
- package/templates/backend/nestjs-api-sqlserver/test/e2e/users.e2e-spec.ts +287 -0
- package/templates/backend/nestjs-api-sqlserver/test/fixtures/test-data.ts +109 -0
- package/templates/backend/nestjs-api-sqlserver/test/helpers/auth.helper.ts +54 -0
- package/templates/backend/nestjs-api-sqlserver/test/helpers/db.helper.ts +68 -0
- package/templates/backend/nestjs-api-sqlserver/test/jest-e2e.json +12 -0
- package/templates/backend/nestjs-api-sqlserver/test/setup-e2e.ts +8 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/app.service.spec.ts +24 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/auth.controller.spec.ts +91 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/auth.service.spec.ts +161 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/health.controller.spec.ts +78 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/http-exception.filter.spec.ts +150 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/jwt-auth.guard.spec.ts +50 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/jwt.strategy.spec.ts +41 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/posts.controller.spec.ts +249 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/posts.service.spec.ts +328 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/profile.service.spec.ts +146 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/settings.service.spec.ts +242 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/users.controller.spec.ts +178 -0
- package/templates/backend/nestjs-api-sqlserver/test/unit/users.service.spec.ts +96 -0
- package/templates/backend/nestjs-api-sqlserver/tsconfig.build.json +4 -0
- package/templates/backend/nestjs-api-sqlserver/tsconfig.json +28 -0
- package/templates/cursor/.cursor/commands/configurar-cursor.md +763 -0
- package/templates/cursor/.cursor/skills/create-huenei-subagent/SKILL.md +223 -0
- package/templates/cursor/.cursor/skills/create-huenei-subagent/examples.md +236 -0
- package/templates/cursor/.cursor/skills/cursor-hooks/SKILL.md +1100 -0
- package/templates/cursor/.cursor/skills/find-skills/SKILL.md +133 -0
- package/templates/frontend/angular-base/.cursor/agents/accessibility-reviewer.md +67 -0
- package/templates/frontend/angular-base/.cursor/agents/angular-code-reviewer.md +60 -0
- package/templates/frontend/angular-base/.cursor/agents/qa-test-expert.md +70 -0
- package/templates/frontend/angular-base/.cursor/agents/security-auditor.md +58 -0
- package/templates/frontend/angular-base/.cursor/hooks/auto-format.ts +70 -0
- package/templates/frontend/angular-base/.cursor/hooks/auto-test-on-stop.ts +113 -0
- package/templates/frontend/angular-base/.cursor/hooks/block-dangerous-commands.ts +160 -0
- package/templates/frontend/angular-base/.cursor/hooks/ensure-tests-exist.ts +363 -0
- package/templates/frontend/angular-base/.cursor/hooks/protect-sensitive-files.ts +118 -0
- package/templates/frontend/angular-base/.cursor/hooks/session-context.ts +110 -0
- package/templates/frontend/angular-base/.cursor/hooks.json +41 -0
- package/templates/frontend/angular-nx/.cursor/agents/angular-code-reviewer.md +64 -0
- package/templates/frontend/angular-nx/.cursor/agents/nx-architecture-guardian.md +69 -0
- package/templates/frontend/angular-nx/.cursor/agents/qa-test-expert.md +75 -0
- package/templates/frontend/angular-nx/.cursor/agents/security-auditor.md +61 -0
- package/templates/frontend/angular-nx/.cursor/hooks/auto-format.ts +70 -0
- package/templates/frontend/angular-nx/.cursor/hooks/auto-test-on-stop.ts +115 -0
- package/templates/frontend/angular-nx/.cursor/hooks/block-dangerous-commands.ts +188 -0
- package/templates/frontend/angular-nx/.cursor/hooks/ensure-tests-exist.ts +399 -0
- package/templates/frontend/angular-nx/.cursor/hooks/protect-sensitive-files.ts +128 -0
- package/templates/frontend/angular-nx/.cursor/hooks/session-context.ts +121 -0
- package/templates/frontend/angular-nx/.cursor/hooks.json +41 -0
- package/templates/frontend/react-vite/.cursor/agents/frontend-senior.agent.md +49 -49
- package/templates/frontend/react-vite/.cursor/agents/qa-test-expert.agent.md +126 -49
- package/templates/frontend/react-vite/.cursor/agents/security-expert.agent.md +39 -39
- package/templates/frontend/react-vite/.cursor/agents/ux-ui-expert.agent.md +45 -45
- package/templates/frontend/react-vite/.cursor/hooks/autoTestOnStop.ts +117 -0
- package/templates/frontend/react-vite/.cursor/hooks/blockDangerous.ts +75 -0
- package/templates/frontend/react-vite/.cursor/hooks/ensureTestsExist.ts +306 -220
- package/templates/frontend/react-vite/.cursor/hooks/formatOnEdit.ts +49 -0
- package/templates/frontend/react-vite/.cursor/hooks/protectSecrets.ts +88 -0
- package/templates/frontend/react-vite/.cursor/hooks/sessionInit.ts +77 -0
- package/templates/frontend/react-vite/.cursor/hooks.json +41 -10
- package/templates/frontend/react-vite/.cursor/settings.json +13 -13
- package/templates/frontend/react-vite/.vscode/settings.json +31 -31
- package/templates/frontend/react-vite/README.md +34 -34
- package/templates/frontend/react-vite/package.json +82 -82
- package/templates/frontend/react-vite/pnpm-lock.yaml +6575 -6575
- package/templates/frontend/react-vite/src/__tests__/components/layout/navbar.test.tsx +63 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/avatar.test.tsx +74 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/badge.test.tsx +55 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/breadcrumb.test.tsx +140 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/button.test.tsx +121 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/card.test.tsx +144 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/dialog.test.tsx +121 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/form.test.tsx +165 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/input.test.tsx +52 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/label.test.tsx +40 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/password-input.test.tsx +59 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/separator.test.tsx +40 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/table.test.tsx +254 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/tabs.test.tsx +82 -0
- package/templates/frontend/react-vite/src/__tests__/components/ui/textarea.test.tsx +47 -0
- package/templates/frontend/react-vite/src/__tests__/helpers/render.tsx +114 -0
- package/templates/frontend/react-vite/src/__tests__/hooks/useLocalStorage.test.ts +95 -0
- package/templates/frontend/react-vite/src/__tests__/lib/queryClient.test.ts +24 -0
- package/templates/frontend/react-vite/src/__tests__/lib/utils.test.ts +43 -0
- package/templates/frontend/react-vite/src/__tests__/routes/index.test.tsx +111 -0
- package/templates/frontend/react-vite/src/__tests__/routes/otra-ruta.test.tsx +126 -0
- package/templates/frontend/react-vite/src/__tests__/routes/root.test.tsx +78 -0
- package/templates/frontend/react-vite/src/__tests__/routes/ui-components.test.tsx +286 -0
- package/templates/frontend/react-vite/src/components/layout/navbar.tsx +38 -38
- package/templates/frontend/react-vite/src/components/ui/avatar.tsx +42 -42
- package/templates/frontend/react-vite/src/components/ui/dialog.tsx +122 -122
- package/templates/frontend/react-vite/src/components/ui/table.tsx +229 -244
- package/templates/frontend/react-vite/src/hooks/useLocalStorage.ts +32 -32
- package/templates/frontend/react-vite/src/routes/__root.tsx +48 -48
- package/templates/frontend/react-vite/src/routes/ui-components.tsx +359 -85
- package/templates/frontend/react-vite/src/test/setup.ts +24 -24
- package/templates/frontend/react-vite/vite.config.ts +2 -2
- package/templates/frontend/react-vite/vitest.config.ts +13 -2
- package/templates/frontend/react-vite-help/.cursor/RECONSTRUCTION-PROMPT.md +738 -0
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { render, screen, within } from "@testing-library/react";
|
|
3
|
+
import userEvent from "@testing-library/user-event";
|
|
4
|
+
import { type ColumnDef } from "@tanstack/react-table";
|
|
5
|
+
import {
|
|
6
|
+
Table,
|
|
7
|
+
TableHeader,
|
|
8
|
+
TableBody,
|
|
9
|
+
TableFooter,
|
|
10
|
+
TableHead,
|
|
11
|
+
TableRow,
|
|
12
|
+
TableCell,
|
|
13
|
+
TableCaption,
|
|
14
|
+
DataTable,
|
|
15
|
+
} from "@/components/ui/table";
|
|
16
|
+
|
|
17
|
+
describe("Table primitivos", () => {
|
|
18
|
+
it("Table renderiza <table> dentro de contenedor", () => {
|
|
19
|
+
render(
|
|
20
|
+
<Table data-testid="table">
|
|
21
|
+
<TableBody>
|
|
22
|
+
<TableRow>
|
|
23
|
+
<TableCell>Cell</TableCell>
|
|
24
|
+
</TableRow>
|
|
25
|
+
</TableBody>
|
|
26
|
+
</Table>
|
|
27
|
+
);
|
|
28
|
+
const table = screen.getByTestId("table");
|
|
29
|
+
expect(table.tagName).toBe("TABLE");
|
|
30
|
+
expect(table).toHaveAttribute("data-slot", "table");
|
|
31
|
+
expect(table.parentElement).toHaveAttribute("data-slot", "table-container");
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("TableHeader renderiza <thead> con data-slot", () => {
|
|
35
|
+
render(
|
|
36
|
+
<table>
|
|
37
|
+
<TableHeader data-testid="thead">
|
|
38
|
+
<tr>
|
|
39
|
+
<th>H</th>
|
|
40
|
+
</tr>
|
|
41
|
+
</TableHeader>
|
|
42
|
+
</table>
|
|
43
|
+
);
|
|
44
|
+
const el = screen.getByTestId("thead");
|
|
45
|
+
expect(el.tagName).toBe("THEAD");
|
|
46
|
+
expect(el).toHaveAttribute("data-slot", "table-header");
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("TableBody renderiza <tbody> con data-slot", () => {
|
|
50
|
+
render(
|
|
51
|
+
<table>
|
|
52
|
+
<TableBody data-testid="tbody">
|
|
53
|
+
<tr>
|
|
54
|
+
<td>B</td>
|
|
55
|
+
</tr>
|
|
56
|
+
</TableBody>
|
|
57
|
+
</table>
|
|
58
|
+
);
|
|
59
|
+
expect(screen.getByTestId("tbody")).toHaveAttribute("data-slot", "table-body");
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("TableFooter renderiza <tfoot> con data-slot", () => {
|
|
63
|
+
render(
|
|
64
|
+
<table>
|
|
65
|
+
<TableFooter data-testid="tfoot">
|
|
66
|
+
<tr>
|
|
67
|
+
<td>F</td>
|
|
68
|
+
</tr>
|
|
69
|
+
</TableFooter>
|
|
70
|
+
</table>
|
|
71
|
+
);
|
|
72
|
+
expect(screen.getByTestId("tfoot")).toHaveAttribute("data-slot", "table-footer");
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("TableRow renderiza <tr> con data-slot", () => {
|
|
76
|
+
render(
|
|
77
|
+
<table>
|
|
78
|
+
<tbody>
|
|
79
|
+
<TableRow data-testid="row">
|
|
80
|
+
<td>R</td>
|
|
81
|
+
</TableRow>
|
|
82
|
+
</tbody>
|
|
83
|
+
</table>
|
|
84
|
+
);
|
|
85
|
+
expect(screen.getByTestId("row")).toHaveAttribute("data-slot", "table-row");
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("TableHead renderiza <th> con data-slot", () => {
|
|
89
|
+
render(
|
|
90
|
+
<table>
|
|
91
|
+
<thead>
|
|
92
|
+
<tr>
|
|
93
|
+
<TableHead data-testid="head">H</TableHead>
|
|
94
|
+
</tr>
|
|
95
|
+
</thead>
|
|
96
|
+
</table>
|
|
97
|
+
);
|
|
98
|
+
expect(screen.getByTestId("head")).toHaveAttribute("data-slot", "table-head");
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it("TableCell renderiza <td> con data-slot", () => {
|
|
102
|
+
render(
|
|
103
|
+
<table>
|
|
104
|
+
<tbody>
|
|
105
|
+
<tr>
|
|
106
|
+
<TableCell data-testid="cell">C</TableCell>
|
|
107
|
+
</tr>
|
|
108
|
+
</tbody>
|
|
109
|
+
</table>
|
|
110
|
+
);
|
|
111
|
+
expect(screen.getByTestId("cell")).toHaveAttribute("data-slot", "table-cell");
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it("TableCaption renderiza <caption> con data-slot", () => {
|
|
115
|
+
render(
|
|
116
|
+
<table>
|
|
117
|
+
<TableCaption data-testid="caption">Cap</TableCaption>
|
|
118
|
+
</table>
|
|
119
|
+
);
|
|
120
|
+
expect(screen.getByTestId("caption")).toHaveAttribute("data-slot", "table-caption");
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
interface TestRow {
|
|
125
|
+
id: number;
|
|
126
|
+
name: string;
|
|
127
|
+
age: number;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const testData: TestRow[] = [
|
|
131
|
+
{ id: 1, name: "Alice", age: 30 },
|
|
132
|
+
{ id: 2, name: "Bob", age: 25 },
|
|
133
|
+
{ id: 3, name: "Charlie", age: 35 },
|
|
134
|
+
];
|
|
135
|
+
|
|
136
|
+
const testColumns: ColumnDef<TestRow, unknown>[] = [
|
|
137
|
+
{ accessorKey: "name", header: "Name" },
|
|
138
|
+
{ accessorKey: "age", header: "Age" },
|
|
139
|
+
];
|
|
140
|
+
|
|
141
|
+
describe("DataTable", () => {
|
|
142
|
+
it("renderiza todas las filas de datos", () => {
|
|
143
|
+
render(<DataTable data={testData} columns={testColumns} />);
|
|
144
|
+
expect(screen.getByText("Alice")).toBeInTheDocument();
|
|
145
|
+
expect(screen.getByText("Bob")).toBeInTheDocument();
|
|
146
|
+
expect(screen.getByText("Charlie")).toBeInTheDocument();
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it("muestra filterPlaceholder custom", () => {
|
|
150
|
+
render(
|
|
151
|
+
<DataTable data={testData} columns={testColumns} filterPlaceholder="Buscar empleados..." />
|
|
152
|
+
);
|
|
153
|
+
expect(screen.getByPlaceholderText("Buscar empleados...")).toBeInTheDocument();
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it("muestra placeholder por defecto 'Buscar...'", () => {
|
|
157
|
+
render(<DataTable data={testData} columns={testColumns} />);
|
|
158
|
+
expect(screen.getByPlaceholderText("Buscar...")).toBeInTheDocument();
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it("filtro global filtra filas visibles", async () => {
|
|
162
|
+
const user = userEvent.setup();
|
|
163
|
+
render(<DataTable data={testData} columns={testColumns} />);
|
|
164
|
+
|
|
165
|
+
await user.type(screen.getByPlaceholderText("Buscar..."), "Alice");
|
|
166
|
+
|
|
167
|
+
expect(screen.getByText("Alice")).toBeInTheDocument();
|
|
168
|
+
expect(screen.queryByText("Bob")).not.toBeInTheDocument();
|
|
169
|
+
expect(screen.queryByText("Charlie")).not.toBeInTheDocument();
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it("filtro sin resultados muestra 'No hay resultados'", async () => {
|
|
173
|
+
const user = userEvent.setup();
|
|
174
|
+
render(<DataTable data={testData} columns={testColumns} />);
|
|
175
|
+
|
|
176
|
+
await user.type(screen.getByPlaceholderText("Buscar..."), "zzzzz");
|
|
177
|
+
expect(screen.getByText("No hay resultados")).toBeInTheDocument();
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it("click en header ordena la columna", async () => {
|
|
181
|
+
const user = userEvent.setup();
|
|
182
|
+
render(<DataTable data={testData} columns={testColumns} />);
|
|
183
|
+
|
|
184
|
+
const originalCells = screen
|
|
185
|
+
.getAllByRole("row")
|
|
186
|
+
.slice(1)
|
|
187
|
+
.map((row) => within(row).getAllByRole("cell")[1].textContent);
|
|
188
|
+
|
|
189
|
+
const ageHeader = screen.getAllByRole("columnheader")[1];
|
|
190
|
+
await user.click(ageHeader);
|
|
191
|
+
|
|
192
|
+
const sortedCells = screen
|
|
193
|
+
.getAllByRole("row")
|
|
194
|
+
.slice(1)
|
|
195
|
+
.map((row) => within(row).getAllByRole("cell")[1].textContent);
|
|
196
|
+
|
|
197
|
+
expect(sortedCells).not.toEqual(originalCells);
|
|
198
|
+
const numericCells = sortedCells.map(Number);
|
|
199
|
+
const isSorted =
|
|
200
|
+
numericCells.every((v, i, a) => i === 0 || a[i - 1] <= v) ||
|
|
201
|
+
numericCells.every((v, i, a) => i === 0 || a[i - 1] >= v);
|
|
202
|
+
expect(isSorted).toBe(true);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
it("doble click invierte el orden de sort", async () => {
|
|
206
|
+
const user = userEvent.setup();
|
|
207
|
+
render(<DataTable data={testData} columns={testColumns} />);
|
|
208
|
+
|
|
209
|
+
const ageHeader = screen.getAllByRole("columnheader")[1];
|
|
210
|
+
await user.click(ageHeader);
|
|
211
|
+
|
|
212
|
+
const firstOrder = screen
|
|
213
|
+
.getAllByRole("row")
|
|
214
|
+
.slice(1)
|
|
215
|
+
.map((row) => within(row).getAllByRole("cell")[1].textContent);
|
|
216
|
+
|
|
217
|
+
await user.click(ageHeader);
|
|
218
|
+
|
|
219
|
+
const secondOrder = screen
|
|
220
|
+
.getAllByRole("row")
|
|
221
|
+
.slice(1)
|
|
222
|
+
.map((row) => within(row).getAllByRole("cell")[1].textContent);
|
|
223
|
+
|
|
224
|
+
expect(firstOrder).not.toEqual(secondOrder);
|
|
225
|
+
expect(firstOrder.reverse()).toEqual(secondOrder);
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
it("con data vacía muestra 'No hay resultados'", () => {
|
|
229
|
+
render(<DataTable data={[]} columns={testColumns} />);
|
|
230
|
+
expect(screen.getByText("No hay resultados")).toBeInTheDocument();
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
it("renderiza celdas custom via columnDef.cell", () => {
|
|
234
|
+
const customColumns: ColumnDef<TestRow, unknown>[] = [
|
|
235
|
+
{
|
|
236
|
+
accessorKey: "name",
|
|
237
|
+
header: "Name",
|
|
238
|
+
cell: ({ row }) => <strong>{row.getValue("name")}</strong>,
|
|
239
|
+
},
|
|
240
|
+
{ accessorKey: "age", header: "Age" },
|
|
241
|
+
];
|
|
242
|
+
|
|
243
|
+
render(<DataTable data={testData} columns={customColumns} />);
|
|
244
|
+
const strong = screen.getByText("Alice");
|
|
245
|
+
expect(strong.tagName).toBe("STRONG");
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it("mergea className custom", () => {
|
|
249
|
+
const { container } = render(
|
|
250
|
+
<DataTable data={testData} columns={testColumns} className="custom-table" />
|
|
251
|
+
);
|
|
252
|
+
expect(container.firstChild).toHaveClass("custom-table");
|
|
253
|
+
});
|
|
254
|
+
});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { render, screen } from "@testing-library/react";
|
|
3
|
+
import userEvent from "@testing-library/user-event";
|
|
4
|
+
import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/ui/tabs";
|
|
5
|
+
|
|
6
|
+
describe("Tabs", () => {
|
|
7
|
+
function renderTabs(defaultValue = "tab1") {
|
|
8
|
+
return render(
|
|
9
|
+
<Tabs defaultValue={defaultValue}>
|
|
10
|
+
<TabsList>
|
|
11
|
+
<TabsTrigger value="tab1">Tab 1</TabsTrigger>
|
|
12
|
+
<TabsTrigger value="tab2">Tab 2</TabsTrigger>
|
|
13
|
+
<TabsTrigger value="tab3">Tab 3</TabsTrigger>
|
|
14
|
+
</TabsList>
|
|
15
|
+
<TabsContent value="tab1">Content 1</TabsContent>
|
|
16
|
+
<TabsContent value="tab2">Content 2</TabsContent>
|
|
17
|
+
<TabsContent value="tab3">Content 3</TabsContent>
|
|
18
|
+
</Tabs>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
it("muestra el contenido del tab activo por defecto", () => {
|
|
23
|
+
renderTabs("tab1");
|
|
24
|
+
expect(screen.getByText("Content 1")).toBeInTheDocument();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("cambiar de tab muestra el contenido correcto", async () => {
|
|
28
|
+
const user = userEvent.setup();
|
|
29
|
+
renderTabs("tab1");
|
|
30
|
+
|
|
31
|
+
await user.click(screen.getByRole("tab", { name: "Tab 2" }));
|
|
32
|
+
expect(screen.getByText("Content 2")).toBeInTheDocument();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("TabsList tiene role='tablist'", () => {
|
|
36
|
+
renderTabs();
|
|
37
|
+
expect(screen.getByRole("tablist")).toBeInTheDocument();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("TabsTrigger tiene role='tab'", () => {
|
|
41
|
+
renderTabs();
|
|
42
|
+
const tabs = screen.getAllByRole("tab");
|
|
43
|
+
expect(tabs).toHaveLength(3);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("tab activo tiene data-state='active'", () => {
|
|
47
|
+
renderTabs("tab2");
|
|
48
|
+
expect(screen.getByRole("tab", { name: "Tab 2" })).toHaveAttribute("data-state", "active");
|
|
49
|
+
expect(screen.getByRole("tab", { name: "Tab 1" })).toHaveAttribute("data-state", "inactive");
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("data-slot correcto en todos los componentes", () => {
|
|
53
|
+
renderTabs();
|
|
54
|
+
expect(screen.getByRole("tablist")).toHaveAttribute("data-slot", "tabs-list");
|
|
55
|
+
screen.getAllByRole("tab").forEach((tab) => {
|
|
56
|
+
expect(tab).toHaveAttribute("data-slot", "tabs-trigger");
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("mergea className custom en TabsList", () => {
|
|
61
|
+
render(
|
|
62
|
+
<Tabs defaultValue="a">
|
|
63
|
+
<TabsList className="extra-list" data-testid="list">
|
|
64
|
+
<TabsTrigger value="a">A</TabsTrigger>
|
|
65
|
+
</TabsList>
|
|
66
|
+
<TabsContent value="a">Content</TabsContent>
|
|
67
|
+
</Tabs>
|
|
68
|
+
);
|
|
69
|
+
expect(screen.getByTestId("list")).toHaveClass("extra-list");
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("navegación con teclado entre tabs", async () => {
|
|
73
|
+
const user = userEvent.setup();
|
|
74
|
+
renderTabs("tab1");
|
|
75
|
+
|
|
76
|
+
const tab1 = screen.getByRole("tab", { name: "Tab 1" });
|
|
77
|
+
tab1.focus();
|
|
78
|
+
|
|
79
|
+
await user.keyboard("{ArrowRight}");
|
|
80
|
+
expect(screen.getByRole("tab", { name: "Tab 2" })).toHaveFocus();
|
|
81
|
+
});
|
|
82
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from "vitest";
|
|
2
|
+
import { render, screen } from "@testing-library/react";
|
|
3
|
+
import userEvent from "@testing-library/user-event";
|
|
4
|
+
import { Textarea } from "@/components/ui/textarea";
|
|
5
|
+
|
|
6
|
+
describe("Textarea", () => {
|
|
7
|
+
it("renderiza <textarea> con data-slot='textarea'", () => {
|
|
8
|
+
render(<Textarea data-testid="textarea" />);
|
|
9
|
+
const el = screen.getByTestId("textarea");
|
|
10
|
+
expect(el.tagName).toBe("TEXTAREA");
|
|
11
|
+
expect(el).toHaveAttribute("data-slot", "textarea");
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("muestra placeholder", () => {
|
|
15
|
+
render(<Textarea placeholder="Write here" />);
|
|
16
|
+
expect(screen.getByPlaceholderText("Write here")).toBeInTheDocument();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("mergea className custom", () => {
|
|
20
|
+
render(<Textarea className="custom" data-testid="textarea" />);
|
|
21
|
+
expect(screen.getByTestId("textarea")).toHaveClass("custom");
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("aplica estado disabled", () => {
|
|
25
|
+
render(<Textarea disabled data-testid="textarea" />);
|
|
26
|
+
expect(screen.getByTestId("textarea")).toBeDisabled();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("soporta aria-invalid para estado de error", () => {
|
|
30
|
+
render(<Textarea aria-invalid="true" data-testid="textarea" />);
|
|
31
|
+
expect(screen.getByTestId("textarea")).toHaveAttribute("aria-invalid", "true");
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("invoca onChange handler", async () => {
|
|
35
|
+
const user = userEvent.setup();
|
|
36
|
+
const handleChange = vi.fn();
|
|
37
|
+
render(<Textarea onChange={handleChange} placeholder="type" />);
|
|
38
|
+
|
|
39
|
+
await user.type(screen.getByPlaceholderText("type"), "abc");
|
|
40
|
+
expect(handleChange).toHaveBeenCalledTimes(3);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("tiene clases base de textarea", () => {
|
|
44
|
+
render(<Textarea data-testid="textarea" />);
|
|
45
|
+
expect(screen.getByTestId("textarea")).toHaveClass("textarea", "textarea-bordered", "w-full");
|
|
46
|
+
});
|
|
47
|
+
});
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { render, type RenderOptions } from "@testing-library/react";
|
|
3
|
+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
4
|
+
import {
|
|
5
|
+
createMemoryHistory,
|
|
6
|
+
createRootRoute,
|
|
7
|
+
createRoute,
|
|
8
|
+
createRouter,
|
|
9
|
+
RouterProvider,
|
|
10
|
+
Outlet,
|
|
11
|
+
} from "@tanstack/react-router";
|
|
12
|
+
|
|
13
|
+
function createTestQueryClient() {
|
|
14
|
+
return new QueryClient({
|
|
15
|
+
defaultOptions: {
|
|
16
|
+
queries: { retry: false, gcTime: 0 },
|
|
17
|
+
mutations: { retry: false },
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const rootRoute = createRootRoute({ component: () => <Outlet /> });
|
|
23
|
+
const indexRoute = createRoute({
|
|
24
|
+
getParentRoute: () => rootRoute,
|
|
25
|
+
path: "/",
|
|
26
|
+
component: () => null,
|
|
27
|
+
});
|
|
28
|
+
const otraRutaRoute = createRoute({
|
|
29
|
+
getParentRoute: () => rootRoute,
|
|
30
|
+
path: "/otra-ruta",
|
|
31
|
+
component: () => null,
|
|
32
|
+
});
|
|
33
|
+
const uiComponentsRoute = createRoute({
|
|
34
|
+
getParentRoute: () => rootRoute,
|
|
35
|
+
path: "/ui-components",
|
|
36
|
+
component: () => null,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const routeTree = rootRoute.addChildren([indexRoute, otraRutaRoute, uiComponentsRoute]);
|
|
40
|
+
|
|
41
|
+
interface WrapperOptions {
|
|
42
|
+
initialEntries?: string[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function renderWithRouter(
|
|
46
|
+
ui: ReactNode,
|
|
47
|
+
{ initialEntries = ["/"], ...renderOptions }: WrapperOptions & Omit<RenderOptions, "wrapper"> = {}
|
|
48
|
+
) {
|
|
49
|
+
const testQueryClient = createTestQueryClient();
|
|
50
|
+
|
|
51
|
+
const testRootRoute = createRootRoute({ component: () => <>{ui}</> });
|
|
52
|
+
const testIndexRoute = createRoute({
|
|
53
|
+
getParentRoute: () => testRootRoute,
|
|
54
|
+
path: "/",
|
|
55
|
+
component: () => null,
|
|
56
|
+
});
|
|
57
|
+
const testOtraRutaRoute = createRoute({
|
|
58
|
+
getParentRoute: () => testRootRoute,
|
|
59
|
+
path: "/otra-ruta",
|
|
60
|
+
component: () => null,
|
|
61
|
+
});
|
|
62
|
+
const testUiComponentsRoute = createRoute({
|
|
63
|
+
getParentRoute: () => testRootRoute,
|
|
64
|
+
path: "/ui-components",
|
|
65
|
+
component: () => null,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const testRouteTree = testRootRoute.addChildren([
|
|
69
|
+
testIndexRoute,
|
|
70
|
+
testOtraRutaRoute,
|
|
71
|
+
testUiComponentsRoute,
|
|
72
|
+
]);
|
|
73
|
+
|
|
74
|
+
const memoryHistory = createMemoryHistory({ initialEntries });
|
|
75
|
+
|
|
76
|
+
const router = createRouter({
|
|
77
|
+
routeTree: testRouteTree,
|
|
78
|
+
history: memoryHistory,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const result = render(
|
|
82
|
+
<QueryClientProvider client={testQueryClient}>
|
|
83
|
+
<RouterProvider router={router as ReturnType<typeof createRouter>} />
|
|
84
|
+
</QueryClientProvider>,
|
|
85
|
+
renderOptions
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
return { ...result, router, queryClient: testQueryClient };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function renderWithProviders(
|
|
92
|
+
ui: ReactNode,
|
|
93
|
+
renderOptions: Omit<RenderOptions, "wrapper"> = {}
|
|
94
|
+
) {
|
|
95
|
+
const testQueryClient = createTestQueryClient();
|
|
96
|
+
const memoryHistory = createMemoryHistory({ initialEntries: ["/"] });
|
|
97
|
+
|
|
98
|
+
const router = createRouter({
|
|
99
|
+
routeTree,
|
|
100
|
+
history: memoryHistory,
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
function Wrapper({ children }: { children: ReactNode }) {
|
|
104
|
+
return <QueryClientProvider client={testQueryClient}>{children}</QueryClientProvider>;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
...render(ui, { wrapper: Wrapper, ...renderOptions }),
|
|
109
|
+
queryClient: testQueryClient,
|
|
110
|
+
router,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export { createTestQueryClient };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
+
import { renderHook, act } from "@testing-library/react";
|
|
3
|
+
import { useLocalStorage } from "@/hooks/useLocalStorage";
|
|
4
|
+
|
|
5
|
+
describe("useLocalStorage", () => {
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
localStorage.clear();
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it("retorna initialValue cuando localStorage está vacío", () => {
|
|
11
|
+
const { result } = renderHook(() => useLocalStorage("key", "default"));
|
|
12
|
+
expect(result.current[0]).toBe("default");
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("lee valor existente de localStorage", () => {
|
|
16
|
+
localStorage.setItem("key", JSON.stringify("stored-value"));
|
|
17
|
+
const { result } = renderHook(() => useLocalStorage("key", "default"));
|
|
18
|
+
expect(result.current[0]).toBe("stored-value");
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("retorna initialValue cuando localStorage tiene JSON corrupto", () => {
|
|
22
|
+
localStorage.setItem("key", "not-valid-json{{{");
|
|
23
|
+
const { result } = renderHook(() => useLocalStorage("key", "fallback"));
|
|
24
|
+
expect(result.current[0]).toBe("fallback");
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("setValue con valor directo actualiza estado y localStorage", () => {
|
|
28
|
+
const { result } = renderHook(() => useLocalStorage("key", "initial"));
|
|
29
|
+
|
|
30
|
+
act(() => {
|
|
31
|
+
result.current[1]("updated");
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
expect(result.current[0]).toBe("updated");
|
|
35
|
+
expect(JSON.parse(localStorage.getItem("key")!)).toBe("updated");
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("setValue con función updater funciona correctamente", () => {
|
|
39
|
+
const { result } = renderHook(() => useLocalStorage("counter", 0));
|
|
40
|
+
|
|
41
|
+
act(() => {
|
|
42
|
+
result.current[1]((prev) => prev + 1);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
expect(result.current[0]).toBe(1);
|
|
46
|
+
expect(JSON.parse(localStorage.getItem("counter")!)).toBe(1);
|
|
47
|
+
|
|
48
|
+
act(() => {
|
|
49
|
+
result.current[1]((prev) => prev + 10);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
expect(result.current[0]).toBe(11);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("maneja error de localStorage.setItem sin romper", () => {
|
|
56
|
+
const setItemSpy = vi.spyOn(Storage.prototype, "setItem").mockImplementation(() => {
|
|
57
|
+
throw new DOMException("quota exceeded");
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const { result } = renderHook(() => useLocalStorage("key", "initial"));
|
|
61
|
+
|
|
62
|
+
act(() => {
|
|
63
|
+
result.current[1]("new-value");
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
expect(result.current[0]).toBe("new-value");
|
|
67
|
+
|
|
68
|
+
setItemSpy.mockRestore();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("persiste valores entre re-renders", () => {
|
|
72
|
+
const { result, rerender } = renderHook(() => useLocalStorage("key", "initial"));
|
|
73
|
+
|
|
74
|
+
act(() => {
|
|
75
|
+
result.current[1]("persisted");
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
rerender();
|
|
79
|
+
expect(result.current[0]).toBe("persisted");
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("soporta valores complejos (objetos)", () => {
|
|
83
|
+
const initial = { name: "test", count: 0 };
|
|
84
|
+
const { result } = renderHook(() => useLocalStorage("obj-key", initial));
|
|
85
|
+
|
|
86
|
+
expect(result.current[0]).toEqual(initial);
|
|
87
|
+
|
|
88
|
+
act(() => {
|
|
89
|
+
result.current[1]({ name: "updated", count: 5 });
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
expect(result.current[0]).toEqual({ name: "updated", count: 5 });
|
|
93
|
+
expect(JSON.parse(localStorage.getItem("obj-key")!)).toEqual({ name: "updated", count: 5 });
|
|
94
|
+
});
|
|
95
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { QueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { queryClient } from "@/lib/queryClient";
|
|
4
|
+
|
|
5
|
+
describe("queryClient", () => {
|
|
6
|
+
it("es una instancia de QueryClient", () => {
|
|
7
|
+
expect(queryClient).toBeInstanceOf(QueryClient);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it("tiene staleTime configurado en 60 segundos", () => {
|
|
11
|
+
const defaults = queryClient.getDefaultOptions();
|
|
12
|
+
expect(defaults.queries?.staleTime).toBe(60_000);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("tiene retry configurado en 1", () => {
|
|
16
|
+
const defaults = queryClient.getDefaultOptions();
|
|
17
|
+
expect(defaults.queries?.retry).toBe(1);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("tiene refetchOnWindowFocus deshabilitado", () => {
|
|
21
|
+
const defaults = queryClient.getDefaultOptions();
|
|
22
|
+
expect(defaults.queries?.refetchOnWindowFocus).toBe(false);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { cn } from "@/lib/utils";
|
|
3
|
+
|
|
4
|
+
describe("cn", () => {
|
|
5
|
+
it("combina múltiples clases", () => {
|
|
6
|
+
expect(cn("foo", "bar")).toBe("foo bar");
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it("resuelve conflictos de Tailwind (tailwind-merge)", () => {
|
|
10
|
+
expect(cn("p-4", "p-2")).toBe("p-2");
|
|
11
|
+
expect(cn("text-red-500", "text-blue-500")).toBe("text-blue-500");
|
|
12
|
+
expect(cn("mx-2", "mx-4")).toBe("mx-4");
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("ignora valores falsy (undefined, null, false)", () => {
|
|
16
|
+
expect(cn("foo", undefined, null, false, "bar")).toBe("foo bar");
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("maneja arrays de clases", () => {
|
|
20
|
+
expect(cn(["foo", "bar"])).toBe("foo bar");
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("maneja condicionales", () => {
|
|
24
|
+
const isActive = true;
|
|
25
|
+
expect(cn("base", isActive && "active")).toBe("base active");
|
|
26
|
+
|
|
27
|
+
const isHidden = false;
|
|
28
|
+
expect(cn("base", isHidden && "hidden")).toBe("base");
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("retorna string vacío sin argumentos", () => {
|
|
32
|
+
expect(cn()).toBe("");
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("maneja objetos condicionales de clsx", () => {
|
|
36
|
+
expect(cn({ active: true, disabled: false })).toBe("active");
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("combina Tailwind variantes complejas", () => {
|
|
40
|
+
expect(cn("hover:bg-red-500", "hover:bg-blue-500")).toBe("hover:bg-blue-500");
|
|
41
|
+
expect(cn("sm:p-4", "sm:p-8")).toBe("sm:p-8");
|
|
42
|
+
});
|
|
43
|
+
});
|