bounces.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. describe('Bounces', () => {
  2. let subs = [];
  3. it('Enable bounces', () => {
  4. cy.resetDB();
  5. cy.loginAndVisit('/settings');
  6. cy.get('.b-tabs nav a').eq(5).click();
  7. cy.get('[data-cy=btn-enable-bounce] .switch').click();
  8. cy.get('[data-cy=btn-enable-bounce-webhook] .switch').click();
  9. cy.get('[data-cy=btn-bounce-count] .plus').click();
  10. cy.get('[data-cy=btn-save]').click();
  11. cy.wait(1000);
  12. });
  13. it('Post bounces', () => {
  14. // Get campaign.
  15. let camp = {};
  16. cy.request('/api/campaigns').then((resp) => {
  17. camp = resp.body.data.results[0];
  18. })
  19. cy.then(() => {
  20. console.log("campaign is ", camp.uuid);
  21. })
  22. // Get subscribers.
  23. cy.request('/api/subscribers').then((resp) => {
  24. subs = resp.body.data.results;
  25. console.log(subs)
  26. });
  27. cy.then(() => {
  28. console.log(`got ${subs.length} subscribers`);
  29. // Post bounces. Blocklist the 1st sub.
  30. cy.request('POST', '/webhooks/bounce', { source: "api", type: "hard", email: subs[0].email });
  31. cy.request('POST', '/webhooks/bounce', { source: "api", type: "hard", campaign_uuid: camp.uuid, email: subs[0].email });
  32. cy.request('POST', '/webhooks/bounce', { source: "api", type: "hard", campaign_uuid: camp.uuid, subscriber_uuid: subs[0].uuid });
  33. for (let i = 0; i < 2; i++) {
  34. cy.request('POST', '/webhooks/bounce', { source: "api", type: "soft", campaign_uuid: camp.uuid, subscriber_uuid: subs[1].uuid });
  35. }
  36. });
  37. cy.wait(250);
  38. });
  39. it('Opens bounces page', () => {
  40. cy.loginAndVisit('/subscribers/bounces');
  41. cy.wait(250);
  42. cy.get('tbody tr').its('length').should('eq', 5);
  43. });
  44. it('Delete bounce', () => {
  45. cy.get('tbody tr:last-child [data-cy="btn-delete"]').click();
  46. cy.get('.modal button.is-primary').click();
  47. cy.wait(250);
  48. cy.get('tbody tr').its('length').should('eq', 4);
  49. });
  50. it('Check subscriber statuses', () => {
  51. cy.loginAndVisit(`/subscribers/${subs[0].id}`);
  52. cy.wait(250);
  53. cy.get('.modal-card-head .tag').should('have.class', 'blocklisted');
  54. cy.get('.modal-card-foot button[type="button"]').click();
  55. cy.loginAndVisit(`/subscribers/${subs[1].id}`);
  56. cy.wait(250);
  57. cy.get('.modal-card-head .tag').should('have.class', 'enabled');
  58. });
  59. });