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