Skip to content

Conversation

@kevalyq
Copy link
Contributor

@kevalyq kevalyq commented Nov 22, 2025

πŸ“‹ Summary

Implements Issue #193 - Phase 2 of Secret Management UI: Create and Edit Forms

✨ What's New

Components

  • SecretForm - Reusable form component with:
    • All secret fields (title*, username, password, URL, notes)
    • Password show/hide toggle
    • Client-side validation
    • Loading states & error display
    • 8 tests βœ…

Pages

  • SecretCreate (/secrets/new) - Create new secrets with navigation to detail view on success (4 tests βœ…)
  • SecretEdit (/secrets/:id/edit) - Edit existing secrets with prefilled values (4 tests βœ…)

API Service

  • createSecret() - POST /api/v1/secrets
  • updateSecret() - PATCH /api/v1/secrets/{id}
  • Comprehensive error handling (ApiError with 401/403/404/422)
  • 12 tests βœ…

Routing

  • /secrets/new β†’ SecretCreate
  • /secrets/:id/edit β†’ SecretEdit

πŸ“Š Testing

  • 28 new tests (all passing)
  • API tests: 12
  • Component tests: 8
  • Page tests: 8

βœ… Quality Checks

  • TypeScript: βœ… No errors
  • ESLint: βœ… Passed with --max-warnings 0
  • REUSE 3.3: βœ… Compliant
  • Pre-push hooks: βœ… All passed

πŸ”— Related

πŸ“ Notes

Advanced features (password generator, strength indicator, tag autocomplete, date picker) deferred to follow-up PRs to keep scope manageable.

πŸš€ Next Steps

  • CI checks
  • Self-review
  • Code review
  • Manual testing

- 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
Copy link

codecov bot commented Nov 22, 2025

Codecov Report

❌ Patch coverage is 88.60759% with 18 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/pages/Secrets/SecretEdit.tsx 85.24% 9 Missing ⚠️
src/pages/Secrets/SecretCreate.tsx 80.00% 6 Missing ⚠️
src/services/secretApi.ts 90.00% 2 Missing ⚠️
src/components/SecretForm.tsx 97.29% 1 Missing ⚠️

πŸ“’ Thoughts on this report? Let us know!

@kevalyq kevalyq added the large-pr-approved Approved large PR (boilerplate/templates that cannot be split) label Nov 22, 2025
- 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%+
@kevalyq kevalyq requested a review from Copilot November 22, 2025 08:41
@kevalyq kevalyq marked this pull request as ready for review November 22, 2025 08:43
Copilot finished reviewing on behalf of kevalyq November 22, 2025 08:45
Copy link

Copilot AI left a 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 SecretForm component with validation, password visibility toggle, and loading states
  • SecretCreate and SecretEdit pages with proper navigation and error handling
  • API service methods (createSecret, updateSecret) with input validation and error handling
  • Routing integration for /secrets/new and /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.
@kevalyq kevalyq merged commit 334352c into main Nov 22, 2025
16 checks passed
@kevalyq kevalyq deleted the feat/secret-create-edit-forms branch November 22, 2025 09:20
kevalyq added a commit that referenced this pull request Nov 22, 2025
- 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
kevalyq added a commit that referenced this pull request Nov 22, 2025
Phase 1: #192 (issue) β†’ #197 (PR)
Phase 2: #193 (issue) β†’ #198 (PR)
Phase 3: #194 (issue) β†’ #200 (PR)

Addresses Copilot review comments.
kevalyq added a commit that referenced this pull request Nov 22, 2025
* 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

large-pr-approved Approved large PR (boilerplate/templates that cannot be split)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants