mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Added example test case for a 404 vs 406
closes https://github.com/TryGhost/Toolbox/issues/291 - When a legit Resource 404 is returned by the API we want to make sure it's not shadowed by a 406. That would be confusing, eh?
This commit is contained in:
parent
9f7bb5b65b
commit
4c2bcba5f0
2 changed files with 45 additions and 0 deletions
|
@ -1,5 +1,34 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`API Versioning Admin API responds with 404 error when the resource cannot be found 1: [body] 1`] = `
|
||||
Object {
|
||||
"errors": Array [
|
||||
Object {
|
||||
"code": null,
|
||||
"context": "Member not found.",
|
||||
"details": 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 read member.",
|
||||
"property": null,
|
||||
"type": "NotFoundError",
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`API Versioning Admin API responds with 404 error when the resource cannot be found 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": "224",
|
||||
"content-type": "application/json; charset=utf-8",
|
||||
"etag": Any<String>,
|
||||
"vary": "Origin, Accept-Encoding",
|
||||
"x-powered-by": "Express",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`API Versioning Admin API responds with current content version header when requested version is AHEAD and CAN respond 1: [body] 1`] = `
|
||||
Object {
|
||||
"site": Object {
|
||||
|
|
|
@ -7,6 +7,8 @@ describe('API Versioning', function () {
|
|||
|
||||
before(async function () {
|
||||
agentAdminAPI = await agentProvider.getAdminAPIAgent();
|
||||
await fixtureManager.init();
|
||||
await agentAdminAPI.loginAsOwner();
|
||||
});
|
||||
|
||||
it('responds with no content version header when accept version header is NOT PRESENT', async function () {
|
||||
|
@ -81,6 +83,20 @@ describe('API Versioning', function () {
|
|||
}]
|
||||
});
|
||||
});
|
||||
|
||||
it('responds with 404 error when the resource cannot be found', async function () {
|
||||
await agentAdminAPI
|
||||
.get('/members/member_does_not_exist@example.com')
|
||||
.header('Accept-Version', 'v4.1')
|
||||
.matchHeaderSnapshot({
|
||||
etag: anyString
|
||||
})
|
||||
.matchBodySnapshot({
|
||||
errors: [{
|
||||
id: anyErrorId
|
||||
}]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Content API', function () {
|
||||
|
|
Loading…
Reference in a new issue