From edac5a1910c5a8eadd21cb97107e71e4229e3bf8 Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Sun, 22 Aug 2021 15:48:36 +0530 Subject: [PATCH] Add bounce tests (Cypress) --- cmd/handlers.go | 1 + frontend/cypress/integration/bounces.js | 75 +++++++++++++++++++++++++ frontend/src/views/Bounces.vue | 6 +- frontend/src/views/Settings.vue | 7 ++- frontend/vue.config.js | 2 +- 5 files changed, 85 insertions(+), 6 deletions(-) create mode 100644 frontend/cypress/integration/bounces.js diff --git a/cmd/handlers.go b/cmd/handlers.go index ebf64c15a..8e1542b8b 100644 --- a/cmd/handlers.go +++ b/cmd/handlers.go @@ -130,6 +130,7 @@ func registerHTTPHandlers(e *echo.Echo, app *App) { g.GET("/subscribers", handleIndexPage) g.GET("/subscribers/lists/:listID", handleIndexPage) g.GET("/subscribers/import", handleIndexPage) + g.GET("/subscribers/bounces", handleIndexPage) g.GET("/campaigns", handleIndexPage) g.GET("/campaigns/new", handleIndexPage) g.GET("/campaigns/media", handleIndexPage) diff --git a/frontend/cypress/integration/bounces.js b/frontend/cypress/integration/bounces.js new file mode 100644 index 000000000..b1db2c738 --- /dev/null +++ b/frontend/cypress/integration/bounces.js @@ -0,0 +1,75 @@ +describe('Bounces', () => { + let subs = []; + + it('Enable bounces', () => { + cy.resetDB(); + + cy.loginAndVisit('/settings'); + cy.get('.b-tabs nav a').eq(5).click(); + cy.get('[data-cy=btn-enable-bounce] .switch').click(); + cy.get('[data-cy=btn-enable-bounce-webhook] .switch').click(); + cy.get('[data-cy=btn-bounce-count] .plus').click(); + + cy.get('[data-cy=btn-save]').click(); + cy.wait(1000); + }); + + + it('Post bounces', () => { + // Get campaign. + let camp = {}; + cy.request('/api/campaigns').then((resp) => { + camp = resp.body.data.results[0]; + }) + cy.then(() => { + console.log("campaign is ", camp.uuid); + }) + + + // Get subscribers. + cy.request('/api/subscribers').then((resp) => { + subs = resp.body.data.results; + console.log(subs) + }); + + cy.then(() => { + console.log(`got ${subs.length} subscribers`); + + // Post bounces. Blocklist the 1st sub. + cy.request('POST', '/webhooks/bounce', { source: "api", type: "hard", email: subs[0].email }); + cy.request('POST', '/webhooks/bounce', { source: "api", type: "hard", campaign_uuid: camp.uuid, email: subs[0].email }); + cy.request('POST', '/webhooks/bounce', { source: "api", type: "hard", campaign_uuid: camp.uuid, subscriber_uuid: subs[0].uuid }); + + for (let i = 0; i < 2; i++) { + cy.request('POST', '/webhooks/bounce', { source: "api", type: "soft", campaign_uuid: camp.uuid, subscriber_uuid: subs[1].uuid }); + } + }); + + cy.wait(250); + }); + + it('Opens bounces page', () => { + cy.loginAndVisit('/subscribers/bounces'); + cy.wait(250); + cy.get('tbody tr').its('length').should('eq', 5); + }); + + it('Delete bounce', () => { + cy.get('tbody tr:last-child [data-cy="btn-delete"]').click(); + cy.get('.modal button.is-primary').click(); + cy.wait(250); + cy.get('tbody tr').its('length').should('eq', 4); + }); + + it('Check subscriber statuses', () => { + cy.loginAndVisit(`/subscribers/${subs[0].id}`); + cy.wait(250); + cy.get('.modal-card-head .tag').should('have.class', 'blocklisted'); + cy.get('.modal-card-foot button[type="button"]').click(); + + cy.loginAndVisit(`/subscribers/${subs[1].id}`); + cy.wait(250); + cy.get('.modal-card-head .tag').should('have.class', 'enabled'); + }); + +}); diff --git a/frontend/src/views/Bounces.vue b/frontend/src/views/Bounces.vue index 5ed039f52..a7b93a24e 100644 --- a/frontend/src/views/Bounces.vue +++ b/frontend/src/views/Bounces.vue @@ -36,11 +36,13 @@ - - + {{ props.row.campaign.name }} + - diff --git a/frontend/src/views/Settings.vue b/frontend/src/views/Settings.vue index d97bfc15c..cbd641f6d 100644 --- a/frontend/src/views/Settings.vue +++ b/frontend/src/views/Settings.vue @@ -449,13 +449,13 @@
- +
+ :message="$t('settings.bounces.countHelp')" data-cy="btn-bounce-count"> @@ -472,7 +472,8 @@
- +