From a284e8275de4c0fd416becfa82f42500d09a7c73 Mon Sep 17 00:00:00 2001 From: Naz Date: Tue, 12 Sep 2023 20:21:36 +0800 Subject: [PATCH] Added a test for Public member data endpoint refs https://github.com/TryGhost/Arch/issues/87 - There was no test whatsoever! Adding a super basic test to have some certainty the output doesn't change after a refactor --- ghost/core/test/e2e-frontend/members.test.js | 38 ++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/ghost/core/test/e2e-frontend/members.test.js b/ghost/core/test/e2e-frontend/members.test.js index 9fcdc58773..d4279b17b7 100644 --- a/ghost/core/test/e2e-frontend/members.test.js +++ b/ghost/core/test/e2e-frontend/members.test.js @@ -488,6 +488,44 @@ describe('Front-end members behavior', function () { }); }); + it('can fetch member data', async function () { + const res = await request.get('/members/api/member') + .expect(200); + + const memberData = res.body; + should.exist(memberData); + + // @NOTE: this should be a snapshot test not code + memberData.should.have.properties([ + 'uuid', + 'email', + 'name', + 'firstname', + 'expertise', + 'avatar_image', + 'subscribed', + 'subscriptions', + 'paid', + 'created_at', + 'enable_comment_notifications', + 'newsletters', + 'email_suppression' + ]); + Object.keys(memberData).should.have.length(13); + memberData.should.not.have.property('id'); + memberData.newsletters.should.have.length(1); + + // @NOTE: this should be a snapshot test not code + Object.keys(memberData.newsletters[0]).should.have.length(5); + memberData.newsletters[0].should.have.properties([ + 'id', + 'name', + 'description', + 'status', + 'sort_order' + ]); + }); + it('can read public post content', async function () { await request .get('/free-to-see/')