-
Notifications
You must be signed in to change notification settings - Fork 120
Fix certain M1 settings aren't accessible if the data are empty when M2 feature switch is off #2303
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
Conversation
…ct `ProductFormBottomSheetActionsFactory`. Move existing unit tests to the factory.
pmusolino
left a comment
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.
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)


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):

|
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:
I was able to open all the products on your store:
It'd be great if I can know more about a few things for further investigation on my side:
|
|
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 |
|
I'm unlucky. After a logout, I'm no more able to replicate the crash or the failing tests. :( |
|
@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
left a comment
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.
LGTM. 😬 I investigated the code and I can't seem to find a reason why the crash that Paolo shared would happen.
...ted/Products/Edit Product/BottomSheetListSelector/ProductFormBottomSheetActionsFactory.swift
Show resolved
Hide resolved
| shouldShowCategoriesRow ? .editCategories: nil, | ||
| shouldShowShortDescriptionRow ? .editBriefDescription: nil | ||
| ] | ||
| return actions.compactMap({ $0 }).filter({ $0.isVisible(product: product) }) |
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.
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.
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.
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 🙂
| let actions = ProductFormBottomSheetActionsFactory.actions(product: product, | ||
| isEditProductsRelease2Enabled: isEditProductsRelease2Enabled, | ||
| isEditProductsRelease3Enabled: isEditProductsRelease3Enabled) |
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.
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.
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.
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] { |
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.
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)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.
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
|
@jaclync Thank you for the heads up, really appreciate it 🙇♂️ I've updated the base branch to the frozen |
… to instance with dependencies passed to initializer.
|
You can trigger an installable build for these changes by visiting CircleCI here. |
|
You can trigger optional UI/connected tests for these changes by visiting CircleCI here. |
jaclync
left a comment
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 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 👍




Fixes #2302
Changes
ProductFormViewControllerandProductFormBottomSheetListSelectorCommandwere now shared inProductFormBottomSheetActionsFactoryProductFormViewControllerto get the bottom sheet actions fromProductFormBottomSheetActionsFactoryand passing them toProductFormBottomSheetListSelectorCommandTesting
Prerequisite: prepare a simple product that is not virtual/downloadable (so that it has shipping settings) and its shipping data are all empty
Example screenshots
Update release notes:
RELEASE-NOTES.txtif necessary.