0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Updated export fixture for Ghost 2.9

refs https://github.com/TryGhost/Team/issues/555

- This test fixure is up to date and contains real export from Ghost 2.9. This file should not be edited any more as it represents a "snapshot" of 2.9 (don't really know why this version was chosen to be tested, so didn't change the convention).
- Ideally in the future we should maintain snapshots of export from major releases (or at least first non-broken releases after major release) AND a snapshot of the latest ghost version export file (canary of a sort). This way we'll be able to build up confidence of older export files still working and keep good track in export file changes with every new version
- Updated db spec suite to remove "fixture" user before each import to reduce a variable amount of import errors (star from the same state). It has to be done through an API call because restarting Ghost instance to have clean slate before each test case times out the suite
This commit is contained in:
Naz 2021-03-24 20:00:34 +13:00
parent 4286fa8a53
commit e290983042
3 changed files with 2706 additions and 2543 deletions

View file

@ -169,12 +169,24 @@ describe('DB API', function () {
.expect(200);
});
it('Can import a JSON database exported from Ghost 2.0', async function () {
it('Can import a JSON database exported from Ghost v2', async function () {
await request.delete(localUtils.API.getApiQuery('db/'))
.set('Origin', config.get('url'))
.set('Accept', 'application/json')
.expect(204);
// preventively remove default "fixture" user
const fixtureUserResponse = await request.get(localUtils.API.getApiQuery('users/slug/fixture/'))
.set('Origin', config.get('url'))
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private);
if (fixtureUserResponse.body.users) {
await request.delete(localUtils.API.getApiQuery(`users/${fixtureUserResponse.body.users[0].id}`))
.set('Origin', config.get('url'))
.set('Accept', 'application/json');
}
const res = await request.post(localUtils.API.getApiQuery('db/'))
.set('Origin', config.get('url'))
.set('Accept', 'application/json')
@ -185,15 +197,23 @@ describe('DB API', function () {
const jsonResponse = res.body;
should.exist(jsonResponse.db);
should.exist(jsonResponse.problems);
jsonResponse.problems.should.have.length(3);
jsonResponse.problems.should.have.length(2);
const res2 = await request.get(localUtils.API.getApiQuery('posts/'))
const postsResponse = await request.get(localUtils.API.getApiQuery('posts/'))
.set('Origin', config.get('url'))
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private)
.expect(200);
res2.body.posts.should.have.length(7);
postsResponse.body.posts.should.have.length(7);
const usersResponse = await request.get(localUtils.API.getApiQuery('users/'))
.set('Origin', config.get('url'))
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private)
.expect(200);
usersResponse.body.users.should.have.length(3);
});
it('Can import a JSON database exported from Ghost 3.0', async function () {
@ -202,6 +222,18 @@ describe('DB API', function () {
.set('Accept', 'application/json')
.expect(204);
// preventively remove default "fixture" user
const fixtureUserResponse = await request.get(localUtils.API.getApiQuery('users/slug/fixture/'))
.set('Origin', config.get('url'))
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private);
if (fixtureUserResponse.body.users) {
await request.delete(localUtils.API.getApiQuery(`users/${fixtureUserResponse.body.users[0].id}`))
.set('Origin', config.get('url'))
.set('Accept', 'application/json');
}
const res = await request.post(localUtils.API.getApiQuery('db/'))
.set('Origin', config.get('url'))
.set('Accept', 'application/json')
@ -221,6 +253,14 @@ describe('DB API', function () {
.expect(200);
res2.body.posts.should.have.length(7);
const usersResponse = await request.get(localUtils.API.getApiQuery('users/'))
.set('Origin', config.get('url'))
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private)
.expect(200);
usersResponse.body.users.should.have.length(3);
});
it('Can import a JSON database exported from Ghost 4.0', async function () {
@ -229,6 +269,18 @@ describe('DB API', function () {
.set('Accept', 'application/json')
.expect(204);
// preventively remove default "fixture" user
const fixtureUserResponse = await request.get(localUtils.API.getApiQuery('users/slug/fixture/'))
.set('Origin', config.get('url'))
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private);
if (fixtureUserResponse.body.users) {
await request.delete(localUtils.API.getApiQuery(`users/${fixtureUserResponse.body.users[0].id}`))
.set('Origin', config.get('url'))
.set('Accept', 'application/json');
}
const res = await request.post(localUtils.API.getApiQuery('db/'))
.set('Origin', config.get('url'))
.set('Accept', 'application/json')
@ -248,5 +300,13 @@ describe('DB API', function () {
.expect(200);
res2.body.posts.should.have.length(7);
const usersResponse = await request.get(localUtils.API.getApiQuery('users/'))
.set('Origin', config.get('url'))
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private)
.expect(200);
usersResponse.body.users.should.have.length(3);
});
});

File diff suppressed because it is too large Load diff

View file

@ -2673,7 +2673,7 @@
"name": "Fixture Ghosty",
"slug": "fixture",
"password": "$2a$10$r0NpLiq8/.nzyxQrM96dI.JHyhx56MzsVv7xI6K4wzQDeR6gOAi3m",
"email": "naz@ghost.org",
"email": "test@ghost.org",
"profile_image": "//www.gravatar.com/avatar/d94a22d95b540979c98f20e4598e32ee?s=250&d=mm&r=x",
"cover_image": null,
"bio": null,