Ghost/ghost/core/test/e2e-api/content/collections.test.js
Fabien "egg" O'Carroll 517c406e17 Added Collections Content API
The only usecases we need to support at the moment are reading individual
collections by ID and by Slug. We can extend this API as we get more usescases
in future.
2023-07-25 16:14:02 +02:00

35 lines
1.0 KiB
JavaScript

const {agentProvider, fixtureManager, matchers} = require('../../utils/e2e-framework');
const {anyISODateTime, anyObjectId} = matchers;
const collectionMatcher = {
id: anyObjectId,
created_at: anyISODateTime,
updated_at: anyISODateTime
};
describe('Collections Content API', function () {
let agent;
before(async function () {
agent = await agentProvider.getContentAPIAgent();
await fixtureManager.init('users', 'api_keys');
await agent.authenticate();
});
it('Can request a collection by slug and id', async function () {
const {body: {collections: [collection]}} = await agent
.get(`collections/slug/featured`)
.expectStatus(200)
.matchBodySnapshot({
collections: [collectionMatcher]
});
await agent
.get(`collections/${collection.id}`)
.expectStatus(200)
.matchBodySnapshot({
collections: [collectionMatcher]
});
});
});