mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-04 02:01:58 -05:00
Grouped edit collection test cases
refs https://github.com/TryGhost/Team/issues/3260 - Cleanup before adding more test cases to the suite
This commit is contained in:
parent
8c02d963c4
commit
988f7e69c2
2 changed files with 120 additions and 56 deletions
|
@ -304,3 +304,65 @@ Object {
|
|||
"x-powered-by": "Express",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Collections API edit Can edit a Collection 1: [body] 1`] = `
|
||||
Object {
|
||||
"collections": Array [
|
||||
Object {
|
||||
"created_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||
"description": null,
|
||||
"feature_image": null,
|
||||
"filter": null,
|
||||
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||
"title": "Test Collection Edited",
|
||||
"type": "manual",
|
||||
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Collections API edit Can edit a Collection 2: [headers] 1`] = `
|
||||
Object {
|
||||
"access-control-allow-origin": "http://127.0.0.1:2369",
|
||||
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
|
||||
"content-length": "234",
|
||||
"content-type": "application/json; charset=utf-8",
|
||||
"content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/,
|
||||
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
|
||||
"vary": "Accept-Version, Origin, Accept-Encoding",
|
||||
"x-cache-invalidate": "/*",
|
||||
"x-powered-by": "Express",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Collections API edit Fails to edit unexistent Collection 1: [body] 1`] = `
|
||||
Object {
|
||||
"errors": Array [
|
||||
Object {
|
||||
"code": null,
|
||||
"context": "Collection not found.",
|
||||
"details": null,
|
||||
"ghostErrorCode": null,
|
||||
"help": null,
|
||||
"id": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
|
||||
"message": "Resource not found error, cannot edit collection.",
|
||||
"property": null,
|
||||
"type": "NotFoundError",
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Collections API edit Fails to edit unexistent Collection 2: [headers] 1`] = `
|
||||
Object {
|
||||
"access-control-allow-origin": "http://127.0.0.1:2369",
|
||||
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
|
||||
"content-length": "254",
|
||||
"content-type": "application/json; charset=utf-8",
|
||||
"content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/,
|
||||
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
|
||||
"vary": "Accept-Version, Origin, Accept-Encoding",
|
||||
"x-powered-by": "Express",
|
||||
}
|
||||
`;
|
||||
|
|
|
@ -104,67 +104,69 @@ describe('Collections API', function () {
|
|||
assert.equal(readResponse.body.collections[0].title, 'Test Collection to Read');
|
||||
});
|
||||
|
||||
it('Can edit a Collection', async function () {
|
||||
const collection = {
|
||||
title: 'Test Collection to Edit'
|
||||
};
|
||||
describe('edit', function () {
|
||||
it('Can edit a Collection', async function () {
|
||||
const collection = {
|
||||
title: 'Test Collection to Edit'
|
||||
};
|
||||
|
||||
const addResponse = await agent
|
||||
.post('/collections/')
|
||||
.body({
|
||||
collections: [collection]
|
||||
})
|
||||
.expectStatus(201)
|
||||
.matchHeaderSnapshot({
|
||||
'content-version': anyContentVersion,
|
||||
etag: anyEtag,
|
||||
location: anyLocationFor('collections')
|
||||
})
|
||||
.matchBodySnapshot({
|
||||
collections: [matchCollection]
|
||||
});
|
||||
const addResponse = await agent
|
||||
.post('/collections/')
|
||||
.body({
|
||||
collections: [collection]
|
||||
})
|
||||
.expectStatus(201)
|
||||
.matchHeaderSnapshot({
|
||||
'content-version': anyContentVersion,
|
||||
etag: anyEtag,
|
||||
location: anyLocationFor('collections')
|
||||
})
|
||||
.matchBodySnapshot({
|
||||
collections: [matchCollection]
|
||||
});
|
||||
|
||||
const collectionId = addResponse.body.collections[0].id;
|
||||
const collectionId = addResponse.body.collections[0].id;
|
||||
|
||||
const editResponse = await agent
|
||||
.put(`/collections/${collectionId}/`)
|
||||
.body({
|
||||
collections: [{
|
||||
title: 'Test Collection Edited'
|
||||
}]
|
||||
})
|
||||
.expectStatus(200)
|
||||
.matchHeaderSnapshot({
|
||||
'content-version': anyContentVersion,
|
||||
etag: anyEtag
|
||||
})
|
||||
.matchBodySnapshot({
|
||||
collections: [matchCollection]
|
||||
});
|
||||
const editResponse = await agent
|
||||
.put(`/collections/${collectionId}/`)
|
||||
.body({
|
||||
collections: [{
|
||||
title: 'Test Collection Edited'
|
||||
}]
|
||||
})
|
||||
.expectStatus(200)
|
||||
.matchHeaderSnapshot({
|
||||
'content-version': anyContentVersion,
|
||||
etag: anyEtag
|
||||
})
|
||||
.matchBodySnapshot({
|
||||
collections: [matchCollection]
|
||||
});
|
||||
|
||||
assert.equal(editResponse.body.collections[0].title, 'Test Collection Edited');
|
||||
});
|
||||
assert.equal(editResponse.body.collections[0].title, 'Test Collection Edited');
|
||||
});
|
||||
|
||||
it('Fails to edit unexistent Collection', async function () {
|
||||
const unexistentID = '5951f5fca366002ebd5dbef7';
|
||||
await agent
|
||||
.put(`/collections/${unexistentID}/`)
|
||||
.body({
|
||||
collections: [{
|
||||
id: unexistentID,
|
||||
title: 'Editing unexistent Collection'
|
||||
}]
|
||||
})
|
||||
.expectStatus(404)
|
||||
.matchBodySnapshot({
|
||||
errors: [{
|
||||
id: anyErrorId
|
||||
}]
|
||||
})
|
||||
.matchHeaderSnapshot({
|
||||
'content-version': anyContentVersion,
|
||||
etag: anyEtag
|
||||
});
|
||||
it('Fails to edit unexistent Collection', async function () {
|
||||
const unexistentID = '5951f5fca366002ebd5dbef7';
|
||||
await agent
|
||||
.put(`/collections/${unexistentID}/`)
|
||||
.body({
|
||||
collections: [{
|
||||
id: unexistentID,
|
||||
title: 'Editing unexistent Collection'
|
||||
}]
|
||||
})
|
||||
.expectStatus(404)
|
||||
.matchBodySnapshot({
|
||||
errors: [{
|
||||
id: anyErrorId
|
||||
}]
|
||||
})
|
||||
.matchHeaderSnapshot({
|
||||
'content-version': anyContentVersion,
|
||||
etag: anyEtag
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('Can delete a Collection', async function () {
|
||||
|
|
Loading…
Add table
Reference in a new issue