[PR #32437] test(base) : added test coverage for base form files #33743

Open
opened 2026-02-21 20:53:48 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/32437

State: open
Merged: No


Checklist

  • This change requires a documentation update
  • I’ve added/updated tests for the behavior covered in this change
  • I ran lint, tests, and coverage for the updated base/form specs
  • No backend/API code paths were changed

Unit Test Added Summary

Added spec files

  • web/app/components/base/form/index.spec.tsx (new)
  • web/app/components/base/form/types.spec.ts (new)
  • web/app/components/base/form/hooks/index.spec.ts (new)
  • web/app/components/base/form/hooks/use-check-validated.spec.ts (new)
  • web/app/components/base/form/hooks/use-get-form-values.spec.ts (new)
  • web/app/components/base/form/hooks/use-get-validators.spec.ts (new)
  • web/app/components/base/form/utils/zod-submit-validator.spec.ts (new)
  • web/app/components/base/form/utils/secret-input/index.spec.ts (new)
  • web/app/components/base/form/form-scenarios/auth/index.spec.tsx (new)
  • web/app/components/base/form/form-scenarios/base/field.spec.tsx (new)
  • web/app/components/base/form/form-scenarios/base/index.spec.tsx (new)
  • web/app/components/base/form/form-scenarios/base/types.spec.ts (new)
  • web/app/components/base/form/form-scenarios/base/utils.spec.ts (new)
  • web/app/components/base/form/form-scenarios/demo/contact-fields.spec.tsx (new)
  • web/app/components/base/form/form-scenarios/demo/index.spec.tsx (new)
  • web/app/components/base/form/form-scenarios/demo/shared-options.spec.tsx (new)
  • web/app/components/base/form/form-scenarios/demo/types.spec.ts (new)
  • web/app/components/base/form/form-scenarios/input-field/field.spec.tsx (new)
  • web/app/components/base/form/form-scenarios/input-field/types.spec.ts (new)
  • web/app/components/base/form/form-scenarios/input-field/utils.spec.ts (new)
  • web/app/components/base/form/form-scenarios/node-panel/field.spec.tsx (new)
  • web/app/components/base/form/form-scenarios/node-panel/types.spec.ts (new)

Validation Run

Lint

cd web && pnpm exec eslint $(rg --files app/components/base/form | rg '\.spec\.(ts|tsx)$')
  • Result: Passed

Type Check

pnpm --dir web type-check:tsgo
  • Result: Passed

Tests

cd web && pnpm exec vitest run $(rg --files app/components/base/form | rg '\.spec\.(ts|tsx)$' | rg -v '^app/components/base/form/components/')
  • Result: Passed (22 files, 64 tests)

Coverage

cd web && pnpm exec vitest run --coverage $(rg --files app/components/base/form | rg '\.spec\.(ts|tsx)$' | rg -v '^app/components/base/form/components/')
  • Result: Passed

Coverage Report (Base Form Source Files, excluding components/)

Scoped statement coverage: 98.94% (375/379)

File Status in this update Statements Branches Functions Lines
app/components/base/form/form-scenarios/auth/index.tsx Covered in current update 100.00% 100.00% 100.00% 100.00%
app/components/base/form/form-scenarios/base/field.tsx Covered in current update 100.00% 100.00% 100.00% 100.00%
app/components/base/form/form-scenarios/base/index.tsx Covered in current update 100.00% 100.00% 100.00% 100.00%
app/components/base/form/form-scenarios/base/types.ts Covered in current update 100.00% 100.00% 100.00% 100.00%
app/components/base/form/form-scenarios/base/utils.ts Covered in current update 86.20% 77.27% 100.00% 86.20%
app/components/base/form/form-scenarios/demo/contact-fields.tsx Covered in current update 100.00% 100.00% 100.00% 100.00%
app/components/base/form/form-scenarios/demo/index.tsx Covered in current update 100.00% 100.00% 100.00% 100.00%
app/components/base/form/form-scenarios/demo/shared-options.tsx Covered in current update 100.00% 100.00% 100.00% 100.00%
app/components/base/form/form-scenarios/demo/types.ts Covered in current update 100.00% 100.00% 100.00% 100.00%
app/components/base/form/form-scenarios/input-field/field.tsx Covered in current update 100.00% 100.00% 100.00% 100.00%
app/components/base/form/form-scenarios/input-field/types.ts Covered in current update 100.00% 100.00% 100.00% 100.00%
app/components/base/form/form-scenarios/input-field/utils.ts Covered in current update 100.00% 88.46% 100.00% 100.00%
app/components/base/form/form-scenarios/node-panel/field.tsx Covered in current update 100.00% 100.00% 100.00% 100.00%
app/components/base/form/form-scenarios/node-panel/types.ts Covered in current update 100.00% 100.00% 100.00% 100.00%
app/components/base/form/hooks/index.ts Covered in current update (barrel export) 100.00% 100.00% 100.00% 100.00%
app/components/base/form/hooks/use-check-validated.ts Covered in current update 100.00% 88.88% 100.00% 100.00%
app/components/base/form/hooks/use-get-form-values.ts Covered in current update 100.00% 77.77% 100.00% 100.00%
app/components/base/form/hooks/use-get-validators.ts Covered in current update 100.00% 81.81% 100.00% 100.00%
app/components/base/form/index.tsx Covered in current update 100.00% 100.00% 100.00% 100.00%
app/components/base/form/types.ts Covered in current update 100.00% 100.00% 100.00% 100.00%
app/components/base/form/utils/secret-input/index.ts Covered in current update 100.00% 75.00% 100.00% 100.00%
app/components/base/form/utils/zod-submit-validator.ts Covered in current update 100.00% 83.33% 100.00% 100.00%

Fixes Issues - #32152

**Original Pull Request:** https://github.com/langgenius/dify/pull/32437 **State:** open **Merged:** No --- ## Checklist - [ ] This change requires a documentation update - [x] I’ve added/updated tests for the behavior covered in this change - [x] I ran lint, tests, and coverage for the updated `base/form` specs - [x] No backend/API code paths were changed ## Unit Test Added Summary ### Added spec files - `web/app/components/base/form/index.spec.tsx` (new) - `web/app/components/base/form/types.spec.ts` (new) - `web/app/components/base/form/hooks/index.spec.ts` (new) - `web/app/components/base/form/hooks/use-check-validated.spec.ts` (new) - `web/app/components/base/form/hooks/use-get-form-values.spec.ts` (new) - `web/app/components/base/form/hooks/use-get-validators.spec.ts` (new) - `web/app/components/base/form/utils/zod-submit-validator.spec.ts` (new) - `web/app/components/base/form/utils/secret-input/index.spec.ts` (new) - `web/app/components/base/form/form-scenarios/auth/index.spec.tsx` (new) - `web/app/components/base/form/form-scenarios/base/field.spec.tsx` (new) - `web/app/components/base/form/form-scenarios/base/index.spec.tsx` (new) - `web/app/components/base/form/form-scenarios/base/types.spec.ts` (new) - `web/app/components/base/form/form-scenarios/base/utils.spec.ts` (new) - `web/app/components/base/form/form-scenarios/demo/contact-fields.spec.tsx` (new) - `web/app/components/base/form/form-scenarios/demo/index.spec.tsx` (new) - `web/app/components/base/form/form-scenarios/demo/shared-options.spec.tsx` (new) - `web/app/components/base/form/form-scenarios/demo/types.spec.ts` (new) - `web/app/components/base/form/form-scenarios/input-field/field.spec.tsx` (new) - `web/app/components/base/form/form-scenarios/input-field/types.spec.ts` (new) - `web/app/components/base/form/form-scenarios/input-field/utils.spec.ts` (new) - `web/app/components/base/form/form-scenarios/node-panel/field.spec.tsx` (new) - `web/app/components/base/form/form-scenarios/node-panel/types.spec.ts` (new) ## Validation Run ### Lint ```bash cd web && pnpm exec eslint $(rg --files app/components/base/form | rg '\.spec\.(ts|tsx)$') ``` - Result: ✅ Passed ### Type Check ```bash pnpm --dir web type-check:tsgo ``` - Result: ✅ Passed ### Tests ```bash cd web && pnpm exec vitest run $(rg --files app/components/base/form | rg '\.spec\.(ts|tsx)$' | rg -v '^app/components/base/form/components/') ``` - Result: ✅ Passed (22 files, 64 tests) ### Coverage ```bash cd web && pnpm exec vitest run --coverage $(rg --files app/components/base/form | rg '\.spec\.(ts|tsx)$' | rg -v '^app/components/base/form/components/') ``` - Result: ✅ Passed ## Coverage Report (Base Form Source Files, excluding `components/`) **Scoped statement coverage:** **98.94% (375/379)** | File | Status in this update | Statements | Branches | Functions | Lines | |---|---|---:|---:|---:|---:| | `app/components/base/form/form-scenarios/auth/index.tsx` | Covered in current update | 100.00% | 100.00% | 100.00% | 100.00% | | `app/components/base/form/form-scenarios/base/field.tsx` | Covered in current update | 100.00% | 100.00% | 100.00% | 100.00% | | `app/components/base/form/form-scenarios/base/index.tsx` | Covered in current update | 100.00% | 100.00% | 100.00% | 100.00% | | `app/components/base/form/form-scenarios/base/types.ts` | Covered in current update | 100.00% | 100.00% | 100.00% | 100.00% | | `app/components/base/form/form-scenarios/base/utils.ts` | Covered in current update | 86.20% | 77.27% | 100.00% | 86.20% | | `app/components/base/form/form-scenarios/demo/contact-fields.tsx` | Covered in current update | 100.00% | 100.00% | 100.00% | 100.00% | | `app/components/base/form/form-scenarios/demo/index.tsx` | Covered in current update | 100.00% | 100.00% | 100.00% | 100.00% | | `app/components/base/form/form-scenarios/demo/shared-options.tsx` | Covered in current update | 100.00% | 100.00% | 100.00% | 100.00% | | `app/components/base/form/form-scenarios/demo/types.ts` | Covered in current update | 100.00% | 100.00% | 100.00% | 100.00% | | `app/components/base/form/form-scenarios/input-field/field.tsx` | Covered in current update | 100.00% | 100.00% | 100.00% | 100.00% | | `app/components/base/form/form-scenarios/input-field/types.ts` | Covered in current update | 100.00% | 100.00% | 100.00% | 100.00% | | `app/components/base/form/form-scenarios/input-field/utils.ts` | Covered in current update | 100.00% | 88.46% | 100.00% | 100.00% | | `app/components/base/form/form-scenarios/node-panel/field.tsx` | Covered in current update | 100.00% | 100.00% | 100.00% | 100.00% | | `app/components/base/form/form-scenarios/node-panel/types.ts` | Covered in current update | 100.00% | 100.00% | 100.00% | 100.00% | | `app/components/base/form/hooks/index.ts` | Covered in current update (barrel export) | 100.00% | 100.00% | 100.00% | 100.00% | | `app/components/base/form/hooks/use-check-validated.ts` | Covered in current update | 100.00% | 88.88% | 100.00% | 100.00% | | `app/components/base/form/hooks/use-get-form-values.ts` | Covered in current update | 100.00% | 77.77% | 100.00% | 100.00% | | `app/components/base/form/hooks/use-get-validators.ts` | Covered in current update | 100.00% | 81.81% | 100.00% | 100.00% | | `app/components/base/form/index.tsx` | Covered in current update | 100.00% | 100.00% | 100.00% | 100.00% | | `app/components/base/form/types.ts` | Covered in current update | 100.00% | 100.00% | 100.00% | 100.00% | | `app/components/base/form/utils/secret-input/index.ts` | Covered in current update | 100.00% | 75.00% | 100.00% | 100.00% | | `app/components/base/form/utils/zod-submit-validator.ts` | Covered in current update | 100.00% | 83.33% | 100.00% | 100.00% | Fixes Issues - #32152
yindo added the pull-request label 2026-02-21 20:53:48 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#33743