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

[Custom Fields] Some fixes #12582

Merged
merged 6 commits into from
Sep 18, 2024
Merged

[Custom Fields] Some fixes #12582

merged 6 commits into from
Sep 18, 2024

Conversation

hichamboushaba
Copy link
Member

@hichamboushaba hichamboushaba commented Sep 11, 2024

Description

This PR fixes some issues with the Custom Fields feature:

  1. The custom field content wasn't capturing click events (this was raised here and here), this was fixed in
    948e8ee
  2. The condition I was using to decide when to check for duplicate fields wasn't reliable, when editing a new non-saved field, we were ignoring the check, this was fixed in ad94ecd
  3. We had a corner case that when editing a new non-saved field, we would add a new entry instead of updating the existing one, this was fixed in 205a684 and
    0c8557f

Steps to reproduce

  1. Make sure an order has at least one custom field.
  2. Opent the order in the app.
  3. Tap on View Custom Fields.

Testing information

TC1:

  • Make sure tapping on the custom field's content opens the editor.

TC2:

  1. Add a new field.
  2. Tap on Done.
  3. Tap on the new field to edit it again.
  4. Update the key to match the content of an existing one.
  5. Tap on Done.
  6. Confirm an error is shown.

TC3:

  1. Add a new field.
  2. Tap on Done.
  3. Tap on the new field to edit again.
  4. Make some changes.
  5. Tap on Done.
  6. Confirm the field was updated correctly.

The tests that have been performed

The above.

  • 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.

@hichamboushaba hichamboushaba added type: task An internally driven task. feature: order details Related to order details. labels Sep 11, 2024
@hichamboushaba hichamboushaba changed the base branch from trunk to issue/12563-delete-custom-fields September 11, 2024 15:35
@hichamboushaba hichamboushaba changed the base branch from issue/12563-delete-custom-fields to issue/12578-copy-field September 11, 2024 15:35
@hichamboushaba hichamboushaba added the status: do not merge Dependent on another PR, ready for review but not ready for merge. label Sep 11, 2024
@dangermattic
Copy link
Collaborator

dangermattic commented Sep 11, 2024

1 Error
🚫 PR is not assigned to a milestone.

Generated by 🚫 Danger

@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 Name WooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commit7de6ad0
Direct Downloadwoocommerce-wear-prototype-build-pr12582-7de6ad0.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 Name WooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commit7de6ad0
Direct Downloadwoocommerce-prototype-build-pr12582-7de6ad0.apk

@hichamboushaba hichamboushaba marked this pull request as ready for review September 11, 2024 16:01
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 94.11765% with 1 line in your changes missing coverage. Please review.

Project coverage is 40.65%. Comparing base (4be88f0) to head (7de6ad0).

Files with missing lines Patch % Lines
...customfields/editor/CustomFieldsEditorViewModel.kt 92.85% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@                     Coverage Diff                      @@
##             issue/12578-copy-field   #12582      +/-   ##
============================================================
+ Coverage                     40.64%   40.65%   +0.01%     
- Complexity                     5670     5671       +1     
============================================================
  Files                          1228     1228              
  Lines                         68938    68947       +9     
  Branches                       9547     9550       +3     
============================================================
+ Hits                          28019    28032      +13     
+ Misses                        38345    38343       -2     
+ Partials                       2574     2572       -2     

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

@hichamboushaba hichamboushaba requested review from irfano and JorgeMucientes and removed request for irfano September 11, 2024 16:28
Base automatically changed from issue/12578-copy-field to trunk September 16, 2024 13:49
@JorgeMucientes JorgeMucientes self-assigned this Sep 16, 2024
Copy link
Contributor

@JorgeMucientes JorgeMucientes left a comment

Choose a reason for hiding this comment

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

Good job @hichamboushaba 👍🏼
While all the test worked as expected I did notice an scenario that it is not handled. It is is possible to add multiple new custom fields with the same key value. It is not until I click save that duplicates are handled. However, the resulting behavior is a bit weird from a users perspective. I think we should avoid being able to add new custom fields with the same key, just as you added a check to avoid editing an existing key to have the same value of other custom fields.

allowsToAddDuplicatesAndThenMerges.mp4

Feel free to address this change in a different PR. Won't block this one for it.

@hichamboushaba
Copy link
Member Author

It is is possible to add multiple new custom fields with the same key value. It is not until I click save that duplicates are handled. However, the resulting behavior is a bit weird from a users perspective.

Great find @JorgeMucientes, I'll address this later, and I'll share it with the iOS team, as for now we are checking against the saved items, and we don't check against the items that are not saved yet.

@hichamboushaba hichamboushaba removed the status: do not merge Dependent on another PR, ready for review but not ready for merge. label Sep 18, 2024
@hichamboushaba hichamboushaba merged commit c5b2d08 into trunk Sep 18, 2024
17 checks passed
@hichamboushaba hichamboushaba deleted the custom-fields/fix-issues branch September 18, 2024 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: order details Related to order details. type: task An internally driven task.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants