0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-04-15 03:01:37 -05:00

Fixed snapshot tests using version headers

refs 3381dae1e6
refs 4a4b0cc8a6
refs f432ee9aa6

- The initial tests didn't take into account the veersion of the Ghost instance would be changing contantly. The "context" part of the returned version missmatch errors should be a regex with only partially hardcoded message.
This commit is contained in:
Naz 2022-04-18 10:35:29 +08:00
parent f432ee9aa6
commit d9ac05f97a
2 changed files with 6 additions and 6 deletions

View file

@ -88,7 +88,7 @@ Object {
"errors": Array [
Object {
"code": null,
"context": "Provided client version v999.1 is ahead of current Ghost instance version v4.43.",
"context": StringMatching /Provided client version v999\\\\\\.1 is ahead of current Ghost instance version v\\\\d\\+\\\\\\.\\\\d\\+/,
"details": null,
"help": "Upgrade your Ghost instance.",
"id": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
@ -117,7 +117,7 @@ Object {
"errors": Array [
Object {
"code": null,
"context": "Provided client version v3.1 is outdated and is behind current Ghost version v4.43.",
"context": StringMatching /Provided client version v3\\.1 is outdated and is behind current Ghost version v\\\\d\\+\\\\\\.\\\\d\\+/,
"details": null,
"help": "Upgrade your Ghost API client.",
"id": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,

View file

@ -54,8 +54,7 @@ describe('API Versioning', function () {
});
});
// eslint-disable-next-line ghost/mocha/no-skipped-tests
it.skip('responds with error requested version is AHEAD and CANNOT respond', async function () {
it('responds with error requested version is AHEAD and CANNOT respond', async function () {
// CASE 2: If accept-version is behind, send a 406 & tell them the client needs updating.
await agentAdminAPI
.get('removed_endpoint')
@ -65,13 +64,13 @@ describe('API Versioning', function () {
})
.matchBodySnapshot({
errors: [{
context: stringMatching(/Provided client version v999\.1 is ahead of current Ghost instance version v\d+\.\d+/),
id: anyErrorId
}]
});
});
// eslint-disable-next-line ghost/mocha/no-skipped-tests
it.skip('responds with error when requested version is BEHIND and CANNOT respond', async function () {
it('responds with error when requested version is BEHIND and CANNOT respond', async function () {
// CASE 2: If accept-version is behind, send a 406 & tell them the client needs updating.
await agentAdminAPI
.get('removed_endpoint')
@ -81,6 +80,7 @@ describe('API Versioning', function () {
})
.matchBodySnapshot({
errors: [{
context: stringMatching(/Provided client version v3.1 is outdated and is behind current Ghost version v\d+\.\d+/),
id: anyErrorId
}]
});