0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00
ghost/test/e2e-api/admin/stats.test.js
Fabien 'egg' O'Carroll d94859f2e5
Added /stats/subscriptions API (#14547)
refs https://github.com/TryGhost/Team/issues/1505
refs https://github.com/TryGhost/Team/issues/1466

Exposes an API for historical counts broken down by tier and cadence.

Counts backwards from the current stats like MRR to minimize inaccruate
data due to missing/superfluous events.
2022-04-27 14:53:32 +01:00

66 lines
1.8 KiB
JavaScript

const {agentProvider, fixtureManager, matchers} = require('../../utils/e2e-framework');
const {anyEtag, anyISODate, anyObjectId} = matchers;
let agent;
describe('Stats API', function () {
before(async function () {
agent = await agentProvider.getAdminAPIAgent();
await fixtureManager.init('members');
await agent.loginAsOwner();
});
it('Can fetch member count history', async function () {
await agent
.get(`/stats/member_count`)
.expectStatus(200)
.matchBodySnapshot({
stats: [{
date: anyISODate
}]
})
.matchHeaderSnapshot({
etag: anyEtag
});
});
it('Can fetch MRR history', async function () {
await agent
.get(`/stats/mrr`)
.expectStatus(200)
.matchBodySnapshot({
stats: [{
date: anyISODate
}, {
date: anyISODate
}]
})
.matchHeaderSnapshot({
etag: anyEtag
});
});
it('Can fetch subscriptions history', async function () {
await agent
.get(`/stats/subscriptions`)
.expectStatus(200)
.matchBodySnapshot({
stats: [{
date: anyISODate,
tier: anyObjectId
}, {
date: anyISODate,
tier: anyObjectId
}],
meta: {
tiers: [anyObjectId],
totals: [{
tier: anyObjectId
}]
}
})
.matchHeaderSnapshot({
etag: anyEtag
});
});
});