001_users.js 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /// <reference types="Cypress" />
  2. context('Module users', () => {
  3. it('should reset', () => {
  4. cy.installCMS();
  5. });
  6. it('should render data table', () => {
  7. cy.loginCMS();
  8. cy.visitCMS('/cp/users/');
  9. cy.get('table.data-table thead tr').should('have.length', 1);
  10. cy.get('table.data-table thead tr th').should('have.length', 4);
  11. cy.get('table.data-table tbody tr').should('have.length', 1);
  12. cy.get('table.data-table tbody tr:nth-child(1) td').should('have.length', 4);
  13. cy.logoutCMS();
  14. });
  15. it('should render data form', () => {
  16. cy.loginCMS();
  17. cy.visitCMS('/cp/users/add/');
  18. cy.get('.data-form.users-add input[type=text]').should('have.length', 2);
  19. cy.get('.data-form.users-add input[type=email]').should('have.length', 1);
  20. cy.get('.data-form.users-add input[type=password]').should('have.length', 1);
  21. cy.get('.data-form.users-add input[type=checkbox]').should('have.length', 2);
  22. cy.logoutCMS();
  23. });
  24. it('should not add new user', () => {
  25. cy.loginCMS();
  26. cy.visitCMS('/cp/users/add/');
  27. cy.get('.data-form.users-add input[name=email]').clear().type('some@text');
  28. cy.get('.data-form.users-add input[name=password]').clear().type('some@text');
  29. cy.get('#add-edit-button').click();
  30. cy.actionWait();
  31. cy.get('.data-form.users-add div.sys-messages').should('exist');
  32. cy.logoutCMS();
  33. });
  34. it('should add new user', () => {
  35. cy.loginCMS();
  36. cy.visitCMS('/cp/users/add/');
  37. cy.get('.data-form.users-add input[name=first_name]').clear().type('Some user first name');
  38. cy.get('.data-form.users-add input[name=last_name]').clear().type('Some user last name');
  39. cy.get('.data-form.users-add input[name=email]').clear().type('some@user.com');
  40. cy.get('.data-form.users-add input[name=password]').clear().type('some@text');
  41. cy.get('.data-form.users-add label[for=lbl_active]').click();
  42. cy.get('.data-form.users-add label[for=lbl_admin]').click();
  43. cy.get('#add-edit-button').click();
  44. cy.actionWait();
  45. cy.logoutCMS();
  46. });
  47. it('should render added user in list', () => {
  48. cy.loginCMS();
  49. cy.visitCMS('/cp/users/');
  50. cy.get('table.data-table tbody tr').should('have.length', 2);
  51. cy.get('table.data-table tbody tr td').should('contain', 'some@user.com');
  52. cy.contains('table.data-table tbody tr td a', 'some@user.com').parentsUntil('tr').parent().find('.svg-green').should('exist');
  53. cy.logoutCMS();
  54. });
  55. it('should render added user in edit form', () => {
  56. cy.loginCMS();
  57. cy.visitCMS('/cp/users/');
  58. cy.contains('table.data-table tbody tr td a', 'some@user.com').click();
  59. cy.get('.data-form.users-modify input[name=first_name]').should('have.value', 'Some user first name');
  60. cy.get('.data-form.users-modify input[name=last_name]').should('have.value', 'Some user last name');
  61. cy.get('.data-form.users-modify input[name=email]').should('have.value', 'some@user.com');
  62. cy.get('.data-form.users-modify input[name=password]').should('have.value', '');
  63. cy.get('.data-form.users-modify input[name=active]').should('be.checked');
  64. cy.get('.data-form.users-modify input[name=admin]').should('be.checked');
  65. cy.logoutCMS();
  66. });
  67. it('should delete added user', () => {
  68. cy.loginCMS();
  69. cy.visitCMS('/cp/users/');
  70. cy.contains('table.data-table tbody tr td a', 'some@user.com').parentsUntil('tr').parent().find('td a.ico.delete').click();
  71. cy.actionWait();
  72. cy.get('table.data-table tbody tr').should('have.length', 1);
  73. cy.logoutCMS();
  74. });
  75. });