From 8a74cd9e11b7e597115906e81f2ede9c5466bb2f Mon Sep 17 00:00:00 2001 From: Fabien O'Carroll Date: Mon, 15 Jun 2020 18:19:26 +0200 Subject: [PATCH] Fixed Redirects API regression tests no-issue These tests were not testing the functionality correctly, but trying to test it based on metadata, which can become out of date. This tests the expected responses and is resilient for future changes to fixtures. --- test/regression/api/canary/admin/redirects_spec.js | 7 ++----- test/regression/api/v2/admin/redirects_spec.js | 7 ++----- test/regression/api/v3/admin/redirects_spec.js | 7 ++----- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/test/regression/api/canary/admin/redirects_spec.js b/test/regression/api/canary/admin/redirects_spec.js index b43b285afe..36f004fb08 100644 --- a/test/regression/api/canary/admin/redirects_spec.js +++ b/test/regression/api/canary/admin/redirects_spec.js @@ -45,8 +45,7 @@ describe('Redirects API', function () { res.headers['content-type'].should.eql('application/json; charset=utf-8'); should.not.exist(res.headers['x-cache-invalidate']); - // API returns an empty file with the correct file structure (empty []) - res.headers['content-length'].should.eql('2'); + should.deepEqual(res.body, []); }); }); @@ -60,10 +59,8 @@ describe('Redirects API', function () { .then((res) => { res.headers['content-disposition'].should.eql('Attachment; filename="redirects.json"'); res.headers['content-type'].should.eql('application/json; charset=utf-8'); - res.headers['content-length'].should.eql('756'); - res.body.should.not.be.empty(); - res.body.length.should.equal(13); + should.deepEqual(res.body, require('../../../../utils/fixtures/data/redirects.json')); }); }); }); diff --git a/test/regression/api/v2/admin/redirects_spec.js b/test/regression/api/v2/admin/redirects_spec.js index b43b285afe..36f004fb08 100644 --- a/test/regression/api/v2/admin/redirects_spec.js +++ b/test/regression/api/v2/admin/redirects_spec.js @@ -45,8 +45,7 @@ describe('Redirects API', function () { res.headers['content-type'].should.eql('application/json; charset=utf-8'); should.not.exist(res.headers['x-cache-invalidate']); - // API returns an empty file with the correct file structure (empty []) - res.headers['content-length'].should.eql('2'); + should.deepEqual(res.body, []); }); }); @@ -60,10 +59,8 @@ describe('Redirects API', function () { .then((res) => { res.headers['content-disposition'].should.eql('Attachment; filename="redirects.json"'); res.headers['content-type'].should.eql('application/json; charset=utf-8'); - res.headers['content-length'].should.eql('756'); - res.body.should.not.be.empty(); - res.body.length.should.equal(13); + should.deepEqual(res.body, require('../../../../utils/fixtures/data/redirects.json')); }); }); }); diff --git a/test/regression/api/v3/admin/redirects_spec.js b/test/regression/api/v3/admin/redirects_spec.js index b43b285afe..36f004fb08 100644 --- a/test/regression/api/v3/admin/redirects_spec.js +++ b/test/regression/api/v3/admin/redirects_spec.js @@ -45,8 +45,7 @@ describe('Redirects API', function () { res.headers['content-type'].should.eql('application/json; charset=utf-8'); should.not.exist(res.headers['x-cache-invalidate']); - // API returns an empty file with the correct file structure (empty []) - res.headers['content-length'].should.eql('2'); + should.deepEqual(res.body, []); }); }); @@ -60,10 +59,8 @@ describe('Redirects API', function () { .then((res) => { res.headers['content-disposition'].should.eql('Attachment; filename="redirects.json"'); res.headers['content-type'].should.eql('application/json; charset=utf-8'); - res.headers['content-length'].should.eql('756'); - res.body.should.not.be.empty(); - res.body.length.should.equal(13); + should.deepEqual(res.body, require('../../../../utils/fixtures/data/redirects.json')); }); }); });