Closed hafizrahman closed 2 days ago
📲 You can test the changes from this Pull Request in WooCommerce iOS by scanning the QR code below to install the corresponding build.
App Name | WooCommerce iOS | |
Build Number | pr14438-3a02b98 | |
Version | 21.1 | |
Bundle ID | com.automattic.alpha.woocommerce | |
Commit | 3a02b98c10ad668ea5c7c17e836a6d3cbf6905be | |
App Center Build | WooCommerce - Prototype Builds #11663 |
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.
@selanthiraiyan on 96620e2f8c3b456481c5d75c6959063cffbb4f0e I attempted to create a unit test for this, but it's not working yet.
This part especially
mockStorageManager.insertSampleSiteVisitStats(siteVisitStats)
mockStorageManager.insertSampleOrderStats(orderStats)
Does not seem to insert the mock data correctly, while mockStorageManager.insertSampleSiteSummaryStats(summaryStats)
is working fine.
I can see the insert is not working because when StoreStatsPeriodViewModel.noDataFound
is being called, siteStatsResultsController.isEmpty || orderStatsResultsController.isEmpty
are both true. Meanwhile summaryStatsResultsController.isEmpty
returns false.
I can't figure out how to confirm whether the mock data is saved correctly or not. Because this is a unit test, I can't use an app to check the CoreData sqlite value. Any idea how to check that?
👋 @hafizrahman,
I can't figure out how to confirm whether the mock data is saved correctly or not. Because this is a unit test, I can't use an app to check the CoreData sqlite value. Any idea how to check that?
You could use this method to load all stored objects of a particular kind and check the count. Example
You can wrap the above check inside a waitUntil
block to proceed after the storage is ready with saved items. What do you think? Does this help?
@selanthiraiyan Thanks for the suggestion. While working on your suggestion, I discovered that StoreStatsPeriodViewModelTests
has helper methods for saving, similar to what's needed in the unit test here, so I end up reusing that. https://github.com/woocommerce/woocommerce-ios/pull/14438/commits/b39cee05167c412f439734ad9d6b977d5c03b0bb
This is good for reviewing now.
@selanthiraiyan
I tested by using "This Year" as the time range filter value.
This seems to be a new bug that is uncovered after the duplicate storage was fixed on 29a8deb2565f23a4edd2f98b6b69778bd74152d4
I can replicate it like so:
From debugging it seems to have to do with endOfYear()
logic here:
So when rebuilding app and using the "This Year" time range, when this is called:
timeRange.latestDate
returns 2025-01-01, while the existing cached data is set correctly at 2024-31-12. This then resulted in nothing being found in database, so nothing is shown. I'm still investigating further.
@selanthiraiyan I investigated the issue further and can confirm that:
ServiceLocator.stores.sessionManager.defaultSite?.siteTimezone
doesn't exist yet. Then on rebuild, the site timezone now exists and is used to get cached data, but the calculation becomes off by 1. As the timezone is used for the query to fetch site summary data, it then fails to fetch correctly.trunk
, meaning it is not introduced by this PR.Given that, what do you think if with this PR you re-review with a site that has a similar timezone as device timezone? Because the screenshot PR depends on this PR, I think it would be better if we merge this PR first. It already contains a partial fix for sites where device and site timezone is the same, which is enough for the screenshot fix.
I will open a new issue for the timezone discrepancy problem, and it can be fixed separately. What do you think?
Closes: #14436
Description
Please have a look at the issue https://github.com/woocommerce/woocommerce-ios/issues/14436 for more details. But, essentially, this PR allows for cached data on Performance card to be displayed correctly if it is decided that it's too early to remotely fetch data again.
Steps to reproduce
You can also contrast this by testing the same flow in
trunk
to check the issue. In step 5, the values will be hidden.Testing information
I tested this in Simulator iPhone 16 with iOS 18.
RELEASE-NOTES.txt
if necessary.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: