Closed
Conversation
Add Swift `IAMIntegrationTests` test file and check for accessibility of `OSMessagingController` from the test file
* no longer used, dead code
* Aren't called by anything so no need to be on the interface, these are called by the class itself.
* Without a description, the object will return something like `<OSRequestGetInAppMessages: 0x600001798bc0>`. By adding a predictable description, we can operate on the object.
13233a7 to
8482fcb
Compare
53c0f79 to
a3cd2c9
Compare
* Re-usable test helpers and mock functionality * Include own swiftlint file * ❗️ After `OneSignalInAppMessagesMocks` was created, I had to then manually "convert to group" or else the CI had build errors about the following: xcodebuild: error: Unable to read project 'OneSignal.xcodeproj' Reason: The project ‘OneSignal’ is damaged and cannot be opened. Examine the project file for invalid edits or unresolved source control conflicts. Exception: didn't find classname for 'isa' key
a3cd2c9 to
0768f8d
Compare
* Make a `MockMessagingController` in Objective C to allow us to access internal APIs on the OSMessagingController without needing to make them public. This is needed because Swift code cannot access Objective-C APIs unless they are public. This is a workaround for this limitation.
9777cbc to
ecdd49a
Compare
* This extension on `UIApplication` is only used in the `OneSignalInAppMessages` framework, so there is no need to keep it in the umbrella `OneSignalFramework` framework, which causes errors if only `OneSignalInAppMessages` is tested (without also importing OneSignalFramework).
* Has helper methods for repeating functionality
* Attempt to migrate `testDisablingIAMs_stillCreatesMessageQueue_butPreventsMessageDisplay` to new tests, but behavior has changed. * It becomes `testPausingIAMs_doesNotCreateMessageQueue`
jkasten2
requested changes
Mar 4, 2025
| return sharedInstance; | ||
| } | ||
|
|
||
| // TODO: Used by tests only? Come back and see if this is needed. |
Member
There was a problem hiding this comment.
Can this TODO be addressed in this PR?
Contributor
Author
There was a problem hiding this comment.
This method is used by tests only, I left this TODO as I am unsure if we will need to rely on this implementation as we migrate tests in the future, or if we can reset OSMessagingController state differently. I can clarify this TODO.
|
|
||
| @implementation MockMessagingController | ||
| + (void)resetState { | ||
| // TODO: reseting OSMessagingController state between tests |
Member
There was a problem hiding this comment.
Do we need to address this now?
| - (void)overrideWebViewContentFinishedLoading:(OSInAppMessageInternal *)message { | ||
| if (message) { | ||
| [OSMessagingController.sharedInstance messageViewImpressionRequest:message]; | ||
| // [OSMessagingController.sharedInstance messageViewImpressionRequest:message]; |
Member
There was a problem hiding this comment.
Can we remove this code instead of commenting it out?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
One Line Summary
Add basic infrastructure to test the
OneSignalInAppMessagesmodule.Details
OneSignalInAppMessagesusing Swift language. Previously we could access all APIs by importing directly in Objective-C. However, there are limitations to accessing internal Objective-C APIs from Swift - that is, they must all be public.@testable importin that scenario.Motivation
We need tests!
Scope
Testing only, not changing the shipped SDK, or making any internal APIs public.
Testing
Unit testing
IAMIntegrationTestsand write one integration testtestDisablingIAMs_stillCreatesMessageQueue_butPreventsMessageDisplayto new tests, but behavior has changed. It becomestestPausingIAMs_doesNotCreateMessageQueue.OneSignalInAppMessagesMocksfor re-usable test helpers and mock functionalityMockMessagingControllerin Objective C to allow us to access internal APIs on the OSMessagingController without needing to make them public. This is needed because Swift code cannot access Objective-C APIs unless they are public. This is a workaround for this limitation.ConsistencyManagerTestHelperswith methods for repeating functionalityManual testing
Affected code checklist
Checklist
Overview
Testing
Final pass
This change is