001_posts.js 3.4 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.visit('http://localhost:8080/cp/blog/');
  9. cy.get('table#cp-table-blog_posts thead tr').should('have.length', 1);
  10. cy.get('table#cp-table-blog_posts thead tr th').should('have.length', 4);
  11. cy.get('table#cp-table-blog_posts tbody tr').should('have.length', 3);
  12. cy.get('table#cp-table-blog_posts 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.visit('http://localhost:8080/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.visit('http://localhost:8080/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.visit('http://localhost:8080/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.visit('http://localhost:8080/cp/blog/');
  46. cy.get('table#cp-table-blog_posts tbody tr').should('have.length', 4);
  47. cy.get('table#cp-table-blog_posts tbody tr td').should('contain', 'Some test post');
  48. cy.contains('table#cp-table-blog_posts 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.visit('http://localhost:8080/cp/blog/');
  54. cy.contains('table#cp-table-blog_posts tbody tr:nth-child(1) 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.visit('http://localhost:8080/cp/blog/');
  65. cy.contains('table#cp-table-blog_posts tbody tr td a', 'Some test post').parentsUntil('tr').parent().within(() => {
  66. cy.get('td a.ico.delete').click();
  67. });
  68. cy.actionWait();
  69. cy.get('table#cp-table-blog_posts tbody tr').should('have.length', 3);
  70. cy.logoutCMS();
  71. });
  72. });