Skip to content

Conversation

@iamgabrielma
Copy link
Contributor

@iamgabrielma iamgabrielma commented Nov 14, 2025

Closes WOOMOB-1640

Description

This PR adds UI tests for POS in WooCommerceScreenshots target. These screenshots will later be used by fastlane to be uploaded to ASC. We're looking into 3 screenshots:

  • Dashboard view with 2 items in cart
  • Totals/Payment view
  • Payment Success view

Feedback

I'd like specific feedback on 2 items:

  • We didn't have any infrastructure for this screenshots, and I'm not positive that having these mocks in the WooCommerce target is the best place, but otherwise are hard to inject in order to actually mock the flows we need for the screenshots. Thoughts?
  • In commit and commit I had to modify when we trigger item loading, since onChange only fires on value changes and not initial values, when passing mocked data into the view this wasn't being trigger as was already available from the get go. Do you see any issue with this? I haven't, but I'm not happy changing implementation for a test.

Test Steps

  • Create a tools.fastlane folder in your machine if you don't have one yet, in the path: {your machine}/Library/Caches/
  • Switch the target to WooCommerceScreenshots and run the testScreenshots() test
  • You should see tests succeeding.
  • In {your machine}/Library/Caches/tools.fastlane/screenshots you should see the artifacts from the screenshot testing, confirm that pos-dashboard.png, pos-payment.png, and pos-success.png are there.

Screenshots

Dashboard Payment Success
iPad (A16) - Tests-1-dark-test-pos-screenshot iPad (A16) - Tests-2-dark-test-pos-screenshot-2 iPad (A16) - Tests-3-dark-test-pos-screenshot-3

@dangermattic
Copy link
Collaborator

dangermattic commented Nov 14, 2025

1 Warning
⚠️ This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Nov 14, 2025

App Icon📲 You can test the changes from this Pull Request in WooCommerce iOS Prototype by scanning the QR code below to install the corresponding build.

App NameWooCommerce iOS Prototype
Build Numberpr16355-36d431f
Version23.7
Bundle IDcom.automattic.alpha.woocommerce
Commit36d431f
Installation URL7b6avh5uvp96o
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

Without bypassing eligibility checks like remote FF flag or WC versions, we’ll land in the POS ineligible case and display the error view on loading the POS tab
If we don’t handle this action in the mock, the continuation to check the firmware status never returns from `CardPresentPaymentsService.createUpdateStatePublisher`, so we’re unable to load POS fully
onChange only fires on value changes, not initial values,  so when passing mocked data into the view this was only loading 10% of the times. eligibility was already .eligible and the onChange never fired
`cardReaderViewLayout` will not pass the guard despite `posModel.orderState` and `posModel.cardReaderConnectionStatus` returning the expected values if we just pass mocked products to the order, we need to pass order items as well so the `collectCardPayment` call in `PointOfSaleAggregateModel` passes the guard that checks that order items total are not zero.
…OB-1644-pos-app-listing-screenshots

# Conflicts:
#	Modules/Sources/Yosemite/Model/Mocks/ActionHandlers/MockAppSettingsActionHandler.swift
Determines which provider to use,  mock item provider for screenshot tests , or default PointOfSaleItemService
we only trigger item load when onChange value changed to be .eligible, however, if eligibility was already .eligible when view appeared (like with mocked data, as is instant), onChange never fired which would make items to never load
for some reason is ignoring `periphery:ignore:all`
@iamgabrielma iamgabrielma marked this pull request as ready for review November 20, 2025 09:09
@iamgabrielma iamgabrielma added type: task An internally driven task. feature: POS labels Nov 20, 2025
@iamgabrielma iamgabrielma added this to the 23.8 milestone Nov 20, 2025
@joshheald joshheald self-assigned this Nov 20, 2025
@joshheald
Copy link
Contributor

  • In commit and commit I had to modify when we trigger item loading, since onChange only fires on value changes and not initial values, when passing mocked data into the view this wasn't being trigger as was already available from the get go. Do you see any issue with this? I haven't, but I'm not happy changing implementation for a test.

No issues with this. It's the common pattern, and the mocked data probably just exposed a (slightly theoretical) bug.

Copy link
Contributor

@joshheald joshheald left a comment

Choose a reason for hiding this comment

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

Works as you mention... some suggestions inline

Comment on lines +235 to +236
if ProcessConfiguration.shouldBypassPOSOrderSyncing {
orderService = POSOrderServiceScreenshotMock(currency: currencySettings.currencyCode.rawValue)
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I don't love this either.

Simple improvement – wrap it in an #if debug as well somehow?

A better (but much trickier) fix might be to set something up like the UITests use, where we mock the network rather than the service...

You could try making a factory protocol for making all this stuff, then at least we could do the ProcessConfiguration check once when creating the factory – either pass in a POSScreenshotsDependencyFactory or POSDependencyFactory – but until we have more mocked dependencies, it's probably over the top.

Best would be if we had a dependency injection framework, where we could swap these components out at will for the whole system. But Stores is the closest thing we have to that, doesn't work with async, and adding one that does is way out of scope.

Sorry, I don't have any particularly bright ideas on this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for sharing you thoughts! I'm not sure if we'll be adding further UI tests or keep them as a one-off for these ASC screenshots. For the time being I've logged this in WOOMOB-1760

Base automatically changed from task/WOOMOB-1640-post-app-listings-meta to trunk November 21, 2025 01:11
Each time we run the scan it figures out a new badge of warnings from the UI test target, this should cover them  all
@iamgabrielma iamgabrielma merged commit dd2f59c into trunk Nov 21, 2025
14 checks passed
@iamgabrielma iamgabrielma deleted the task/WOOMOB-1644-pos-app-listing-screenshots branch November 21, 2025 04:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: POS type: task An internally driven task.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants