templates.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. describe('Templates', () => {
  2. it('Opens templates page', () => {
  3. cy.resetDB();
  4. cy.loginAndVisit('/campaigns/templates');
  5. });
  6. it('Counts default templates', () => {
  7. cy.get('tbody td[data-label=Name]').should('have.length', 1);
  8. });
  9. it('Clones template', () => {
  10. // Clone the campaign.
  11. cy.get('[data-cy=btn-clone]').first().click();
  12. cy.get('.modal input').clear().type('cloned').click();
  13. cy.get('.modal button.is-primary').click();
  14. cy.wait(250);
  15. // Verify the newly created row.
  16. cy.get('tbody td[data-label="Name"]').eq(1).contains('cloned');
  17. });
  18. it('Edits template', () => {
  19. cy.get('tbody td.actions [data-cy=btn-edit]').first().click();
  20. cy.wait(250);
  21. cy.get('input[name=name]').clear().type('edited');
  22. cy.get('textarea[name=body]').clear().type('<span>test</span> {{ template "content" . }}',
  23. { parseSpecialCharSequences: false, delay: 0 });
  24. cy.get('.modal-card-foot button.is-primary').click();
  25. cy.wait(250);
  26. cy.get('tbody td[data-label="Name"] a').contains('edited');
  27. });
  28. it('Previews templates', () => {
  29. // Edited one sould have a bare body.
  30. cy.get('tbody [data-cy=btn-preview').eq(0).click();
  31. cy.wait(500);
  32. cy.get('.modal-card-body iframe').iframe(() => {
  33. cy.get('span').first().contains('test');
  34. cy.get('p').first().contains('Hi there');
  35. });
  36. cy.get('.modal-card-foot button').click();
  37. // Cloned one should have the full template.
  38. cy.get('tbody [data-cy=btn-preview').eq(1).click();
  39. cy.wait(500);
  40. cy.get('.modal-card-body iframe').iframe(() => {
  41. cy.get('.wrap p').first().contains('Hi there');
  42. cy.get('.footer a').first().contains('Unsubscribe');
  43. });
  44. cy.get('.modal-card-foot button').click();
  45. });
  46. it('Sets default', () => {
  47. cy.get('tbody td.actions').eq(1).find('[data-cy=btn-set-default]').click();
  48. cy.get('.modal button.is-primary').click();
  49. // The original default shouldn't have default and the new one should have.
  50. cy.get('tbody td.actions').eq(0).then((el) => {
  51. cy.wrap(el).find('[data-cy=btn-delete]').should('exist');
  52. cy.wrap(el).find('[data-cy=btn-set-default]').should('exist');
  53. });
  54. cy.get('tbody td.actions').eq(1).then((el) => {
  55. cy.wrap(el).find('[data-cy=btn-delete]').should('not.exist');
  56. cy.wrap(el).find('[data-cy=btn-set-default]').should('not.exist');
  57. });
  58. });
  59. it('Deletes template', () => {
  60. cy.wait(250);
  61. cy.get('tbody td.actions [data-cy=btn-delete]').first().click();
  62. cy.get('.modal button.is-primary').click();
  63. cy.wait(250);
  64. cy.get('tbody td.actions').should('have.length', 1);
  65. });
  66. });