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

[BK] Create ProductType, ProductVariant, and Product Entities and APIs #20

Merged
merged 2 commits into from
Dec 17, 2024

Conversation

jimenezz22
Copy link
Contributor

🚀 StarShop Pull Request


📝 Changes description

1. Entities Created

  • ProductType: Represents categories for products, including fields like id, name, and description.
  • Product: Represents individual products, linked to ProductType. Fields include id, name, description, and a ManyToOne relationship with ProductType.
  • ProductVariant: Represents specific variants of a product. Fields include id, sku, price, stock, and a ManyToOne relationship with Product.

2. API Services Implemented

  • ProductTypeService: CRUD operations for ProductType entities.
  • ProductService: CRUD operations for Product entities, ensuring proper linkage to ProductType.
  • ProductVariantService: CRUD operations for ProductVariant entities, ensuring proper linkage to Product.

3. Unit Tests

Created unit tests for the following services:

  • ProductTypeService
  • ProductService
  • ProductVariantService
  • Tests validate the behavior of the CRUD methods and ensure proper error handling for invalid inputs.

4. Integration Tests

  • Implemented integration tests to validate database interactions and relationships:
    • ProductType Integration Tests:
      • CRUD operations.
      • Fetching Products associated with a ProductType.
    • Product Integration Tests:
      • CRUD operations.
      • Ensuring proper linkage with ProductType.
    • ProductVariant Integration Tests:
      • CRUD operations.
      • Ensuring proper linkage with Product.

5. Additional Adjustments

  • Updated ormconfig.ts to support testing with an in-memory SQLite database.
  • Configured Jest to include integration test setup and teardown:
  • Database synchronization before tests.
  • Data cleanup after each test.

How to Test

Run the unit and integration tests with the following commands:

  • npm test
    For a specific integration test:
  • npm test src/tests/integration/services/.spec.ts

📸 Evidence (A photo is required as evidence)

Screenshot 2024-12-15 at 10 05 14 PM

⏰ Time spent breakdown

1 Day


🌌 Comments


Thank you for contributing to StarShop, we are glad that you have chosen us as your project of choice and we hope that you continue to contribute to this great project, so that together we can make our mark at the top!

Copy link
Member

@Villarley Villarley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM great work homie!

@Villarley Villarley merged commit d36d656 into StarShopCr:main Dec 17, 2024
1 check passed
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.

[BK]: Create ProductType, ProductVariant, and Product Entities and APIs
2 participants