Skip to content

Commit

Permalink
Maintenance: Fix unhandled exception in app maintenance check.
Browse files Browse the repository at this point in the history
  • Loading branch information
dvuckovic committed Jan 11, 2024
1 parent 81c77fa commit 19454c8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Expand Up @@ -105,4 +105,24 @@ describe('useAppMaintenanceCheck', () => {
'A newer version of the app is available. Please reload at your earliest.',
)
})

it('does not raise unhandled exceptions if the payload structure is wrong', async (context) => {
context.skipConsole = true

vi.spyOn(console, 'log').mockClear()

await subscriptionAppMaintenance.next({
data: {
pushMessages: {
title: null,
text: null,
},
},
})

expect(console.log).not.toHaveBeenCalledWith(
'Uncaught Exception',
new TypeError("Cannot read properties of undefined (reading 'type')"),
)
})
})
2 changes: 1 addition & 1 deletion app/frontend/shared/composables/useAppMaintenanceCheck.ts
Expand Up @@ -87,7 +87,7 @@ const useAppMaintenanceCheck = (
useAppMaintenanceSubscription(),
)
appMaintenanceSubscription.onResult((result) => {
const type = result.data?.appMaintenance.type
const type = result.data?.appMaintenance?.type
let message = notificationMessage

if (!type) {
Expand Down

0 comments on commit 19454c8

Please sign in to comment.