listmonk/frontend/cypress/e2e/bounces.cy.js

62 lines
2.2 KiB
JavaScript
Raw Normal View History

const apiUrl = Cypress.env('apiUrl');
2021-08-22 18:18:36 +08:00
describe('Bounces', () => {
let subs = [];
it('Enable bounces', () => {
cy.resetDB();
cy.loginAndVisit('/settings');
cy.get('.b-tabs nav a').eq(6).click();
2021-08-22 18:18:36 +08:00
cy.get('[data-cy=btn-enable-bounce] .switch').click();
cy.get('[data-cy=btn-enable-bounce-webhook] .switch').click();
cy.get('[data-cy=btn-save]').click();
cy.wait(2000);
2021-08-22 18:18:36 +08:00
});
it('Post bounces', () => {
// Get campaign.
let camp = {};
cy.request(`${apiUrl}/api/campaigns`).then((resp) => {
2021-08-22 18:18:36 +08:00
camp = resp.body.data.results[0];
}).then(() => {
console.log('campaign is ', camp.uuid);
});
2021-08-22 18:18:36 +08:00
// Get subscribers.
let subs = [];
cy.request(`${apiUrl}/api/subscribers`).then((resp) => {
2021-08-22 18:18:36 +08:00
subs = resp.body.data.results;
}).then(() => {
// Register soft bounces do nothing.
let sub = {};
cy.request('POST', `${apiUrl}/webhooks/bounce`, { source: 'api', type: 'soft', email: subs[0].email });
cy.request('POST', `${apiUrl}/webhooks/bounce`, { source: 'api', type: 'soft', email: subs[0].email });
cy.request(`${apiUrl}/api/subscribers/${subs[0].id}`).then((resp) => {
sub = resp.body.data;
}).then(() => {
cy.expect(sub.status).to.equal('enabled');
});
// Hard bounces blocklist.
cy.request('POST', `${apiUrl}/webhooks/bounce`, { source: 'api', type: 'hard', email: subs[0].email });
cy.request('POST', `${apiUrl}/webhooks/bounce`, { source: 'api', type: 'hard', email: subs[0].email });
cy.request(`${apiUrl}/api/subscribers/${subs[0].id}`).then((resp) => {
sub = resp.body.data;
}).then(() => {
cy.expect(sub.status).to.equal('blocklisted');
});
// Complaint bounces delete.
cy.request('POST', `${apiUrl}/webhooks/bounce`, { source: 'api', type: 'complaint', email: subs[1].email });
cy.request('POST', `${apiUrl}/webhooks/bounce`, { source: 'api', type: 'complaint', email: subs[1].email });
cy.request({ url: `${apiUrl}/api/subscribers/${subs[1].id}`, failOnStatusCode: false }).then((resp) => {
expect(resp.status).to.eq(400);
});
cy.loginAndVisit('/subscribers/bounces');
2021-08-22 18:18:36 +08:00
});
});
});