mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-27 04:43:12 +03:00
03be383d8b
refs https://github.com/TryGhost/Toolbox/issues/135 - Going though local utils allows to have the "withFrontend: false" flag applied only to the e2e-api test suites. This way we can gradually introduce the no-frontend change across all test suites
39 lines
1.3 KiB
JavaScript
39 lines
1.3 KiB
JavaScript
const path = require('path');
|
|
const fs = require('fs-extra');
|
|
const should = require('should');
|
|
const supertest = require('supertest');
|
|
const localUtils = require('./utils');
|
|
const testUtils = require('../../utils');
|
|
const config = require('../../../core/shared/config');
|
|
|
|
describe('Files API', function () {
|
|
const files = [];
|
|
let request;
|
|
|
|
before(async function () {
|
|
await localUtils.startGhost();
|
|
request = supertest.agent(config.get('url'));
|
|
await localUtils.doAuth(request);
|
|
});
|
|
|
|
after(function () {
|
|
files.forEach(function (file) {
|
|
fs.removeSync(config.get('paths').appRoot + file);
|
|
});
|
|
});
|
|
|
|
it('Can upload a file', async function () {
|
|
const res = await request.post(localUtils.API.getApiQuery('files/upload'))
|
|
.set('Origin', config.get('url'))
|
|
.expect('Content-Type', /json/)
|
|
.field('ref', '934203942')
|
|
.attach('file', path.join(__dirname, '/../../utils/fixtures/images/loadingcat_square.gif'))
|
|
.expect(201);
|
|
|
|
res.body.files[0].url.should.match(new RegExp(`${config.get('url')}/content/files/\\d+/\\d+/loadingcat_square.gif`));
|
|
res.body.files[0].ref.should.equal('934203942');
|
|
|
|
files.push(res.body.files[0].url.replace(config.get('url'), ''));
|
|
});
|
|
});
|