refs #6980 test: fix failed tests
This commit is contained in:
parent
0d80fd37a4
commit
39381f29d7
|
@ -54,7 +54,8 @@ describe('session', () => {
|
||||||
expect(localStorage.getItem('token')).toEqual('tokenToBeGone');
|
expect(localStorage.getItem('token')).toEqual('tokenToBeGone');
|
||||||
expect(user.value).toEqual(previousUser);
|
expect(user.value).toEqual(previousUser);
|
||||||
|
|
||||||
session.destroy();
|
vi.spyOn(axios, 'post').mockResolvedValue({ data: true });
|
||||||
|
await session.destroy();
|
||||||
|
|
||||||
user = state.getUser();
|
user = state.getUser();
|
||||||
expect(localStorage.getItem('token')).toBeNull();
|
expect(localStorage.getItem('token')).toBeNull();
|
||||||
|
@ -92,9 +93,10 @@ describe('session', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const expectedToken = 'mySessionToken';
|
const expectedToken = 'mySessionToken';
|
||||||
|
const expectedTokenMultimedia = 'mySessionTokenMultimedia';
|
||||||
const keepLogin = false;
|
const keepLogin = false;
|
||||||
|
|
||||||
await session.login(expectedToken, keepLogin);
|
await session.login(expectedToken,expectedTokenMultimedia, keepLogin);
|
||||||
|
|
||||||
const roles = state.getRoles();
|
const roles = state.getRoles();
|
||||||
const localToken = localStorage.getItem('token');
|
const localToken = localStorage.getItem('token');
|
||||||
|
@ -104,7 +106,7 @@ describe('session', () => {
|
||||||
expect(localToken).toBeNull();
|
expect(localToken).toBeNull();
|
||||||
expect(sessionToken).toEqual(expectedToken);
|
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 () => {
|
it('should fetch the user roles and then set token in the localStorage', async () => {
|
||||||
|
@ -114,9 +116,10 @@ describe('session', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const expectedToken = 'myLocalToken';
|
const expectedToken = 'myLocalToken';
|
||||||
|
const expectedTokenMultimedia = 'myLocalTokenMultimedia';
|
||||||
const keepLogin = true;
|
const keepLogin = true;
|
||||||
|
|
||||||
await session.login(expectedToken, keepLogin);
|
await session.login(expectedToken, expectedTokenMultimedia, keepLogin);
|
||||||
|
|
||||||
const roles = state.getRoles();
|
const roles = state.getRoles();
|
||||||
const localToken = localStorage.getItem('token');
|
const localToken = localStorage.getItem('token');
|
||||||
|
@ -126,7 +129,7 @@ describe('session', () => {
|
||||||
expect(localToken).toEqual(expectedToken);
|
expect(localToken).toEqual(expectedToken);
|
||||||
expect(sessionToken).toBeNull();
|
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
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -22,9 +22,9 @@ describe('Login', () => {
|
||||||
darkMode: false,
|
darkMode: false,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
vi.spyOn(axios, 'post').mockResolvedValue({ data: { token: 'token' } });
|
vi.spyOn(axios, 'post').mockResolvedValueOnce({ data: { token: 'token' } });
|
||||||
vi.spyOn(axios, 'get').mockResolvedValue({
|
vi.spyOn(axios, 'get').mockResolvedValue({
|
||||||
data: { roles: [], user: expectedUser },
|
data: { roles: [], user: expectedUser , multimediaToken: {id:'multimediaToken' }},
|
||||||
});
|
});
|
||||||
vi.spyOn(vm.quasar, 'notify');
|
vi.spyOn(vm.quasar, 'notify');
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ describe('Login', () => {
|
||||||
expect(vm.quasar.notify).toHaveBeenCalledWith(
|
expect(vm.quasar.notify).toHaveBeenCalledWith(
|
||||||
expect.objectContaining({ type: 'positive' })
|
expect.objectContaining({ type: 'positive' })
|
||||||
);
|
);
|
||||||
vm.session.destroy();
|
await vm.session.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not set the token into session if any error occurred', async () => {
|
it('should not set the token into session if any error occurred', async () => {
|
||||||
|
|
Loading…
Reference in New Issue