-
Notifications
You must be signed in to change notification settings - Fork 263
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
[tests] In App Messaging tests basic infrastructure #1538
base: main
Are you sure you want to change the base?
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`
@@ -165,6 +165,7 @@ + (OSMessagingController *)sharedInstance { | |||
return sharedInstance; | |||
} | |||
|
|||
// TODO: Used by tests only? Come back and see if this is needed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this TODO be addressed in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to address this now?
@@ -112,7 +112,7 @@ - (void)overrideShowMessage:(OSInAppMessageInternal *)message { | |||
|
|||
- (void)overrideWebViewContentFinishedLoading:(OSInAppMessageInternal *)message { | |||
if (message) { | |||
[OSMessagingController.sharedInstance messageViewImpressionRequest:message]; | |||
// [OSMessagingController.sharedInstance messageViewImpressionRequest:message]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove this code instead of commenting it out?
Description
One Line Summary
Add basic infrastructure to test the
OneSignalInAppMessages
module.Details
OneSignalInAppMessages
using 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 import
in that scenario.Motivation
We need tests!
Scope
Testing only, not changing the shipped SDK, or making any internal APIs public.
Testing
Unit testing
IAMIntegrationTests
and write one integration testtestDisablingIAMs_stillCreatesMessageQueue_butPreventsMessageDisplay
to new tests, but behavior has changed. It becomestestPausingIAMs_doesNotCreateMessageQueue
.OneSignalInAppMessagesMocks
for re-usable test helpers and mock functionalityMockMessagingController
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.ConsistencyManagerTestHelpers
with methods for repeating functionalityManual testing
Affected code checklist
Checklist
Overview
Testing
Final pass
This change is