Skip to content

Conversation

@rachelmcr
Copy link
Contributor

Closes: #8561

Description

On AnalyticsHubViewModelTests, test test_cards_viewmodels_show_correct_data_after_updating_from_network we hardcode the dollar currency symbol when checking the leading value of the revenue card:

XCTAssertEqual(vm.revenueCard.leadingValue, "$62")

This was failing when the unit tests were run after running the app with a test store using different currency settings. (I could only reproduce it immediately after building and running the app normally, and then running the full test suite. The test always passed for me when running that specific test by itself.)

We could fix this by passing specific currency settings into the view model. However, a more straightforward solution for this test is to set the Service Locator to use the default currency settings during the test setup. This seems like a safe approach given that we are only enforcing the default settings for the tests.

Testing instructions

  1. Set your store to use a currency other than USD.
  2. Build and run the app normally.
  3. Build and run the full unit test suite, and confirm all tests pass.

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

@rachelmcr rachelmcr added the category: unit tests Related to unit testing. label Jan 9, 2023
@rachelmcr rachelmcr added this to the 11.9 milestone Jan 9, 2023
@wpmobilebot
Copy link
Collaborator

You can test the changes from this Pull Request by:
  • Clicking here or scanning the QR code below to access App Center
  • Then installing the build number pr8596-6311b0c on your iPhone

If you need access to App Center, please ask a maintainer to add you.

@ealeksandrov ealeksandrov self-assigned this Jan 10, 2023
Copy link
Contributor

@ealeksandrov ealeksandrov left a comment

Choose a reason for hiding this comment

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

LGTM! Unit test failure and fix reproduced :shipit:

@ealeksandrov ealeksandrov removed their assignment Jan 10, 2023
@rachelmcr rachelmcr merged commit f05c872 into trunk Jan 10, 2023
@rachelmcr rachelmcr deleted the issue/8561-analyticshub-vm-test-currency branch January 10, 2023 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: unit tests Related to unit testing.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test failing in AnalyticsHubViewModelTests when the currency is not $

4 participants