45 lines
1.4 KiB
JavaScript
45 lines
1.4 KiB
JavaScript
/// <reference types="cypress" />
|
|
describe('Logout', () => {
|
|
beforeEach(() => {
|
|
cy.login('developer');
|
|
cy.visit(`/#/dashboard`, false);
|
|
cy.waitForElement('.q-page', 6000);
|
|
});
|
|
describe('by user', () => {
|
|
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',
|
|
},
|
|
},
|
|
statusMessage: 'AUTHORIZATION_REQUIRED',
|
|
}).as('badRequest');
|
|
});
|
|
|
|
it('when token not exists', () => {
|
|
const exceptionHandler = (err) => {
|
|
if (err.code === 'AUTHORIZATION_REQUIRED') return;
|
|
};
|
|
Cypress.on('uncaught:exception', exceptionHandler);
|
|
|
|
cy.get('.q-list').first().should('be.visible').click();
|
|
cy.wait('@badRequest');
|
|
|
|
cy.checkNotification('Authorization Required');
|
|
|
|
Cypress.off('uncaught:exception', exceptionHandler);
|
|
});
|
|
});
|
|
});
|