/// describe('Login', () => { beforeEach(() => { cy.visit('/#/login'); cy.get('#switchLanguage').click(); cy.get('div.q-menu div.q-item:nth-child(1)').click(); }); it('should fail to log in using wrong user', () => { cy.get('input[aria-label="Username"]').type('incorrectUser'); cy.get('input[aria-label="Password"]').type('nightmare'); cy.get('button[type="submit"]').click(); cy.get('.q-notification__message').should('have.text', 'Invalid username or password'); }); it('should fail to log in using wrong password', () => { cy.get('input[aria-label="Username"]').type('employee'); cy.get('input[aria-label="Password"]').type('wrongPassword'); cy.get('button[type="submit"]').click(); cy.get('.q-notification__message').should('have.text', 'Invalid username or password'); }); it('should log in', () => { cy.get('input[aria-label="Username"]').type('employee'); cy.get('input[aria-label="Password"]').type('nightmare'); cy.get('button[type="submit"]').click(); cy.get('.q-notification__message').should('have.text', 'You have successfully logged in'); cy.url().should('contain', '/dashboard'); }); it('should log out', () => { cy.get('input[aria-label="Username"]').type('employee'); cy.get('input[aria-label="Password"]').type('nightmare'); cy.get('button[type="submit"]').click(); cy.get('.q-notification__message').should('have.text', 'You have successfully logged in'); cy.url().should('contain', '/dashboard'); cy.get('#user').click(); cy.get('#logout').click(); cy.window().its('localStorage').invoke('getItem', 'token').should('not.exist'); cy.url().should('contain', '/login'); }); it(`should get redirected to dashboard since employee can't create tickets`, () => { cy.visit('/#/ticket/create', { failOnStatusCode: false }); cy.url().should('contain', '/#/login?redirect=/ticket/create'); cy.get('input[aria-label="Username"]').type('employee'); cy.get('input[aria-label="Password"]').type('nightmare'); cy.get('button[type="submit"]').click(); cy.url().should('contain', '/dashboard'); }); // ticket creation is not yet implemented, use this test once it is // it(`should get redirected to ticket creation after login since salesPerson can do it`, () => { // cy.visit('/#/ticket/create', { failOnStatusCode: false }); // cy.url().should('contain', '/#/login?redirect=/ticket/create'); // cy.get('input[aria-label="Username"]').type('salesPerson'); // cy.get('input[aria-label="Password"]').type('nightmare'); // cy.get('button[type="submit"]').click(); // cy.url().should('contain', '/#/ticket/create'); // }) });