-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Update WooPosItems Tests - default to happy path #13728
Conversation
📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
|
📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.
|
@coderabbitai review |
1 similar comment
@coderabbitai review |
📝 WalkthroughWalkthroughThe pull request updates the WooPosItemsViewModel test file. Changes include adding a step in the setup to initialize a list of products using a product test utility, which is then used to mock the product data source behavior. Test comments and method names have been updated to clarify the different test phases (e.g., renaming “given loading products is failure” to “given loading products fails”) and redundant product generation code has been removed. These adjustments streamline the test structure and improve readability without affecting the underlying test logic. Changes
Sequence Diagram(s)sequenceDiagram
participant TR as Test Runner
participant VM as WooPosItemsViewModel
participant DS as ProductsDataSource
participant PT as ProductTestUtils
TR->>VM: Initialize Test Environment
VM->>PT: Generate product list
PT-->>VM: Return product list
VM->>DS: Call loadSimpleProducts()
DS-->>VM: Return simulated error
VM-->>TR: Emit error state
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🔇 Additional comments (6)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this. The code changes looks good to me
…ate-pos-items-vm-tests
@coderabbitai review
do not merge
label - this PR is dependant on #13724 which needs to be merged first. Feel free to remove the label and merge the PR when the parent PR gets merged.Description
This PR doesn't introduce any changes, it only refactors unit tests of WooPosItemsViewModel. I noticed the tests are quite repetitive and more importantly, the
given
section setups items that are not related to the code path the code is testing. This makes tests a bit tricky to read and adds friction when introducing new tests. I've refactored the code so the happy path (items successfully loaded) is the default setup, while allowing each test to modify this behavior only when needed (only when it affects the code path the test is verifying).cc @kidinov @samiuelson @ThomazFB In case you'd disagree with this approach of setting up tests in a way that the default setup is the happy path.
Testing information
CI run is enough
The tests that have been performed
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: