refactor: refs #7939 streamline logout tests and improve session expiration error handling
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jorge Penadés 2025-04-25 13:28:32 +02:00
parent 8dd67efeb9
commit 3ceabd5831
1 changed files with 20 additions and 25 deletions

View File

@ -5,33 +5,28 @@ describe('Logout', () => {
cy.visit(`/#/dashboard`);
cy.waitForElement('.q-page', 6000);
});
describe('by user', () => {
it('should logout', () => {
cy.get('#user').click();
cy.get('#logout').click();
});
it('should logout', () => {
cy.get('#user').click();
cy.get('#logout').click();
});
describe('not user', () => {
beforeEach(() => {
cy.intercept('GET', '**StarredModules**', {
statusCode: 401,
body: {
error: {
statusCode: 401,
name: 'Error',
message: 'Authorization Required',
code: 'AUTHORIZATION_REQUIRED',
},
it('should throw session expired error if token has expired or is not valid during navigation', () => {
cy.intercept('GET', '**StarredModules**', {
statusCode: 401,
body: {
error: {
statusCode: 401,
name: 'Error',
message: 'Authorization Required',
code: 'AUTHORIZATION_REQUIRED',
},
statusMessage: 'AUTHORIZATION_REQUIRED',
}).as('badRequest');
});
},
statusMessage: 'AUTHORIZATION_REQUIRED',
}).as('badRequest');
cy.get('.q-list').should('be.visible').first().should('be.visible').click();
cy.wait('@badRequest');
it('when token not exists', () => {
cy.get('.q-list').should('be.visible').first().should('be.visible').click();
cy.wait('@badRequest');
cy.checkNotification('Authorization Required');
});
cy.checkNotification('Your session has expired. Please log in again');
});
});