mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-27 22:49:56 -05:00
Added test coverage to automatic collections
refs https://github.com/TryGhost/Team/issues/3170 - The test confirms `published_at` filtering works for automatic collections
This commit is contained in:
parent
bfefcfd4df
commit
260ca0548a
2 changed files with 87 additions and 0 deletions
|
@ -42,6 +42,68 @@ Object {
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`Collections API Automatic Collection Filtering Creates an automatic Collection with a published_at filter 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": "Test Collection Description with published_at filter",
|
||||||
|
"feature_image": null,
|
||||||
|
"filter": "published_at:>=2022-05-25",
|
||||||
|
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||||
|
"posts": Array [
|
||||||
|
Object {
|
||||||
|
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||||
|
"sort_order": 0,
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||||
|
"sort_order": 1,
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||||
|
"sort_order": 2,
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||||
|
"sort_order": 3,
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||||
|
"sort_order": 4,
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||||
|
"sort_order": 5,
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||||
|
"sort_order": 6,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"title": "Test Collection with published_at filter",
|
||||||
|
"type": "automatic",
|
||||||
|
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`Collections API Automatic Collection Filtering Creates an automatic Collection with a published_at filter 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": "681",
|
||||||
|
"content-type": "application/json; charset=utf-8",
|
||||||
|
"content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/,
|
||||||
|
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
|
||||||
|
"location": StringMatching /https\\?:\\\\/\\\\/\\.\\*\\?\\\\/collections\\\\/\\[a-f0-9\\]\\{24\\}\\\\//,
|
||||||
|
"vary": "Accept-Version, Origin, Accept-Encoding",
|
||||||
|
"x-cache-invalidate": "/*",
|
||||||
|
"x-powered-by": "Express",
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`Collections API Can add a Collection 1: [body] 1`] = `
|
exports[`Collections API Can add a Collection 1: [body] 1`] = `
|
||||||
Object {
|
Object {
|
||||||
"collections": Array [
|
"collections": Array [
|
||||||
|
|
|
@ -354,5 +354,30 @@ describe('Collections API', function () {
|
||||||
collections: [buildMatcher(2)]
|
collections: [buildMatcher(2)]
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Creates an automatic Collection with a published_at filter', async function () {
|
||||||
|
const collection = {
|
||||||
|
title: 'Test Collection with published_at filter',
|
||||||
|
description: 'Test Collection Description with published_at filter',
|
||||||
|
type: 'automatic',
|
||||||
|
// should return all available posts
|
||||||
|
filter: 'published_at:>=2022-05-25'
|
||||||
|
};
|
||||||
|
|
||||||
|
await agent
|
||||||
|
.post('/collections/')
|
||||||
|
.body({
|
||||||
|
collections: [collection]
|
||||||
|
})
|
||||||
|
.expectStatus(201)
|
||||||
|
.matchHeaderSnapshot({
|
||||||
|
'content-version': anyContentVersion,
|
||||||
|
etag: anyEtag,
|
||||||
|
location: anyLocationFor('collections')
|
||||||
|
})
|
||||||
|
.matchBodySnapshot({
|
||||||
|
collections: [buildMatcher(7)]
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue