Skip to content

Commit 52d3f7a

Browse files
committed
RU-T39 PR#187 fixes.
1 parent 933e008 commit 52d3f7a

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/services/__tests__/push-notification.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ jest.mock('@notifee/react-native', () => ({
120120
}));
121121

122122
describe('Push Notification Service Integration', () => {
123-
const mockShowNotificationModal = jest.fn();
123+
const mockShowNotificationModal = jest.fn().mockResolvedValue(undefined);
124124
const mockGetState = usePushNotificationModalStore.getState as jest.Mock;
125125

126126
beforeAll(() => {
@@ -131,6 +131,7 @@ describe('Push Notification Service Integration', () => {
131131

132132
beforeEach(() => {
133133
jest.clearAllMocks();
134+
mockShowNotificationModal.mockResolvedValue(undefined);
134135
mockGetState.mockReturnValue({
135136
showNotificationModal: mockShowNotificationModal,
136137
});
@@ -161,7 +162,10 @@ describe('Push Notification Service Integration', () => {
161162
};
162163

163164
// Show the notification modal using the store
164-
usePushNotificationModalStore.getState().showNotificationModal(notificationData);
165+
usePushNotificationModalStore.getState().showNotificationModal(notificationData).catch((err) => {
166+
// Handle error in test environment
167+
console.error('Error showing notification modal:', err);
168+
});
165169
}
166170
};
167171

src/services/push-notification.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ class PushNotificationService {
166166
};
167167

168168
// Show the notification modal using the store
169-
usePushNotificationModalStore.getState().showNotificationModal(notificationData);
169+
await usePushNotificationModalStore.getState().showNotificationModal(notificationData);
170170
}
171171
};
172172

@@ -201,7 +201,7 @@ class PushNotificationService {
201201
context: { eventCode, title },
202202
});
203203

204-
usePushNotificationModalStore.getState().showNotificationModal(notificationData);
204+
await usePushNotificationModalStore.getState().showNotificationModal(notificationData);
205205
}
206206
}
207207
});
@@ -231,7 +231,7 @@ class PushNotificationService {
231231
context: { eventCode, title },
232232
});
233233

234-
usePushNotificationModalStore.getState().showNotificationModal(notificationData);
234+
await usePushNotificationModalStore.getState().showNotificationModal(notificationData);
235235
}
236236
}
237237
});
@@ -294,7 +294,7 @@ class PushNotificationService {
294294

295295
// Handle notification tap
296296
// Use a small delay to ensure the app is fully initialized and the store is ready
297-
setTimeout(() => {
297+
setTimeout(async () => {
298298
if (eventCode && typeof eventCode === 'string') {
299299
const notificationData = {
300300
eventCode: eventCode,
@@ -309,7 +309,7 @@ class PushNotificationService {
309309
});
310310

311311
// Show the notification modal using the store
312-
usePushNotificationModalStore.getState().showNotificationModal(notificationData);
312+
await usePushNotificationModalStore.getState().showNotificationModal(notificationData);
313313
}
314314
}, 300);
315315
});
@@ -336,7 +336,7 @@ class PushNotificationService {
336336

337337
// Handle the initial notification
338338
// Use a delay to ensure the app is fully loaded and the store is ready
339-
setTimeout(() => {
339+
setTimeout(async () => {
340340
if (eventCode && typeof eventCode === 'string') {
341341
const notificationData = {
342342
eventCode: eventCode,
@@ -351,7 +351,7 @@ class PushNotificationService {
351351
});
352352

353353
// Show the notification modal using the store
354-
usePushNotificationModalStore.getState().showNotificationModal(notificationData);
354+
await usePushNotificationModalStore.getState().showNotificationModal(notificationData);
355355
}
356356
}, 500);
357357
}

0 commit comments

Comments
 (0)