-
Notifications
You must be signed in to change notification settings - Fork 0
Phase 2: Secret Create/Edit Forms (Implements #193) #198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add reusable SecretForm component with validation - Add SecretCreate page for new secrets - Add SecretEdit page for updating existing secrets - Extend secretApi with createSecret() and updateSecret() - Add routes: /secrets/new, /secrets/:id/edit - 28 new tests (all passing) - TypeScript & ESLint clean Implements #193
Codecov Reportβ Patch coverage is π’ Thoughts on this report? Let us know! |
- Add test for 422 validation error display in SecretCreate - Add test for load error in SecretEdit - Add test for 422 validation errors in SecretEdit - Add tests for form field changes and notes field in SecretForm - Improve error handling to support both ApiError instances and error objects - Add form role attribute for better test accessibility Coverage improvements: - SecretCreate: 75% β 85%+ - SecretEdit: 67% β 85%+ - SecretForm: 80% β 90%+
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements Phase 2 of the Secret Management UI, adding create and edit functionality for secrets. It builds upon the previously merged Phase 1 (list and detail views) by introducing a reusable SecretForm component, dedicated create/edit pages, and corresponding API service methods for createSecret and updateSecret. The implementation follows React best practices with functional components, proper TypeScript typing, comprehensive test coverage (28 tests), and appropriate error handling patterns consistent with the existing codebase.
Key Changes:
- Reusable
SecretFormcomponent with validation, password visibility toggle, and loading states SecretCreateandSecretEditpages with proper navigation and error handling- API service methods (
createSecret,updateSecret) with input validation and error handling - Routing integration for
/secrets/newand/secrets/:id/edit
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/services/secretApi.ts | Added CreateSecretRequest and UpdateSecretRequest type definitions, plus createSecret() and updateSecret() API methods with input validation and comprehensive error handling |
| src/services/secretApi.create.test.ts | 12 tests covering create/update operations including success cases, validation errors (422), authorization errors (401/403), and 404 errors |
| src/components/SecretForm.tsx | Reusable form component with all secret fields, password show/hide toggle, client-side validation, and loading states |
| src/components/SecretForm.test.tsx | 8 tests covering form rendering, validation, submission, initial values, password toggle, and error display |
| src/pages/Secrets/SecretCreate.tsx | Create page with form submission, error handling, and navigation to detail view on success |
| src/pages/Secrets/SecretCreate.test.tsx | 4 tests covering form rendering, successful creation, error handling, and cancel navigation |
| src/pages/Secrets/SecretEdit.tsx | Edit page with secret loading, prefilled form (password intentionally excluded), error handling, and navigation |
| src/pages/Secrets/SecretEdit.test.tsx | 4 tests covering secret loading, successful updates, error handling, cancel navigation, and validation errors |
| src/App.tsx | Added routes for /secrets/new and /secrets/:id/edit with proper route ordering |
- Extract validation error formatting to errorUtils - Fix field clearing bug in SecretEdit (use !== undefined) - Simplify button label logic in SecretForm (remove fragile regex) - Clarify password behavior comment Addresses 5 Copilot code review comments from PR #198
- Update SecretForm test to expect 'Create...' instead of 'Creating...' - Update SecretEdit test to expect empty strings for cleared url/notes fields - Reflects changes from Copilot review fixes
- Add test for missing ID in SecretEdit - Add test for non-ApiError when loading secret - Add test to verify empty password is not sent - Add test for non-ApiError with validation format (SecretEdit and SecretCreate) - Improves patch coverage from 86.70% to target 87.88%
The test 'should handle non-ApiError when loading' was redundant with existing test 'should display error when loading fails' at line 197. Both tested the same scenario: Network error shows 'Failed to load secret'. Also fixed mock usage in coverage tests to use mockResolvedValue instead of mockResolvedValueOnce for consistency with other tests.
- Add Phase 1 (Secret List & Detail Views, PR #197) - Add Phase 2 (Secret Create/Edit Forms, PR #198) - Add Phase 3 (File Attachments UI, PR #200) - Update README.md with Secret Management feature section - Update Epic #191 with completed phases (60% progress) All phases merged on 22.11.2025 with 87.95% test coverage. Part of: #191
* chore: format SecretForm.enhanced.test.tsx * docs: Add Secret Management Phase 1-3 documentation - Add Phase 1 (Secret List & Detail Views, PR #197) - Add Phase 2 (Secret Create/Edit Forms, PR #198) - Add Phase 3 (File Attachments UI, PR #200) - Update README.md with Secret Management feature section - Update Epic #191 with completed phases (60% progress) All phases merged on 22.11.2025 with 87.95% test coverage. Part of: #191 * fix: Correct PR numbers in CHANGELOG.md Phase 1: #192 (issue) β #197 (PR) Phase 2: #193 (issue) β #198 (PR) Phase 3: #194 (issue) β #200 (PR) Addresses Copilot review comments.
π Summary
Implements Issue #193 - Phase 2 of Secret Management UI: Create and Edit Forms
β¨ What's New
Components
Pages
/secrets/new) - Create new secrets with navigation to detail view on success (4 tests β )/secrets/:id/edit) - Edit existing secrets with prefilled values (4 tests β )API Service
createSecret()- POST /api/v1/secretsupdateSecret()- PATCH /api/v1/secrets/{id}Routing
/secrets/newβ SecretCreate/secrets/:id/editβ SecretEditπ Testing
β Quality Checks
--max-warnings 0π Related
π Notes
Advanced features (password generator, strength indicator, tag autocomplete, date picker) deferred to follow-up PRs to keep scope manageable.
π Next Steps