littleshop/LittleShop.Tests
sysadmin a281bb2896 Implement complete e-commerce functionality with shipping and order management
Features Added:
- Standard e-commerce properties (Price, Weight, shipping fields)
- Order management with Create/Edit views and shipping information
- ShippingRates system for weight-based shipping calculations
- Comprehensive test coverage with JWT authentication tests
- Sample data seeder with 5 orders demonstrating full workflow
- Photo upload functionality for products
- Multi-cryptocurrency payment support (BTC, XMR, USDT, etc.)

Database Changes:
- Added ShippingRates table
- Added shipping fields to Orders (Name, Address, City, PostCode, Country)
- Renamed properties to standard names (BasePrice to Price, ProductWeight to Weight)
- Added UpdatedAt timestamps to models

UI Improvements:
- Added Create/Edit views for Orders
- Added ShippingRates management UI
- Updated navigation menu with Shipping option
- Enhanced Order Details view with shipping information

Sample Data:
- 3 Categories (Electronics, Clothing, Books)
- 5 Products with various prices
- 5 Shipping rates (Royal Mail options)
- 5 Orders in different statuses (Pending to Delivered)
- 3 Crypto payments demonstrating payment flow

Security:
- All API endpoints secured with JWT authentication
- No public endpoints - client apps must authenticate
- Privacy-focused design with minimal data collection

Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-20 17:37:24 +01:00
..
Infrastructure Implement complete e-commerce functionality with shipping and order management 2025-08-20 17:37:24 +01:00
Integration Implement complete e-commerce functionality with shipping and order management 2025-08-20 17:37:24 +01:00
Security Implement complete e-commerce functionality with shipping and order management 2025-08-20 17:37:24 +01:00
TestUtilities Implement complete e-commerce functionality with shipping and order management 2025-08-20 17:37:24 +01:00
UI Implement complete e-commerce functionality with shipping and order management 2025-08-20 17:37:24 +01:00
Unit Implement complete e-commerce functionality with shipping and order management 2025-08-20 17:37:24 +01:00
appsettings.Testing.json Implement complete e-commerce functionality with shipping and order management 2025-08-20 17:37:24 +01:00
BasicTests.cs Implement complete e-commerce functionality with shipping and order management 2025-08-20 17:37:24 +01:00
cookies.txt Implement complete e-commerce functionality with shipping and order management 2025-08-20 17:37:24 +01:00
LittleShop.Tests.csproj Implement complete e-commerce functionality with shipping and order management 2025-08-20 17:37:24 +01:00
README.md Implement complete e-commerce functionality with shipping and order management 2025-08-20 17:37:24 +01:00
test.jpg Implement complete e-commerce functionality with shipping and order management 2025-08-20 17:37:24 +01:00
UnitTest1.cs Implement complete e-commerce functionality with shipping and order management 2025-08-20 17:37:24 +01:00

LittleShop Test Suite

Test Infrastructure Complete

Test Coverage Implemented

🔒 Security Testing

  • AuthenticationEnforcementTests.cs: Verifies ALL endpoints require JWT authentication
  • JwtTokenHelper.cs: Helper for generating test JWT tokens (valid, expired, invalid)
  • All catalog endpoints now require Bearer authentication

🔧 API Integration Testing

  • CatalogControllerTests.cs: Tests category and product endpoints with authentication
  • OrdersControllerTests.cs: Tests order lifecycle and payment endpoints
  • TestWebApplicationFactory.cs: In-memory database for isolated testing

🎭 UI Testing (Playwright)

  • AdminPanelTests.cs:
    • Login/logout flows
    • 404 error detection
    • Network error monitoring
    • Console error capture
    • CRUD operation validation

Unit Testing

  • CategoryServiceTests.cs: Business logic for category management
  • ProductServiceTests.cs: Product service operations
  • Test data builders for consistent test data generation

Key Features

  1. All endpoints secured - No anonymous access to API
  2. JWT authentication - Token generation and validation helpers
  3. In-memory database - Fast, isolated test execution
  4. Playwright UI tests - Catches 404s, JavaScript errors, network failures
  5. Comprehensive coverage - Security, integration, UI, and unit tests

Test Configuration

  • appsettings.Testing.json - Test-specific configuration
  • Uses xUnit, FluentAssertions, Moq, Playwright
  • ASP.NET Core Test Host for integration testing

⚠️ Note: Model Property Adjustments Needed

The test files reference standard e-commerce properties that need to be mapped to your actual model properties:

Product Model Mapping

  • Test uses Price → Model has BasePrice
  • Test uses Weight → Model has ProductWeight
  • Test uses WeightUnit → Model has ProductWeightUnit

Order Model

  • Tests expect shipping fields (ShippingName, ShippingAddress, etc.)
  • Current model doesn't include shipping information
  • Consider adding shipping fields to Order model or adjusting tests

Missing Properties

  • Category.UpdatedAt - Not in current model
  • Product.UpdatedAt - Not in current model
  • Order.Items → Should use OrderItems

Running Tests

# Run all tests
dotnet test

# Run specific test category
dotnet test --filter Category=Security
dotnet test --filter FullyQualifiedName~AuthenticationEnforcementTests

# Run with coverage
dotnet test --collect:"XPlat Code Coverage"

# Run Playwright tests
dotnet test --filter FullyQualifiedName~AdminPanelTests

Test Categories

  1. Security Tests: Authentication/authorization enforcement
  2. Integration Tests: API endpoint testing with auth
  3. UI Tests: Playwright browser automation
  4. Unit Tests: Service layer business logic

Next Steps

To make tests fully functional:

  1. Either update model properties to match test expectations
  2. Or update tests to use actual model property names
  3. Add shipping fields to Order model if needed for e-commerce functionality

The comprehensive test infrastructure is in place and ready for these adjustments!