Skip to content

Conversation

@jaclync
Copy link
Contributor

@jaclync jaclync commented May 15, 2020

Fixes #2302

Changes

  • Since there 2 places that require the knowledge of the visible actions on the product form bottom sheet (the CTA visibility + bottom sheet list selector data), the duplicated actions logic from ProductFormViewController and ProductFormBottomSheetListSelectorCommand were now shared in ProductFormBottomSheetActionsFactory
  • Updated ProductFormViewController to get the bottom sheet actions from ProductFormBottomSheetActionsFactory and passing them to ProductFormBottomSheetListSelectorCommand
  • Updated unit tests

Testing

Prerequisite: prepare a simple product that is not virtual/downloadable (so that it has shipping settings) and its shipping data are all empty

  • Go to Settings > Experimental Features, and turn off the Products feature switch
  • Go to the Products tab
  • Tap on the simple Product in the prerequisite --> "Add more details" CTA should be visible at the bottom

Example screenshots

before (no way to edit shipping settings) after
Simulator Screen Shot - iPhone 8 Plus - 2020-05-15 at 16 58 44 Simulator Screen Shot - iPhone 8 Plus - 2020-05-15 at 17 52 36

Update release notes:

  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@jaclync jaclync added type: bug A confirmed bug. feature: add/edit products Related to adding or editing products. labels May 15, 2020
@jaclync jaclync added this to the 4.3 milestone May 15, 2020
@jaclync jaclync requested a review from a team May 15, 2020 09:55
@jaclync jaclync self-assigned this May 15, 2020
Copy link
Contributor

@pmusolino pmusolino left a comment

Choose a reason for hiding this comment

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

Hey Jaclyn! During the test, I encountered a crash tapping on the product "Premium Quality" on my test store on an iPhone Xs with iOS 12.2 (it happens also on other products every time I launch the application from Xcode)

Schermata 2020-05-15 alle 19 33 54

I also encountered that the content of the cells now it's not populated (this happens for every simple product that I'm able to open):

I've also 4 tests failing.
Schermata 2020-05-15 alle 19 54 26

@jaclync
Copy link
Contributor Author

jaclync commented May 18, 2020

Thanks for testing @pmusolino ! I just tested your store on iPhone Xs simulator iOS 12.1, and somehow I wasn't able to see the crashes and issues you had with M2 feature flag off or on 🤔also, I was wondering why your test cases looked different:

test cases that failed during your testing test cases that passed on my end
Screen Shot 2020-05-18 at 8 29 41 AM

I was able to open all the products on your store:

Premium Quality product "Woo Ninja - H&M" product
Simulator Screen Shot - iPhone Xs - 2020-05-18 at 08 25 24 Simulator Screen Shot - iPhone Xs - 2020-05-18 at 08 29 59

It'd be great if I can know more about a few things for further investigation on my side:

  • for the crash, do you mind sharing the indexPath.row value?
  • it sounds like you were able to reproduce the crash/label issue consistently? were you able to reproduce on all devices, or specific to this OS/device type?
  • did you have any diffs during your testing, like to manually turn on/off other feature flags? I tested with M3 flag on/off manually in DefaultFeatureFlagService and both worked for me

@jaclync
Copy link
Contributor Author

jaclync commented May 18, 2020

this PR is going to target release 4.3 for Products M2 release behind a feature switch, sorry if it's not making the code freeze today! cc @oguzkocer

@pmusolino pmusolino self-requested a review May 18, 2020 11:15
@pmusolino
Copy link
Contributor

I'm unlucky. After a logout, I'm no more able to replicate the crash or the failing tests. :(
I can't really tell you what was different. The M2 product flag was disabled (from the Experimental Features screen), while the M3 one was enabled.

@pmusolino pmusolino requested a review from shiki May 18, 2020 11:51
@pmusolino
Copy link
Contributor

@shiki Can you take a look at it too? There is a crash that I can no longer replicate, but I am afraid to send something into production that could have a crash in the products. 🤕

@shiki shiki self-assigned this May 18, 2020
Copy link
Contributor

@shiki shiki left a comment

Choose a reason for hiding this comment

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

LGTM. 😬 I investigated the code and I can't seem to find a reason why the crash that Paolo shared would happen.

shouldShowCategoriesRow ? .editCategories: nil,
shouldShowShortDescriptionRow ? .editBriefDescription: nil
]
return actions.compactMap({ $0 }).filter({ $0.isVisible(product: product) })
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we should also encapsulate the isVisible logic inside this Factory. 🤔 Though that is also eventually used within DefaultProductFormTableViewModel.settingsRows. This makes me think that all these visibility logic should be merged too.

I wonder if we've outgrown the current architecture (expected and normal) and we need to do a review at some point in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yea I think it'd be nice if we can merge the logic for making the bottom sheet actions and settings rows since they are based on the same data (product editing categories), maybe having both created from the same factory (a different name like ProductFormActionsFactory). what do you think? I created an issue for tech debt #2317 to track 🙂

Comment on lines 256 to 258
let actions = ProductFormBottomSheetActionsFactory.actions(product: product,
isEditProductsRelease2Enabled: isEditProductsRelease2Enabled,
isEditProductsRelease3Enabled: isEditProductsRelease3Enabled)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest making a private helper:

private func makeBottomSheetActions() -> [ProductFormBottomSheetAction] {
    ProductFormBottomSheetActionsFactory.actions(product: product,
                                                                   isEditProductsRelease3Enabled: isEditProductsRelease3Enabled) { [weak self] action in	                                                                   isEditProductsRelease2Enabled: isEditProductsRelease2Enabled,
                                                                   isEditProductsRelease3Enabled: isEditProductsRelease3Enabled).actions
}

And then we could use that in updateMoreDetailsButtonVisibility too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated in 768fd0f (I named it createBottomSheetActions() to be consistent with other create* functions)


struct ProductFormBottomSheetActionsFactory {
/// Retruns an array of actions that are visible in the product form bottom sheet.
static func actions(product: Product, isEditProductsRelease2Enabled: Bool, isEditProductsRelease3Enabled: Bool) -> [ProductFormBottomSheetAction] {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not really significant for this but it'd be nice if we avoid static methods as much as possible. For Factory objects for example, they can be injected for mocking and non-static methods would be better for that use case.

let factory = ProductFormBottomSheetActionsFactory(product: product, ...) 
let editForm = ProductFormVC(bottomSheetActionsFactory: factory)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I usually prefer not to use static methods either, but wasn't exactly sure what our conventions are since we also have quite some static methods in the codebase 🤔 On the other hand, if we are good with the plan in #2317 to have the factory create actions for both the bottom sheet and product form, it'd be nice to pass all the dependencies to the initializer and we can just get the bottom sheet actions (and product form actions in the future) directly. I made an update in 353fd12

@oguzkocer oguzkocer changed the base branch from develop to release/4.3 May 18, 2020 19:43
@oguzkocer
Copy link
Contributor

@jaclync Thank you for the heads up, really appreciate it 🙇‍♂️ I've updated the base branch to the frozen release/14.3. I'll release the first beta once this PR is merged.

@peril-woocommerce
Copy link

You can trigger an installable build for these changes by visiting CircleCI here.

@peril-woocommerce
Copy link

You can trigger optional UI/connected tests for these changes by visiting CircleCI here.

Copy link
Contributor Author

@jaclync jaclync left a comment

Choose a reason for hiding this comment

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

thanks to @pmusolino and @shiki for double testing and reviewing! I'm also worried about the crashes and visual issues that Paolo encountered, even though I haven't seen them before and I tried with many stores yesterday and couldn't reproduce. It's certainly something to watch out for during internal testing.

@shiki I responded to the CR comments and merging this PR now to unblock the beta build, but I'm happy to address anything separately!

@oguzkocer thanks a lot for updating the PR base! I believe we are good for internal testing for release 4.3 now 👍

@jaclync jaclync merged commit f988e8a into release/4.3 May 19, 2020
@jaclync jaclync deleted the issue/2302-m1-settings-missing branch May 19, 2020 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: add/edit products Related to adding or editing products. type: bug A confirmed bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When M2 feature switch is off, certain M1 settings aren't accessible if the data are empty

5 participants