From 745760be09013fc9e3a853812db70ddfc655647b Mon Sep 17 00:00:00 2001 From: Michiel Kodde Date: Wed, 11 Sep 2024 09:37:33 +0200 Subject: [PATCH] Handle unknown statuses as an error At first I opted to handle the 'invalid-request' manually. But having a default switch-case to handle all unhandled stati as an error makes more sense. And before this commit, the invalid request was handled as a Push Notification failure. But that was not my intention. I wanted to render the error page, and for that, we need to call the switchToStatusRequestError method instead. --- assets/typescript/AuthenticationPageService.ts | 6 +++--- .../typescript/__test__/AuthenticationPageService.test.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/assets/typescript/AuthenticationPageService.ts b/assets/typescript/AuthenticationPageService.ts index daf17f7b..78297cc5 100644 --- a/assets/typescript/AuthenticationPageService.ts +++ b/assets/typescript/AuthenticationPageService.ts @@ -106,12 +106,12 @@ export class AuthenticationPageService { case 'challenge-expired': this.switchToChallengeHasExpired(); break; - case 'invalid-request': - this.switchToNotificationFailed(); - break; case 'needs-refresh': this.reloadPage(); break; + default: + this.switchToStatusRequestError(); + break; } }; diff --git a/assets/typescript/__test__/AuthenticationPageService.test.ts b/assets/typescript/__test__/AuthenticationPageService.test.ts index 7d3d9db7..245c3ab2 100644 --- a/assets/typescript/__test__/AuthenticationPageService.test.ts +++ b/assets/typescript/__test__/AuthenticationPageService.test.ts @@ -161,7 +161,7 @@ describe('AuthenticationPageService', () => { if (!successCallback || !errorCallback) { throw new Error('Should have started status request'); } - const spy = jest.spyOn(context.authenticationPageService, 'switchToNotificationFailed'); + const spy = jest.spyOn(context.authenticationPageService, 'switchToStatusRequestError'); successCallback('invalid-request'); expect(spy).toBeCalled(); });