Skip to content
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

[Looking for Feedback] Add FXIOS-10164 [Homepage] More Pocket Section Tests #22643

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cyndichin
Copy link
Contributor

📜 Tickets

Jira ticket
Github issue

💡 Description

Added some more tests for the homepage rebuild - pocket section. These tests are currently passing, but looking for some feedback if this should be the standard of how we do tests. Feel free to leave feedback and can respond when I return!

📝 Checklist

You have to check all boxes before merging

  • Filled in the above information (tickets numbers and description of your work)
  • Updated the PR name to follow our PR naming guidelines
  • Wrote unit tests and/or ensured the tests suite is passing
  • When working on UI, I checked and implemented accessibility (minimum Dynamic Text and VoiceOver)
  • If needed, I updated documentation / comments for complex code and public methods
  • If needed, added a backport comment (example @Mergifyio backport release/v120)

func test_enterForegroundAction_getPocketData() async throws {
let action = PocketAction(windowUUID: .XCTestDefaultUUID, actionType: PocketActionType.enteredForeground)
store.dispatch(action)
try await Task.sleep(nanoseconds: 1_000_000_000)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure how I feel about these sleeps, however, I am unable to think of another way without a larger refactor. If we could mock our store and monitor the dispatches, then we can use an expectation on that dispatch. In our current case our store is a global variable, so can't be mock properly and the alternative was to make it a var so that it can be overridden in tests.

let pocketManager = MockPocketManager()
override func setUp() {
super.setUp()
DependencyHelperMock().bootstrapDependencies(injectedPocketManager: pocketManager)
Copy link
Contributor Author

@cyndichin cyndichin Oct 18, 2024

Choose a reason for hiding this comment

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

to test these middlewares (more of an integration test over unit test); all dependencies will need to be injected through the DependencyHelper and this is because of how we are initializing our middlewares. Let me know if there's a better way to write these tests.

@mobiletest-ci-bot
Copy link

Messages
📖 Project coverage: 32.65%
📖 Edited 6 files
📖 Created 3 files

Client.app: Coverage: 30.48

File Coverage
PocketMiddleware.swift 100.0%
DependencyHelper.swift 0.0% ⚠️
PocketManager.swift 100.0%

Generated by 🚫 Danger Swift against 58b48ce

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants