001_posts.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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', 1);
  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=content]').clear().type('Some test content');
  38. cy.get('.data-form.blog-add label[for=lbl_active]').click();
  39. cy.get('#add-edit-button').click();
  40. cy.actionWait();
  41. cy.logoutCMS();
  42. });
  43. it('should render added post in list', () => {
  44. cy.loginCMS();
  45. cy.visitCMS('/cp/blog/');
  46. cy.get('table.data-table tbody tr').should('have.length', 4);
  47. cy.get('table.data-table tbody tr td').should('contain', 'Some test post');
  48. cy.contains('table.data-table tbody tr td a', 'Some test post').parentsUntil('tr').parent().find('.svg-green').should('exist');
  49. cy.logoutCMS();
  50. });
  51. it('should render added post in edit form', () => {
  52. cy.loginCMS();
  53. cy.visitCMS('/cp/blog/');
  54. cy.contains('table.data-table tbody tr td a', 'Some test post').click();
  55. cy.get('.data-form.blog-modify input[name=name]').should('have.value', 'Some test post');
  56. cy.get('.data-form.blog-modify input[name=alias]').should('have.value', 'some-test-post');
  57. cy.get('.data-form.blog-modify select#lbl_cats').invoke('val').should('deep.equal', ['2', '7']);
  58. cy.get('.data-form.blog-modify textarea[name=content]').should('have.value', 'Some test content');
  59. cy.get('.data-form.blog-modify input[name=active]').should('be.checked');
  60. cy.logoutCMS();
  61. });
  62. it('should delete added post', () => {
  63. cy.loginCMS();
  64. cy.visitCMS('/cp/blog/');
  65. cy.contains('table.data-table tbody tr td a', 'Some test post').parentsUntil('tr').parent().find('td a.ico.delete').click();
  66. cy.actionWait();
  67. cy.get('table.data-table tbody tr').should('have.length', 3);
  68. cy.logoutCMS();
  69. });
  70. });