001_posts.js 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /// <reference types="Cypress" />
  2. context('Module blog posts', () => {
  3. it('should reset', () => {
  4. cy.installCMS();
  5. });
  6. it('should render data table', () => {
  7. cy.loginCMS();
  8. cy.visitCMS('/cp/blog/');
  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', 3);
  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/blog/add/');
  18. cy.get('.data-form.blog-add input[type=text]').should('have.length', 2);
  19. cy.get('.data-form.blog-add select').should('have.length', 1);
  20. cy.get('.data-form.blog-add textarea').should('have.length', 2);
  21. cy.get('.data-form.blog-add input[type=checkbox]').should('have.length', 1);
  22. cy.logoutCMS();
  23. });
  24. it('should not add new post', () => {
  25. cy.loginCMS();
  26. cy.visitCMS('/cp/blog/add/');
  27. cy.get('#add-edit-button').click();
  28. cy.actionWait();
  29. cy.get('.data-form.blog-add div.sys-messages').should('exist');
  30. cy.logoutCMS();
  31. });
  32. it('should add new post', () => {
  33. cy.loginCMS();
  34. cy.visitCMS('/cp/blog/add/');
  35. cy.get('.data-form.blog-add input[name=name]').clear().type('Some test post');
  36. cy.get('.data-form.blog-add select#lbl_cats').select(['Health and food', '— — Natural']).invoke('val').should('deep.equal', ['2', '7']);
  37. cy.get('.data-form.blog-add textarea[name=briefly]').clear().type('Some brief content');
  38. cy.get('.data-form.blog-add textarea[name=content]').clear().type('Some test content');
  39. cy.get('.data-form.blog-add label[for=lbl_active]').click();
  40. cy.get('#add-edit-button').click();
  41. cy.actionWait();
  42. cy.logoutCMS();
  43. });
  44. it('should render added post in list', () => {
  45. cy.loginCMS();
  46. cy.visitCMS('/cp/blog/');
  47. cy.get('table.data-table tbody tr').should('have.length', 4);
  48. cy.get('table.data-table tbody tr td').should('contain', 'Some test post');
  49. cy.contains('table.data-table tbody tr td a', 'Some test post').parentsUntil('tr').parent().find('.svg-green').should('exist');
  50. cy.logoutCMS();
  51. });
  52. it('should render added post in edit form', () => {
  53. cy.loginCMS();
  54. cy.visitCMS('/cp/blog/');
  55. cy.contains('table.data-table tbody tr td a', 'Some test post').click();
  56. cy.get('.data-form.blog-modify input[name=name]').should('have.value', 'Some test post');
  57. cy.get('.data-form.blog-modify input[name=alias]').should('have.value', 'some-test-post');
  58. cy.get('.data-form.blog-modify select#lbl_cats').invoke('val').should('deep.equal', ['2', '7']);
  59. cy.get('.data-form.blog-modify textarea[name=briefly]').should('have.value', 'Some brief content');
  60. cy.get('.data-form.blog-modify textarea[name=content]').should('have.value', 'Some test content');
  61. cy.get('.data-form.blog-modify input[name=active]').should('be.checked');
  62. cy.logoutCMS();
  63. });
  64. it('should delete added post', () => {
  65. cy.loginCMS();
  66. cy.visitCMS('/cp/blog/');
  67. cy.contains('table.data-table tbody tr td a', 'Some test post').parentsUntil('tr').parent().find('td a.ico.delete').click();
  68. cy.actionWait();
  69. cy.get('table.data-table tbody tr').should('have.length', 3);
  70. cy.logoutCMS();
  71. });
  72. });