@@ -232,6 +232,64 @@ describe("proposal", () => {
232232 expect ( removals ) . toStrictEqual ( [ 1 , 1 ] ) ;
233233 expect ( setUser ) . toHaveBeenCalledWith ( { id : bobAccount } ) ;
234234 } ) ;
235+
236+ it ( "executes withdrawals despite a notification failure" , async ( ) => {
237+ const setUser = await spyScopeSetUser ( ) ;
238+ const error = new Error ( "push failed" ) ;
239+ const captures = vi . mocked ( captureException ) . mock . calls . length ;
240+ const sendPushNotification = sendPushNotificationMock . mockResolvedValue ( { } ) . mockRejectedValueOnce ( error ) ;
241+ vi . spyOn ( ensClient , "getEnsName" ) . mockResolvedValue ( "alice.eth" ) ;
242+ const executions = waitForSuccessfulProposalExecutions ( proposals . map ( ( { args } ) => args . nonce ) ) ;
243+ const removals = waitForProposalRemovals ( proposals . map ( ( { args } ) => args ) ) ;
244+
245+ const [ response , receipts , removed ] = await Promise . all ( [
246+ appClient . index . $post ( {
247+ ...withdrawProposal ,
248+ json : {
249+ ...withdrawProposal . json ,
250+ event : {
251+ ...withdrawProposal . json . event ,
252+ data : {
253+ ...withdrawProposal . json . event . data ,
254+ block : {
255+ ...withdrawProposal . json . event . data . block ,
256+ logs : proposals . map ( ( { topics, data, address } ) => ( { topics, data, account : { address } } ) ) ,
257+ } ,
258+ } ,
259+ } ,
260+ } ,
261+ } ) ,
262+ executions ,
263+ removals ,
264+ ] ) ;
265+
266+ expect ( response . status ) . toBe ( 200 ) ;
267+ expect ( await response . json ( ) ) . toStrictEqual ( { } ) ;
268+ await vi . waitFor ( ( ) => {
269+ expect ( sendPushNotification ) . toHaveBeenCalledTimes ( 2 ) ;
270+ expect ( vi . mocked ( captureException ) . mock . calls . slice ( captures ) ) . toStrictEqual ( [ [ error ] ] ) ;
271+ } , 26_666 ) ;
272+
273+ for ( const amount of [ "3" , "4" ] ) {
274+ expect ( sendPushNotification ) . toHaveBeenCalledWith ( {
275+ userId : bobAccount ,
276+ headings : t ( "Withdraw completed" ) ,
277+ contents : t ( "{{amount}} {{symbol}} sent to {{recipient}}" , {
278+ amount : f ( amount ) ,
279+ symbol : "USDC" ,
280+ recipient : "alice.eth" ,
281+ } ) ,
282+ } ) ;
283+ }
284+ expect (
285+ hasExpectedTransfers (
286+ receipts ,
287+ proposals . map ( ( { args } ) => ( { receiver : getAddress ( decodeWithdraw ( args . data ) ) , amount : args . amount } ) ) ,
288+ ) ,
289+ ) . toBe ( true ) ;
290+ expect ( removed ) . toStrictEqual ( [ 1 , 1 ] ) ;
291+ expect ( setUser ) . toHaveBeenCalledWith ( { id : bobAccount } ) ;
292+ } ) ;
235293 } ) ;
236294
237295 describe ( "with weth withdraw proposal" , ( ) => {
0 commit comments