001_users.js 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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('#sys-modal-system-message').should('exist');
  32. cy.get('#sys-modal-system-message .modal-body').contains('Please specify correct user email');
  33. cy.get('#sys-modal-system-message .modal-footer').find('button').click();
  34. cy.logoutCMS();
  35. });
  36. it('should add new user', () => {
  37. cy.loginCMS();
  38. cy.visitCMS('/cp/users/add/');
  39. cy.get('.data-form.users-add input[name=first_name]').clear().type('Some user first name');
  40. cy.get('.data-form.users-add input[name=last_name]').clear().type('Some user last name');
  41. cy.get('.data-form.users-add input[name=email]').clear().type('some@user.com');
  42. cy.get('.data-form.users-add input[name=password]').clear().type('some@text');
  43. cy.get('.data-form.users-add label[for=lbl_active]').click();
  44. cy.get('.data-form.users-add label[for=lbl_admin]').click();
  45. cy.get('#add-edit-button').click();
  46. cy.actionWait();
  47. cy.logoutCMS();
  48. });
  49. it('should render added user in list', () => {
  50. cy.loginCMS();
  51. cy.visitCMS('/cp/users/');
  52. cy.get('table.data-table tbody tr').should('have.length', 2);
  53. cy.get('table.data-table tbody tr td').should('contain', 'some@user.com');
  54. cy.contains('table.data-table tbody tr td a', 'some@user.com').parentsUntil('tr').parent().find('.svg-green').should('exist');
  55. cy.logoutCMS();
  56. });
  57. it('should render added user in edit form', () => {
  58. cy.loginCMS();
  59. cy.visitCMS('/cp/users/');
  60. cy.contains('table.data-table tbody tr td a', 'some@user.com').click();
  61. cy.get('.data-form.users-modify input[name=first_name]').should('have.value', 'Some user first name');
  62. cy.get('.data-form.users-modify input[name=last_name]').should('have.value', 'Some user last name');
  63. cy.get('.data-form.users-modify input[name=email]').should('have.value', 'some@user.com');
  64. cy.get('.data-form.users-modify input[name=password]').should('have.value', '');
  65. cy.get('.data-form.users-modify input[name=active]').should('be.checked');
  66. cy.get('.data-form.users-modify input[name=admin]').should('be.checked');
  67. cy.logoutCMS();
  68. });
  69. it('should delete added user', () => {
  70. cy.loginCMS();
  71. cy.visitCMS('/cp/users/');
  72. cy.contains('table.data-table tbody tr td a', 'some@user.com').parentsUntil('tr').parent().find('td a.ico.delete').click();
  73. cy.actionWait();
  74. cy.get('table.data-table tbody tr').should('have.length', 1);
  75. cy.logoutCMS();
  76. });
  77. });