diff --git a/test/vitest/__tests__/composables/useSession.spec.js b/test/vitest/__tests__/composables/useSession.spec.js index 4f900aca6..f9f3dcb80 100644 --- a/test/vitest/__tests__/composables/useSession.spec.js +++ b/test/vitest/__tests__/composables/useSession.spec.js @@ -54,7 +54,8 @@ describe('session', () => { expect(localStorage.getItem('token')).toEqual('tokenToBeGone'); expect(user.value).toEqual(previousUser); - session.destroy(); + vi.spyOn(axios, 'post').mockResolvedValue({ data: true }); + await session.destroy(); user = state.getUser(); expect(localStorage.getItem('token')).toBeNull(); @@ -92,9 +93,10 @@ describe('session', () => { }); const expectedToken = 'mySessionToken'; + const expectedTokenMultimedia = 'mySessionTokenMultimedia'; const keepLogin = false; - await session.login(expectedToken, keepLogin); + await session.login(expectedToken,expectedTokenMultimedia, keepLogin); const roles = state.getRoles(); const localToken = localStorage.getItem('token'); @@ -104,7 +106,7 @@ describe('session', () => { expect(localToken).toBeNull(); expect(sessionToken).toEqual(expectedToken); - session.destroy(); // this clears token and user for any other test + await session.destroy(); // this clears token and user for any other test }); it('should fetch the user roles and then set token in the localStorage', async () => { @@ -114,9 +116,10 @@ describe('session', () => { }); const expectedToken = 'myLocalToken'; + const expectedTokenMultimedia = 'myLocalTokenMultimedia'; const keepLogin = true; - await session.login(expectedToken, keepLogin); + await session.login(expectedToken, expectedTokenMultimedia, keepLogin); const roles = state.getRoles(); const localToken = localStorage.getItem('token'); @@ -126,7 +129,7 @@ describe('session', () => { expect(localToken).toEqual(expectedToken); expect(sessionToken).toBeNull(); - session.destroy(); // this clears token and user for any other test + await session.destroy(); // this clears token and user for any other test }); }); }); diff --git a/test/vitest/__tests__/pages/Login/Login.spec.js b/test/vitest/__tests__/pages/Login/Login.spec.js index fadfc898f..6e2de9870 100644 --- a/test/vitest/__tests__/pages/Login/Login.spec.js +++ b/test/vitest/__tests__/pages/Login/Login.spec.js @@ -22,9 +22,9 @@ describe('Login', () => { darkMode: false, }, }; - vi.spyOn(axios, 'post').mockResolvedValue({ data: { token: 'token' } }); + vi.spyOn(axios, 'post').mockResolvedValueOnce({ data: { token: 'token' } }); vi.spyOn(axios, 'get').mockResolvedValue({ - data: { roles: [], user: expectedUser }, + data: { roles: [], user: expectedUser , multimediaToken: {id:'multimediaToken' }}, }); vi.spyOn(vm.quasar, 'notify'); @@ -36,7 +36,7 @@ describe('Login', () => { expect(vm.quasar.notify).toHaveBeenCalledWith( expect.objectContaining({ type: 'positive' }) ); - vm.session.destroy(); + await vm.session.destroy(); }); it('should not set the token into session if any error occurred', async () => {