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

Handle loading predefined packages error #13618

Open
wants to merge 5 commits into
base: trunk
Choose a base branch
from

Conversation

irfano
Copy link
Contributor

@irfano irfano commented Feb 25, 2025

Closes: #13324

Description

This updates the error screen when loading a predefined package case.

Steps to reproduce

To create a fake error response from the endpoint

  1. Go to Menu → Settings → Developer Options → API Faker
  2. Tap + button.
  3. Enter these settings:
Type: WordPress REST API
Http Method: GET
Path: /wcshipping/v1/packages
Status Code: 500
  1. Tap Save.
  2. Enable API Faker.

To test the retry screen

  1. Log in to a site that is eligible for shipping labels.
  2. Go to orders.
  3. Create a new order and complete the payment.
  4. Open the order details and tap the "Create shipping label" button.
  5. Tap Select a package button
  6. Disable the API faker by tapping the red bottom banner.
  7. Tap the Retry button.
  8. Verify that the error disappears.

Testing information

It's nice to retest #13608 as well.

The tests that have been performed

Streps above

Images/gif

Before After
After video
after.webm
  • [x ] 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.

Reviewer (or Author, in the case of optional code reviews):

Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement:

  • The PR is small and has a clear, single focus, or a valid explanation is provided in the description. If needed, please request to split it into smaller PRs.
  • Ensure Adequate Unit Test Coverage: The changes are reasonably covered by unit tests or an explanation is provided in the PR description.
  • Manual Testing: The author listed all the tests they ran, including smoke tests when needed (e.g., for refactorings). The reviewer confirmed that the PR works as expected on big (tablet) and small (phone) in case of UI changes, and no regressions are added.

@irfano irfano added the feature: shipping labels Related to creating, ordering, or printing shipping labels. label Feb 25, 2025
@irfano irfano added this to the 21.9 milestone Feb 25, 2025
Copy link

coderabbitai bot commented Feb 25, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

The changes update error handling and package management UIs across several files. In the shipping label creation screen, the error display is refactored to directly use a new composable, ErrorMessageWithButton, replacing a custom Column layout. In the package creation screens, parameters related to adding packages were removed while an onRetryClick parameter was added to handle error retries. The ViewModel’s initialization now delegates data fetching to a dedicated loadData() method and includes a new public onRetryClick() method. A new string resource for a package loading error message has also been introduced.

Changes

File(s) Change Summary
WooCommerce/.../WooShippingLabelCreationScreen.kt Updated ErrorScreen to use the new ErrorMessageWithButton; removed the WCTextButton import; renamed EmptyScreenPreview to ErrorScreenPreview.
WooCommerce/.../packages/WooShippingLabelPackageCreationScreen.kt
WooCommerce/.../packages/ui/WooShippingSavedPackageScreen.kt
Removed parameters isAddPackageEnabled and onAddPackageClick from package content calls; added an onRetryClick parameter in function signatures and updated preview methods.
WooCommerce/.../packages/WooShippingLabelPackageCreationViewModel.kt Refactored initialization by moving data fetch logic into a new private loadData() method; added a public onRetryClick() method to invoke the retry flow.
WooCommerce/.../packages/components/ErrorMessageWithButton.kt Introduced a new composable, ErrorMessageWithButton, that displays an error message with a retry button, along with an associated preview function.
WooCommerce/.../res/values/strings.xml Added a new string resource woo_shipping_labels_package_creation_saved_loading_error for displaying a package loading error message.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant UI as ErrorMessageWithButton
    participant VM as PackageCreationViewModel
    participant DS as Data Source

    U->>UI: Click "Retry" button
    UI->>VM: onRetryClick()
    VM->>VM: Show loading dialog
    VM->>DS: loadData() to fetch packages
    DS-->>VM: Return package data
    VM->>VM: Update state and hide loading dialog
    VM-->>UI: UI reflects updated data
Loading

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Feb 25, 2025

📲 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 Name WooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commitd49afbe
Direct Downloadwoocommerce-wear-prototype-build-pr13618-d49afbe.apk

@irfano
Copy link
Contributor Author

irfano commented Feb 25, 2025

@coderabbitai review

Copy link

coderabbitai bot commented Feb 25, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Feb 25, 2025

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

App Name WooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commitd49afbe
Direct Downloadwoocommerce-prototype-build-pr13618-d49afbe.apk

@irfano irfano force-pushed the issue/13324-load-predefined-packages-fails branch from 6bfc9c1 to 7a42462 Compare February 25, 2025 19:25
@irfano irfano force-pushed the issue/13324-load-predefined-packages-fails branch from 7a42462 to d49afbe Compare February 26, 2025 10:13
@irfano irfano requested a review from atorresveiga February 26, 2025 10:14
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 11.42857% with 31 lines in your changes missing coverage. Please review.

Project coverage is 38.05%. Comparing base (0a0c70c) to head (d49afbe).

Files with missing lines Patch % Lines
...bels/packages/components/ErrorMessageWithButton.kt 0.00% 25 Missing ⚠️
...ckages/WooShippingLabelPackageCreationViewModel.kt 40.00% 6 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              trunk   #13618      +/-   ##
============================================
- Coverage     38.06%   38.05%   -0.02%     
- Complexity     9058     9059       +1     
============================================
  Files          2058     2059       +1     
  Lines        112694   112725      +31     
  Branches      14286    14293       +7     
============================================
- Hits          42898    42896       -2     
- Misses        65895    65928      +33     
  Partials       3901     3901              

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: shipping labels Related to creating, ordering, or printing shipping labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Load predefined packages fails
3 participants