Skip to content
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

Refactor and Enhance PaymentScreen with Improved Modularity and Test Coverage #8

Merged
merged 7 commits into from
Dec 26, 2024

Conversation

abdullahbayram
Copy link
Owner

Refactor and Enhance PaymentScreen with Improved Modularity and Test Coverage


Key Changes

  1. Component Reorganization:

    • Moved BasketSummary to @components/molecules and added it to ProductListScreen.
    • Modularized BasketSummary and PaymentForm into components/.
  2. Improvements to PaymentScreen:

    • Refactored logic for readability and maintainability.
    • Extracted parseErrorMessage into a utility for reuse.
  3. Validation Updates:

    • Moved hardcoded strings from validation rules to strings.
  4. Testing:

    • Added unit tests for paymentUtil, ControlledInput, BasketSummary, and PaymentForm.
    • Enhanced PaymentScreen tests to include form validation and functionality.
    • Achieved good testing coverage

Test Coverage

Metric Percentage
Statements 88.03%
Branches 82.91%
Functions 87.93%
Lines 87.17%

- Extracted ControlledInput component to a separate file for reuse and clarity.
- Split utility functions into paymentUtils for improved modularity and easier testing.
- Refactored PaymentScreen to use the new modular components and utilities.
- Split `BasketSummary` and `PaymentForm` into the local `components/` directory for modularity.
- Extracted `parseErrorMessage` utility into a separate function for reusability and clarity.
- Improved readability and maintainability of the `PaymentScreen` logic.
- Prepared the screen for better testability with enhanced structure and utility abstraction.
- Rename variables to `totalItemCount` and `totalPrice` for clarity.
- Move `BasketSummary` component to `@components/molecules`
- Add `BasketSummary` to `ProductListScreen`.
- Extract hardcoded strings from validation rules into `strings`
- Enhance `PaymentScreen` tests to include form validation
@abdullahbayram abdullahbayram merged commit 2852791 into main Dec 26, 2024
2 checks passed
@abdullahbayram abdullahbayram deleted the enhance/payment-screen-with-tests branch December 26, 2024 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant