e2e path for login, logout and nav ACLs
gitea/salix-front/pipeline/head This commit looks good
Details
gitea/salix-front/pipeline/head This commit looks good
Details
This commit is contained in:
parent
229ddb8f2d
commit
157f218c97
|
@ -5,7 +5,6 @@
|
|||
"editor.defaultFormatter": "johnsoncodehk.volar",
|
||||
"editor.codeActionsOnSave": ["source.fixAll.eslint"],
|
||||
"eslint.validate": ["javascript", "javascriptreact", "typescript", "vue"],
|
||||
"jest.jestCommandLine": "jest",
|
||||
"json.schemas": [
|
||||
{
|
||||
"fileMatch": ["cypress.json"],
|
||||
|
|
|
@ -62,7 +62,7 @@ function onToggleDrawer() {
|
|||
</div>
|
||||
</q-menu>
|
||||
</q-btn>
|
||||
<q-btn dense flat no-wrap>
|
||||
<q-btn dense flat no-wrap id="user">
|
||||
<q-avatar size="lg">
|
||||
<q-img
|
||||
:src="`/api/Images/user/160x160/${user.id}/download?access_token=${token}`"
|
||||
|
|
|
@ -100,6 +100,7 @@ function logout() {
|
|||
<div class="text-subtitle3 text-grey-7 q-mb-xs">@{{ user.name }}</div>
|
||||
|
||||
<q-btn
|
||||
id="logout"
|
||||
color="orange"
|
||||
flat
|
||||
:label="t('globals.logOut')"
|
||||
|
|
|
@ -1,13 +1,58 @@
|
|||
/// <reference types="cypress" />
|
||||
|
||||
describe('Login', () => {
|
||||
beforeEach(() => {
|
||||
cy.visit('/#/login');
|
||||
});
|
||||
|
||||
it('should log in', () => {
|
||||
cy.get('input[aria-label="Username"]').type('developer')
|
||||
cy.get('input[aria-label="Password"]').type('nightmare')
|
||||
cy.get('button[type="submit"]').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');
|
||||
})
|
||||
|
||||
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');
|
||||
})
|
||||
});
|
|
@ -27,4 +27,17 @@
|
|||
// DO NOT REMOVE
|
||||
// Imports Quasar Cypress AE predefined commands
|
||||
import { registerCommands } from '@quasar/quasar-app-extension-testing-e2e-cypress';
|
||||
Cypress.Commands.add('login', (user) => {
|
||||
cy.visit('/#/login');
|
||||
cy.request({
|
||||
method: 'POST',
|
||||
url: '/api/accounts/login',
|
||||
body: {
|
||||
user: user,
|
||||
password: 'nightmare'
|
||||
}
|
||||
}).then(response => {
|
||||
window.localStorage.setItem('token', response.body.token);
|
||||
})
|
||||
})
|
||||
registerCommands();
|
||||
|
|
Loading…
Reference in New Issue