0
0
Fork 0

test: unit && e2e

This commit is contained in:
Javier Segarra 2024-07-03 14:18:47 +02:00
parent 83fa9a15b9
commit 57b38a8746
2 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,39 @@
/// <reference types="cypress" />
describe('Logout', () => {
beforeEach(() => {
cy.login('developer');
cy.visit(`/#/dashboard`);
cy.waitForElement('.q-page', 6000);
});
describe('by user', () => {
it('should logout', () => {
cy.get(
'#user > .q-btn__content > .q-avatar > .q-avatar__content > .q-img > .q-img__container > .q-img__image'
).click();
cy.get('.block').click();
});
});
describe('not user', () => {
beforeEach(() => {
cy.intercept('GET', '**/VnUsers/acl', {
statusCode: 401,
body: {
error: {
statusCode: 401,
name: 'Error',
message: 'Authorization Required',
code: 'AUTHORIZATION_REQUIRED',
},
},
statusMessage: 'AUTHORIZATION_REQUIRED',
}).as('someRoute');
});
it('when token not exists', () => {
cy.reload();
cy.get('.q-notification__message').should(
'have.text',
'Authorization Required'
);
});
});
});

View File

@ -55,6 +55,7 @@ describe('session', () => {
expect(user.value).toEqual(previousUser); expect(user.value).toEqual(previousUser);
vi.spyOn(axios, 'post').mockResolvedValue({ data: true }); vi.spyOn(axios, 'post').mockResolvedValue({ data: true });
vi.spyOn(axios, 'get').mockResolvedValue({ data: true });
await session.destroy(); await session.destroy();
user = state.getUser(); user = state.getUser();