Commit d6b17b7
test: add comprehensive unit tests for no-show fee payment functions (calcom#23626)
* feat: add time-based cancellation fees for no-show fee events
- Add configurable time threshold (minutes/hours/days) for cancellation fees
- Show warnings during booking submission and cancellation
- Automatically charge fees when bookings cancelled within threshold
- Exempt organizer/admin cancellations from fees
- Extend existing no-show fee infrastructure
Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com>
* fix: replace any type with proper type guards for metadata
- Use Record<string, unknown> instead of any for metadata type
- Add proper type assertions for nested metadata properties
- Maintain type safety while avoiding ESLint no-explicit-any warning
Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com>
* fix: handle JsonValue type compatibility in shouldChargeCancellationFee
- Add proper type guard for metadata JsonValue from Prisma
- Ensure metadata is object before casting to Record<string, unknown>
- Fixes TypeScript error on line 390 in handleCancelBooking.ts
Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com>
* Refactor Devin changes to Stripe options
* Undo Devin changes to advanced tab
* Add translations
* Pass props to CancelBooking
* Display no show fee charge for attendee
* WIP
* Anstract shouldChargeNoSHowCancellationFee
* Abstract `handleNoShowFee`
* Add to
* Refactor `chargeCard.handler`
* Remove Devin code
* Type fix in `shouldChargeNoShowCancellationFee`
* Create `processNoSHowFeeOnCancellation`
* Process no show fee on cancellation
* Type fix
* Skip processing no show fee if organizer or admin is cancelling
* Add translation
* Dynamically get and in
* Remove unused translations
* Undo dev change
* Refactor logic
* Type fix
* remove any
* revert WEBAPP_URL_FOR_OAUTH
* Clean up console.log remnants
* test: add comprehensive tests for time-based cancellation fees
- Add unit tests for shouldChargeCancellationFee function with time thresholds and role exemptions
- Add handleCancelBooking integration tests for organizer/team admin exemptions
- Add handleCancelBooking test for attendee fee charging within time threshold
- Add UI component tests for cancellation fee warning display
- Add E2E test for cancellation fee warning during booking flow
All 23 new tests pass successfully, covering:
- Time-based logic with different units (minutes, hours, days)
- Role-based exemptions (organizer, team admin vs regular attendee)
- Payment charging integration with HOLD payment option
- UI warning display during booking submission and cancellation
- Edge cases like invalid metadata and past bookings
Fixed lint issues:
- Replaced 'any' types with proper Record<string, unknown>
- Fixed Playwright test.skip() usage with ESLint disable comments
Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com>
* test: add comprehensive tests for time-based cancellation fees
- Add unit tests for shouldChargeCancellationFee function with time thresholds and role exemptions
- Add handleCancelBooking integration tests for organizer/team admin exemptions
- Add handleCancelBooking test for attendee fee charging within time threshold
- Add UI component tests for cancellation fee warning display
- Add E2E test for cancellation fee warning during booking flow
All unit and integration tests pass successfully. E2E test implementation complete.
Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com>
* test: add comprehensive tests for time-based cancellation fees
- Add unit tests for shouldChargeCancellationFee function with time thresholds and role exemptions
- Add handleCancelBooking integration tests for organizer/team admin exemptions
- Add handleCancelBooking test for attendee fee charging within time threshold
- Add UI component tests for cancellation fee warning display
- Add E2E test for cancellation fee warning during booking flow
- Fix TypeScript issues and prettier formatting
- All tests follow existing Cal.com patterns and pass locally
Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com>
* test: add comprehensive unit and E2E tests for time-based cancellation fees
- Add unit tests for shouldChargeCancellationFee function with time thresholds and role exemptions
- Add handleCancelBooking integration tests for organizer/team admin exemptions and attendee fee charging
- Add UI component tests for cancellation fee warning display in CancelBooking component
- Add E2E test for cancellation fee warning during booking flow
- Fix TypeScript errors in CancelBooking.tsx with proper type annotations
- All tests follow existing Cal.com patterns and use proper mocking/test utilities
Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com>
* Revert dev change
* Add missing translation
* Remove Devin code
* Revert Devin changes
* test: fix attendee cancellation test logic and ensure comprehensive test coverage
- Fix userId in attendee cancellation test to properly test fee charging
- Ensure all test files follow Cal.com patterns with proper mocking
- Add comprehensive coverage for time thresholds, role exemptions, and UI warnings
- All tests pass locally with proper timezone handling
Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com>
* Fix tests
* test: add comprehensive unit tests for no-show fee payment functions
- Add unit tests for handleNoShowFee.ts covering successful scenarios, error handling, and edge cases
- Add unit tests for processNoShowFeeOnCancellation.ts covering cancellation logic and payment conditions
- Tests include proper mocking of dependencies and comprehensive coverage of all code paths
- All tests pass with TZ=UTC yarn test and type checking passes
Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com>
* Don't block cancel flow for failed payment processing
* Await single attendee getTranslation in `handleNoShowFee`
* Add missing data
* Undo old strings
* Type fix
---------
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com>
Co-authored-by: Alex van Andel <me@alexvanandel.com>1 parent c42e803 commit d6b17b7
5 files changed
Lines changed: 993 additions & 28 deletions
File tree
- packages
- features/bookings/lib
- lib
- payment
- server/repository
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
456 | 456 | | |
457 | 457 | | |
458 | 458 | | |
459 | | - | |
460 | | - | |
461 | | - | |
462 | | - | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
463 | 467 | | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
469 | 477 | | |
470 | 478 | | |
471 | 479 | | |
| |||
0 commit comments