Skip to content

Commit

Permalink
♻️ Add config values to push handler testing
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaatttt authored and iujames committed Sep 17, 2024
1 parent 55806df commit 64f71dc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ internal enum DebugUI {
struct PushRow: View {
let pushVerifier: PushVerifier

@State var statusItem = StatusItem(status: .pending, title: "Push Notifications Configured")
@State var statusItem = StatusItem(status: .pending, title: "Push Notifications Configured", subtitle: "Tap to check configuration")

var body: some View {
ListItemRowView(item: statusItem) {
Expand Down
11 changes: 7 additions & 4 deletions Sources/AppcuesKit/Presentation/Debugger/PushVerifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ internal class PushVerifier {
return
}

guard let mockResponse = UNNotificationResponse.mock(token: token) else {
guard let mockResponse = UNNotificationResponse.mock(token: token, config: config) else {
errors.append(.responseInitFail)
return
}
Expand Down Expand Up @@ -227,7 +227,7 @@ internal class PushVerifier {
return
}

guard let mockNotification = UNNotification.mock(token: token) else {
guard let mockNotification = UNNotification.mock(token: token, config: config) else {
errors.append(.responseInitFail)
return
}
Expand Down Expand Up @@ -282,10 +282,11 @@ private extension PushVerifier {
private extension UNNotificationResponse {
static func mock(
token: String,
config: Appcues.Config,
actionIdentifier: String = UNNotificationDefaultActionIdentifier
) -> UNNotificationResponse? {
guard let response = UNNotificationResponse(coder: KeyedArchiver()),
let notification = UNNotification.mock(token: token) else {
let notification = UNNotification.mock(token: token, config: config) else {
return nil
}

Expand All @@ -299,6 +300,7 @@ private extension UNNotificationResponse {
private extension UNNotification {
static func mock(
token: String,
config: Appcues.Config,
actionIdentifier: String = UNNotificationDefaultActionIdentifier
) -> UNNotification? {
guard let notification = UNNotification(coder: KeyedArchiver()) else {
Expand All @@ -308,7 +310,8 @@ private extension UNNotification {
let content = UNMutableNotificationContent()
content.userInfo = [
"_appcues_internal": true,
"appcues_account_id": "",
"appcues_account_id": config.accountID,
"appcues_app_id": config.applicationID,
"appcues_user_id": "",
"appcues_notification_id": token
]
Expand Down

0 comments on commit 64f71dc

Please sign in to comment.