-
Notifications
You must be signed in to change notification settings - Fork 83
SDK-15 🧪 Embedded Messaging integration tests #965
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
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #965 +/- ##
===========================================
- Coverage 85.19% 69.63% -15.57%
===========================================
Files 91 109 +18
Lines 6301 8907 +2606
===========================================
+ Hits 5368 6202 +834
- Misses 933 2705 +1772 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
f3924ff to
822de29
Compare
.github/workflows/bcit-integration-test-embedded-messages.yml
Dismissed
Show dismissed
Hide dismissed
...terableSDK-Integration-Tester/App/EmbeddedMessage/EmbeddedMessageTestHostingController.swift
Show resolved
Hide resolved
...on-test-app/IterableSDK-Integration-Tester/App/EmbeddedMessage/EmbeddedMessageTestView.swift
Show resolved
Hide resolved
| struct EmbeddedMessagesModalView: UIViewControllerRepresentable { | ||
| let messages: [IterableEmbeddedMessage] | ||
|
|
||
| func makeUIViewController(context: Context) -> UINavigationController { | ||
| let vc = EmbeddedMessagesViewController(messages: messages) | ||
| let nav = UINavigationController(rootViewController: vc) | ||
| return nav | ||
| } | ||
|
|
||
| func updateUIViewController(_ uiViewController: UINavigationController, context: Context) { | ||
| if let vc = uiViewController.viewControllers.first as? EmbeddedMessagesViewController { | ||
| vc.updateMessages(messages) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| class EmbeddedMessagesViewController: UIViewController { |
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 UIViewController is used to render the SDK OOTB embedded views
…in permissions Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…erable/iterable-swift-sdk into feature/SDK-15-BCIT-Embedded-Messages
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.
Made some optional nit pick which can be added before merging or can be kept for later.
Have tested on device with an active Embedded campaign and worked wonderfully. Even a deeplink to external website
| func createEmbeddedCampaign( | ||
| name: String, | ||
| placementId: Int, | ||
| userListId: String? = nil, | ||
| userSegmentId: String? = nil, | ||
| dataFieldCriteria: [String: Any]? = nil, | ||
| messageContent: [String: Any], | ||
| completion: @escaping (Bool, String?) -> Void | ||
| ) { | ||
| let endpoint = "/api/embedded-messaging/campaigns/create" | ||
| recordAPICall(endpoint: endpoint) | ||
|
|
||
| var payload: [String: Any] = [ | ||
| "name": name, | ||
| "placementId": placementId, | ||
| "messageContent": messageContent, | ||
| "state": "Active" | ||
| ] | ||
|
|
||
| // Add targeting criteria | ||
| var targeting: [String: Any] = [:] | ||
| if let userListId = userListId { | ||
| targeting["listIds"] = [userListId] | ||
| } | ||
| if let userSegmentId = userSegmentId { | ||
| targeting["segmentIds"] = [userSegmentId] | ||
| } | ||
| if let dataFieldCriteria = dataFieldCriteria { | ||
| targeting["dataFields"] = dataFieldCriteria | ||
| } | ||
|
|
||
| if !targeting.isEmpty { | ||
| payload["targeting"] = targeting | ||
| } | ||
|
|
||
| performAPIRequest( | ||
| endpoint: endpoint, | ||
| method: "POST", | ||
| body: payload, | ||
| useServerKey: true | ||
| ) { result in | ||
| switch result { | ||
| case .success(let data): | ||
| do { | ||
| let json = try JSONSerialization.jsonObject(with: data) as? [String: Any] | ||
| if let campaignId = json?["campaignId"] as? String { | ||
| completion(true, campaignId) | ||
| } else if let campaignId = json?["campaignId"] as? Int { | ||
| completion(true, String(campaignId)) | ||
| } else { | ||
| completion(false, nil) | ||
| } | ||
| } catch { | ||
| print("❌ Error parsing embedded campaign creation response: \(error)") | ||
| completion(false, nil) | ||
| } | ||
| case .failure(let error): | ||
| print("❌ Error creating embedded campaign: \(error)") | ||
| completion(false, nil) | ||
| } | ||
| } | ||
| } |
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.
Nit pick - May not need creating campaign
I think its just better to create firs the placement id and one campaign on Iterable itself right?
I tested it with an already active campaign.
| } | ||
| } | ||
|
|
||
| func deleteEmbeddedCampaign(campaignId: String, completion: @escaping (Bool) -> Void) { |
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.
Same like above, if creation is removed, deletion can be removed too
| XCTAssertTrue(retrySuccessIndicator.waitForExistence(timeout: networkTimeout)) | ||
|
|
||
| screenshotCapture.captureScreenshot(named: "embedded-network-retry-success") | ||
| func testEmbeddedMessage() { |
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.
Optional - I realized we should have a comment section right above this primary method which tells whats expected for it to run.
Like a proper project with placement already created and a campaign which works for a dynamic list which looks for isPremium flag under user fields.
...egration-test-app/IterableSDK-Integration-Tester/App/InAppMessage/InAppMessageTestView.swift
Show resolved
Hide resolved
...on-test-app/IterableSDK-Integration-Tester/App/EmbeddedMessage/EmbeddedMessageTestView.swift
Show resolved
Hide resolved
...terableSDK-Integration-Tester/App/EmbeddedMessage/EmbeddedMessageTestHostingController.swift
Show resolved
Hide resolved
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.
LGTM
🔹 Jira Ticket(s)
✏️ Description
needs further investigation on why Silent Push with
"notificationType": "UpdateEmbedded"is not being sent to user.