mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Added functional test for import endpoint in API v2
no issue - This change is a follow up to this bugfix https://github.com/TryGhost/Ghost/pull/10299 - Added default export JSON to keep the state of db test suite intact - Small typo fixe that noticed while debugging
This commit is contained in:
parent
8d6def159a
commit
6797da599b
3 changed files with 2681 additions and 1 deletions
|
@ -18,7 +18,7 @@ module.exports = {
|
|||
},
|
||||
|
||||
importContent(response, apiConfig, frame) {
|
||||
debug('exportContent');
|
||||
debug('importContent');
|
||||
|
||||
// NOTE: response can contain 2 objects if images are imported
|
||||
const problems = (response.length === 2)
|
||||
|
|
|
@ -84,6 +84,43 @@ describe('DB API', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('import should succeed with default content', () => {
|
||||
return Promise.resolve()
|
||||
.then(() => {
|
||||
return request.delete(localUtils.API.getApiQuery('db/'))
|
||||
.set('Origin', config.get('url'))
|
||||
.set('Accept', 'application/json')
|
||||
.expect(204);
|
||||
})
|
||||
.then(() => {
|
||||
return request.post(localUtils.API.getApiQuery('db/'))
|
||||
.set('Origin', config.get('url'))
|
||||
.set('Accept', 'application/json')
|
||||
.expect('Content-Type', /json/)
|
||||
.attach('importfile', path.join(__dirname, '/../../../../utils/fixtures/export/default_export.json'))
|
||||
.expect(200)
|
||||
.then((res) => {
|
||||
const jsonResponse = res.body;
|
||||
should.exist(jsonResponse.db);
|
||||
should.exist(jsonResponse.problems);
|
||||
jsonResponse.problems.should.have.length(3);
|
||||
});
|
||||
})
|
||||
.then(() => {
|
||||
return request.get(localUtils.API.getApiQuery('posts/'))
|
||||
.set('Origin', config.get('url'))
|
||||
.expect('Content-Type', /json/)
|
||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||
.expect(200)
|
||||
.then((res) => {
|
||||
let jsonResponse = res.body;
|
||||
let results = jsonResponse.posts;
|
||||
jsonResponse.posts.should.have.length(7);
|
||||
_.filter(results, {page: false, status: 'published'}).length.should.equal(7);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('import should fail without file', () => {
|
||||
return request.post(localUtils.API.getApiQuery('db/'))
|
||||
.set('Origin', config.get('url'))
|
||||
|
|
2643
core/test/utils/fixtures/export/default_export.json
Normal file
2643
core/test/utils/fixtures/export/default_export.json
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Reference in a new issue