mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 03:44:29 +03:00
c66eeb5879
- split out the two tests that use files, as the new framework doesn't support this yet - convert the 3 existing tests for the settings endpoint to use the new framework - introduced a new pattern of using a function to generate a matching array, so that we can do extra stuff - in this case, just one of the items needed a matcher for the value, which results in slightly weird code - wrapping in a function gives us somewhere to do this and leave a comment
51 lines
1.7 KiB
JavaScript
51 lines
1.7 KiB
JavaScript
const should = require('should');
|
|
const supertest = require('supertest');
|
|
const os = require('os');
|
|
const fs = require('fs-extra');
|
|
const config = require('../../../core/shared/config');
|
|
const testUtils = require('../../utils');
|
|
const localUtils = require('./utils');
|
|
|
|
/**
|
|
* The new test framework doesn't yet support files
|
|
*/
|
|
describe('Settings File API', function () {
|
|
let request;
|
|
|
|
before(async function () {
|
|
await localUtils.startGhost();
|
|
request = supertest.agent(config.get('url'));
|
|
await localUtils.doAuth(request);
|
|
});
|
|
|
|
after(function () {
|
|
return testUtils.stopGhost();
|
|
});
|
|
|
|
it('Can download routes.yaml', async function () {
|
|
const res = await request.get(localUtils.API.getApiQuery('settings/routes/yaml/'))
|
|
.set('Origin', config.get('url'))
|
|
.set('Accept', 'application/yaml')
|
|
.expect(200);
|
|
|
|
res.headers['content-disposition'].should.eql('Attachment; filename="routes.yaml"');
|
|
res.headers['content-type'].should.eql('application/yaml; charset=utf-8');
|
|
res.headers['content-length'].should.eql('138');
|
|
});
|
|
|
|
it('Can upload routes.yaml', async function () {
|
|
const newRoutesYamlPath = `${os.tmpdir()}/routes.yaml`;
|
|
|
|
await fs.writeFile(newRoutesYamlPath, 'routes:\ncollections:\ntaxonomies:\n');
|
|
const res = await request
|
|
.post(localUtils.API.getApiQuery('settings/routes/yaml/'))
|
|
.set('Origin', config.get('url'))
|
|
.attach('routes', newRoutesYamlPath)
|
|
.expect('Content-Type', /application\/json/)
|
|
.expect(200);
|
|
|
|
res.headers['x-cache-invalidate'].should.eql('/*');
|
|
await testUtils.stopGhost();
|
|
});
|
|
});
|