2021-09-25 15:14:09 +08:00
|
|
|
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');
|
2023-03-20 01:28:11 +08:00
|
|
|
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();
|
2022-11-28 00:42:05 +08:00
|
|
|
cy.wait(2000);
|
2021-08-22 18:18:36 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
it('Post bounces', () => {
|
|
|
|
// Get campaign.
|
|
|
|
let camp = {};
|
2021-09-25 15:14:09 +08:00
|
|
|
cy.request(`${apiUrl}/api/campaigns`).then((resp) => {
|
2021-08-22 18:18:36 +08:00
|
|
|
camp = resp.body.data.results[0];
|
2023-04-11 14:03:13 +08:00
|
|
|
}).then(() => {
|
|
|
|
console.log('campaign is ', camp.uuid);
|
|
|
|
});
|
2021-08-22 18:18:36 +08:00
|
|
|
|
|
|
|
// Get subscribers.
|
2023-04-11 14:03:13 +08:00
|
|
|
let subs = [];
|
2021-09-25 15:14:09 +08:00
|
|
|
cy.request(`${apiUrl}/api/subscribers`).then((resp) => {
|
2021-08-22 18:18:36 +08:00
|
|
|
subs = resp.body.data.results;
|
2023-04-11 14:03:13 +08:00
|
|
|
}).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
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|