From 7b950f63825adb1622266863891f14060b95a58a Mon Sep 17 00:00:00 2001 From: Nazar Gargol Date: Wed, 26 Sep 2018 11:55:21 +0200 Subject: [PATCH] Added test case for includes not being present in response refs #9866 - Adds a test case checking current filtering behavior for 'include' parameter --- core/test/functional/routes/api/posts_spec.js | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/core/test/functional/routes/api/posts_spec.js b/core/test/functional/routes/api/posts_spec.js index 1adea44906..8132829e9c 100644 --- a/core/test/functional/routes/api/posts_spec.js +++ b/core/test/functional/routes/api/posts_spec.js @@ -186,6 +186,37 @@ describe('Post API', function () { }); }); + it('fields and formats and include ignores include', function (done) { + request.get(testUtils.API.getApiQuery('posts/?formats=mobiledoc,html&fields=id,title&include=authors')) + .set('Authorization', 'Bearer ' + ownerAccessToken) + .expect('Content-Type', /json/) + .expect('Cache-Control', testUtils.cacheRules.private) + .expect(200) + .end(function (err, res) { + if (err) { + return done(err); + } + + should.not.exist(res.headers['x-cache-invalidate']); + var jsonResponse = res.body; + should.exist(jsonResponse.posts); + should.not.exist(jsonResponse.posts[0].authors); + testUtils.API.checkResponse(jsonResponse, 'posts'); + jsonResponse.posts.should.have.length(11); + testUtils.API.checkResponse( + jsonResponse.posts[0], + 'post', + null, + null, + ['mobiledoc', 'id', 'title', 'html'] + ); + + testUtils.API.checkResponse(jsonResponse.meta.pagination, 'pagination'); + + done(); + }); + }); + it('can retrieve all published posts and pages', function (done) { request.get(testUtils.API.getApiQuery('posts/?staticPages=all')) .set('Authorization', 'Bearer ' + ownerAccessToken)