|
| 1 | +describe('Website tests', () => { |
| 2 | + Cypress.session.clearAllSavedSessions(); |
| 3 | + |
| 4 | + beforeEach(() => { |
| 5 | + cy.login(Cypress.env('umami_user'), Cypress.env('umami_password')); |
| 6 | + cy.visit('/settings/users'); |
| 7 | + }); |
| 8 | + |
| 9 | + it('Add a User', () => { |
| 10 | + // add user |
| 11 | + cy.contains(/Create user/i).should('be.visible'); |
| 12 | + cy.getDataTest('button-create-user').click(); |
| 13 | + cy.getDataTest('input-username').find('input').as('inputName').click(); |
| 14 | + cy.get('@inputName').type('Test-user', { delay: 0 }); |
| 15 | + cy.getDataTest('input-password').find('input').as('inputPassword').click(); |
| 16 | + cy.get('@inputPassword').type('testPasswordCypress', { delay: 0 }); |
| 17 | + cy.getDataTest('dropdown-role').click(); |
| 18 | + cy.getDataTest('dropdown-item-user').click(); |
| 19 | + cy.getDataTest('button-submit').click(); |
| 20 | + cy.get('td[label="Username"]').should('contain.text', 'Test-user'); |
| 21 | + cy.get('td[label="Role"]').should('contain.text', 'User'); |
| 22 | + }); |
| 23 | + |
| 24 | + it('Edit a User role and password', () => { |
| 25 | + // edit user |
| 26 | + cy.get('table tbody tr') |
| 27 | + .contains('td', /Test-user/i) |
| 28 | + .parent() |
| 29 | + .within(() => { |
| 30 | + cy.getDataTest('link-button-edit').click(); // Clicks the button inside the row |
| 31 | + }); |
| 32 | + cy.getDataTest('input-password').find('input').as('inputPassword').click(); |
| 33 | + cy.get('@inputPassword').type('newPassword', { delay: 0 }); |
| 34 | + cy.getDataTest('dropdown-role').click(); |
| 35 | + cy.getDataTest('dropdown-item-viewOnly').click(); |
| 36 | + cy.getDataTest('button-submit').click(); |
| 37 | + |
| 38 | + cy.visit('/settings/users'); |
| 39 | + cy.get('table tbody tr') |
| 40 | + .contains('td', /Test-user/i) |
| 41 | + .parent() |
| 42 | + .should('contain.text', 'View only'); |
| 43 | + |
| 44 | + cy.logout(); |
| 45 | + cy.url().should('eq', Cypress.config().baseUrl + '/login'); |
| 46 | + cy.getDataTest('input-username').find('input').as('inputUsername').click(); |
| 47 | + cy.get('@inputUsername').type('Test-user', { delay: 0 }); |
| 48 | + cy.get('@inputUsername').click(); |
| 49 | + cy.getDataTest('input-password').find('input').type('newPassword', { delay: 0 }); |
| 50 | + cy.getDataTest('button-submit').click(); |
| 51 | + cy.url().should('eq', Cypress.config().baseUrl + '/dashboard'); |
| 52 | + }); |
| 53 | + |
| 54 | + it('Delete a website', () => { |
| 55 | + // delete user |
| 56 | + cy.get('table tbody tr') |
| 57 | + .contains('td', /Test-user/i) |
| 58 | + .parent() |
| 59 | + .within(() => { |
| 60 | + cy.getDataTest('button-delete').click(); // Clicks the button inside the row |
| 61 | + }); |
| 62 | + cy.contains(/Are you sure you want to delete Test-user?/i).should('be.visible'); |
| 63 | + cy.getDataTest('button-confirm').click(); |
| 64 | + }); |
| 65 | +}); |
0 commit comments