Ghost/test/e2e-api/admin/redirects.test.js
Naz fc5984b486 Slimmed down redirects test suites
refs https://github.com/TryGhost/Toolbox/issues/139

- The regression test suite for redirects functionality for way too big. And each restart was causing massive overhead. It's enough to have a single exhaustive test using multiple input files
- The tests testing API endpoints should've been e2e tests to start with
- The rest is covered in the unit tests for redirects api service
2021-11-26 06:18:36 +13:00

41 lines
1.4 KiB
JavaScript

const should = require('should');
const supertest = require('supertest');
const fs = require('fs-extra');
const path = require('path');
const localUtils = require('./utils');
const config = require('../../../core/shared/config');
describe('Redirects API', function () {
let request;
before(async function () {
await localUtils.startGhost();
request = supertest.agent(config.get('url'));
await localUtils.doAuth(request, 'users:extra', 'posts');
});
it('download', function () {
return request
.get(localUtils.API.getApiQuery('redirects/download/'))
.set('Origin', config.get('url'))
.expect('Content-Type', /application\/json/)
.expect('Content-Disposition', 'Attachment; filename="redirects.json"')
.expect(200);
});
it('upload', function () {
// Provide a redirects file in the root directory of the content test folder
fs.writeFileSync(path.join(config.get('paths:contentPath'), 'redirects-init.json'), JSON.stringify([{
from: 'k',
to: 'l'
}]));
return request
.post(localUtils.API.getApiQuery('redirects/upload/'))
.set('Origin', config.get('url'))
.attach('redirects', path.join(config.get('paths:contentPath'), 'redirects-init.json'))
.expect('Content-Type', /application\/json/)
.expect(200);
});
});