bounces.js 2.3 KB

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