Skip to content

feat: characterization tests and domain extraction for flight booking API#1

Open
martinov wants to merge 1 commit intomainfrom
feat/session2-characterization-refactoring
Open

feat: characterization tests and domain extraction for flight booking API#1
martinov wants to merge 1 commit intomainfrom
feat/session2-characterization-refactoring

Conversation

@martinov
Copy link
Copy Markdown
Member

Summary

  • Added characterization tests capturing existing behavior of all flight search and booking endpoints (happy paths, edge cases, quirks)
  • Created behavior catalogs documenting every tested scenario for flights and bookings
  • Extracted domain logic from monolithic flight-booking-api.ts into focused modules: pricing, search-flights, create-booking, update-booking, cancel-booking
  • Introduced repository ports (FlightRepository, BookingRepository) with in-memory adapters

Test plan

  • Run pnpm test in session-2/1-characterization-refactoring/ to verify all characterization tests pass
  • Start the API server and run requests.sh to verify endpoints work end-to-end

…oking API

Add characterization tests capturing existing behavior of all flight and
booking endpoints, then extract domain logic into focused modules
(pricing, search-flights, create/update/cancel-booking) behind
repository ports with in-memory adapters.
@martinov
Copy link
Copy Markdown
Member Author

Thanks for the refactor and characterization coverage - I found one blocker before merge:\n\n- Blocking: starts the server at module import time (). With multiple test files, Jest runs suites in parallel by default, so multiple workers try to bind and one fails with .\n - Repro: run

flight-booking-api-legacy@1.0.0 test
jest in (default config)\n - Result: one suite fails immediately on import due to port collision\n - Suggested fix: only start listening when the file is executed directly (not when imported by tests), and keep exporting for .\n\n- Non-blocking: hardcodes a booking ID (), so GET/PUT/DELETE usually fail unless that exact ID exists from an earlier run.

@martinov
Copy link
Copy Markdown
Member Author

Posting a corrected version of my previous comment (formatting got mangled by shell interpolation):

Thanks for the refactor and characterization coverage - I found one blocker before merge:

  • Blocking: session-2/1-characterization-refactoring/src/flight-booking-api.ts:86 starts the server at module import time (app.listen(...)). With multiple test files, Jest runs suites in parallel by default, so multiple workers try to bind :3000 and one fails with EADDRINUSE.

    • Repro: run npm test in session-2/1-characterization-refactoring/ (default config)
    • Result: one suite fails immediately on import due to port collision
    • Suggested fix: only start listening when the file is executed directly (not when imported by tests), and keep exporting app for supertest.
  • Non-blocking: session-2/1-characterization-refactoring/requests.sh:17 hardcodes a booking ID (BK-1773732306909-1), so GET/PUT/DELETE usually fail unless that exact ID exists from an earlier run.

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