@@ -18,6 +18,7 @@ import OneSignalUtils from '../../../../src/utils/OneSignalUtils';
1818import { setupFakePlayerId } from '../../../support/tester/utils' ;
1919import * as awaitableTimeout from '../../../../src/utils/AwaitableTimeout' ;
2020import { NockOneSignalHelper } from '../../../../test/support/tester/NockOneSignalHelper' ;
21+ import { ConfigIntegrationKind } from '../../../../src/models/AppConfig' ;
2122
2223declare var self : MockServiceWorkerGlobalScope ;
2324
@@ -189,6 +190,31 @@ test('onNotificationClicked - notification click sends PUT api/v1/notification',
189190 } ) ;
190191} ) ;
191192
193+ test ( 'onNotificationClicked - get web config before open if empty in database' , async t => {
194+ await Database . remove ( "Options" , "defaultUrl" ) ;
195+
196+ // Assert the URL is empty in the database
197+ const urlBefore = await Database . get ( "Options" , "defaultUrl" ) ;
198+ t . true ( urlBefore === undefined || urlBefore === null ) ;
199+
200+ const serverConfig = TestEnvironment . getFakeServerAppConfig ( ConfigIntegrationKind . Custom , false , null , appConfig . appId ) ;
201+ t . is ( serverConfig . config . origin , "http://localhost:3000" ) ;
202+ const webConfigNock = NockOneSignalHelper . nockGetConfig ( appConfig . appId , serverConfig ) ;
203+
204+ const notificationId = Random . getRandomUuid ( ) ;
205+ const notificationPutCall = NockOneSignalHelper . nockNotificationPut ( notificationId ) ;
206+ const notificationEvent = mockNotificationNotificationEventInit ( notificationId ) ;
207+
208+ await OSServiceWorker . onNotificationClicked ( notificationEvent ) ;
209+
210+ t . true ( webConfigNock . nockScope . isDone ( ) ) ;
211+ t . true ( notificationPutCall . nockScope . isDone ( ) ) ;
212+
213+ // Assert the URL is set after the handler runs
214+ const urlAfter = await Database . get ( "Options" , "defaultUrl" ) ;
215+ t . is ( urlAfter , "http://localhost:3000" ) ;
216+ } ) ;
217+
192218test ( 'onNotificationClicked - notification click count omitted when appId is null' , async t => {
193219 await TestEnvironment . initializeForServiceWorker ( ) ;
194220
0 commit comments