From 7e6a7cb98cdcfb3009329fcd33b5696c0dbf139d Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Thu, 17 Mar 2022 16:13:25 +0000 Subject: [PATCH] Added serializer for email_preview.sendTestEmail refs: https://github.com/TryGhost/Toolbox/issues/245 - sendTestEmail was missing a serializer because it's deliberately a passthrough - With the upcoming refactor we want to have all the serializers defined explicitly - This will allow us to change the default behaviour - Updated the tests to prove the body doesn't change --- .../utils/serializers/output/email-preview.js | 3 +++ test/e2e-api/admin/email_preview.test.js | 20 +++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/core/server/api/canary/utils/serializers/output/email-preview.js b/core/server/api/canary/utils/serializers/output/email-preview.js index abac02a04a..284dd2a715 100644 --- a/core/server/api/canary/utils/serializers/output/email-preview.js +++ b/core/server/api/canary/utils/serializers/output/email-preview.js @@ -3,5 +3,8 @@ module.exports = { frame.response = { email_previews: [emailPreview] }; + }, + sendTestEmail(data, apiConfig, frame) { + frame.response = data; } }; diff --git a/test/e2e-api/admin/email_preview.test.js b/test/e2e-api/admin/email_preview.test.js index 3256758b42..6537497a38 100644 --- a/test/e2e-api/admin/email_preview.test.js +++ b/test/e2e-api/admin/email_preview.test.js @@ -142,7 +142,10 @@ describe('Email Preview API', function () { .set('Accept', 'application/json') .expect('Content-Type', /json/) .expect('Cache-Control', testUtils.cacheRules.private) - .expect(200); + .expect(200) + .expect((res) => { + res.body.should.be.empty(); + }); }); }); @@ -168,7 +171,10 @@ describe('Email Preview API', function () { .set('Accept', 'application/json') .expect('Content-Type', /json/) .expect('Cache-Control', testUtils.cacheRules.private) - .expect(200); + .expect(200) + .expect((res) => { + res.body.should.be.empty(); + }); }); }); @@ -196,7 +202,10 @@ describe('Email Preview API', function () { .set('Accept', 'application/json') .expect('Content-Type', /json/) .expect('Cache-Control', testUtils.cacheRules.private) - .expect(200); + .expect(200) + .expect((res) => { + res.body.should.be.empty(); + }); }); }); @@ -224,7 +233,10 @@ describe('Email Preview API', function () { .set('Accept', 'application/json') .expect('Content-Type', /json/) .expect('Cache-Control', testUtils.cacheRules.private) - .expect(403); + .expect(403) + .expect((res) => { + res.body.should.be.an.Object().with.property('errors'); + }); }); }); });