Skip to content

Conversation

@AdamGrzybkowski
Copy link
Contributor

WOOMOB-1561

Description

This PR implements the Cancel booking action (REST API part). There were some extra things that had to updated to make the whole Cancel work as expected:

  • Update the logic to determine Pay on site badge. The previous order.status != "completed" didn't work well for cancelled bookings/orders`. This also follows the latest changes to the web logic. - p1761223364429439/1761044767.213429-slack-C09FHQNQERG. d762e9a
  • Cancell button visibility - 01894d4
  • Attendance section visibility - 7bc5f2c

Additionally, there's an extra commit that adds an option to refresh the underlying order when updating the booking af05120. Up untill now, updating the booking was not affecting the order, but the new cancel booking is different as it also marks the order as cancelled. The order status is used to determine the badge so we need it updated.

Test Steps

  1. Launch the app
  2. Open the bookings tab
  3. Find a booking that wasn't cancelled
  4. Tap Cancel
  5. If successful, make sure that the button and the attendance section were hidden and the badge status changed
  6. You can also verify that a request to refresh an order was made

Please, try changing the attendance status, saving a new note and verify network requests to make sure we are not refreshing the order.

Images/gif

Screen_recording_20251023_151051.mp4
  • I have considered if this change warrants release notes and have added them to RELEASE-NOTES.txt if necessary. Use the "[Internal]" label for non-user-facing changes.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements the Cancel booking action for the REST API, allowing users to cancel bookings through the mobile app. The implementation includes necessary UI updates to properly reflect the cancelled state and handle the cancellation flow.

Key Changes

  • Added REST API support for canceling bookings with automatic order refresh to sync status updates
  • Updated booking status badge logic to correctly handle cancelled bookings using "on-hold" instead of incomplete order status
  • Modified UI visibility logic to hide cancel button and attendance section for cancelled bookings

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
BookingsStore.kt Added refreshBooking parameter and refactored update logic to support optional order refresh
BookingsRestClient.kt Extended payload mapping to include booking status field
BookingUpdatePayload.kt Added status field to support cancellation requests
BookingDtoMapper.kt Changed toBookingOrderInfo visibility to support order refresh logic
BookingsRepository.kt Implemented cancelBooking method that updates status and refreshes order
BookingMapper.kt Fixed badge logic to check for "on-hold" status and added cancel button visibility logic
BookingDetailsViewModel.kt Integrated cancel booking repository call with error handling
BookingDetailsViewState.kt Added computed property for attendance status modification capability
BookingDetailsScreen.kt Wrapped attendance section in animated visibility based on cancel button state
BookingAppointmentDetails.kt Added cancel button visibility control and conditional divider rendering
BookingsStoreTest.kt Added comprehensive test coverage for booking update scenarios
BookingDetailsViewModelTest.kt Added tests for cancel booking success and failure cases
BookingMapperTest.kt Updated test name and assertion to reflect corrected "on-hold" status logic
strings.xml Added error message string for booking cancellation failures

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@AdamGrzybkowski AdamGrzybkowski force-pushed the issue/WOOMOB-1561_cancel_booking branch from af05120 to 27afcb3 Compare October 23, 2025 14:11
@wpmobilebot
Copy link
Collaborator

📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
App NameWooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commit27afcb3
Direct Downloadwoocommerce-wear-prototype-build-pr14808-27afcb3.apk

@wpmobilebot
Copy link
Collaborator

📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App NameWooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commit27afcb3
Direct Downloadwoocommerce-prototype-build-pr14808-27afcb3.apk

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 38.77551% with 60 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.19%. Comparing base (33b66e6) to head (27afcb3).
⚠️ Report is 46 commits behind head on trunk.

Files with missing lines Patch % Lines
...d/ui/bookings/compose/BookingAppointmentDetails.kt 2.32% 40 Missing and 2 partials ⚠️
...commerce/android/ui/bookings/BookingsRepository.kt 0.00% 9 Missing ⚠️
...xc/network/rest/wpcom/wc/bookings/BookingsStore.kt 87.87% 2 Missing and 2 partials ⚠️
...twork/rest/wpcom/wc/bookings/BookingsRestClient.kt 0.00% 3 Missing ⚠️
...m/woocommerce/android/ui/bookings/BookingMapper.kt 0.00% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              trunk   #14808      +/-   ##
============================================
+ Coverage     38.17%   38.19%   +0.02%     
- Complexity    10060    10068       +8     
============================================
  Files          2132     2132              
  Lines        120344   120407      +63     
  Branches      16458    16476      +18     
============================================
+ Hits          45939    45993      +54     
+ Misses        69776    69771       -5     
- Partials       4629     4643      +14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants