mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-29 22:01:49 +03:00
89493893d1
- this cleans up all imports or variables that aren't currently being used - this really helps keep the tests clean by only allowing what is needed - I've left `should` as an exemption for now because we need to clean up how it is used
95 lines
2.9 KiB
JavaScript
95 lines
2.9 KiB
JavaScript
const {agentProvider, mockManager, fixtureManager, matchers} = require('../../utils/e2e-framework');
|
|
const {anyContentVersion, anyEtag, anyObjectId, anyUuid, anyISODateTime, anyArray} = matchers;
|
|
|
|
const memberMatcherShallowIncludesForNewsletters = {
|
|
id: anyObjectId,
|
|
uuid: anyUuid,
|
|
created_at: anyISODateTime,
|
|
updated_at: anyISODateTime,
|
|
subscriptions: anyArray,
|
|
labels: anyArray,
|
|
newsletters: anyArray
|
|
};
|
|
|
|
let agent;
|
|
|
|
describe('Members API - With Newsletters', function () {
|
|
before(async function () {
|
|
agent = await agentProvider.getAdminAPIAgent();
|
|
await fixtureManager.init('newsletters', 'members:newsletters');
|
|
await agent.loginAsOwner();
|
|
});
|
|
|
|
afterEach(function () {
|
|
mockManager.restore();
|
|
});
|
|
|
|
// List Members
|
|
|
|
it('Can fetch members who are subscribed', async function () {
|
|
await agent
|
|
.get('/members/?filter=newsletters.status:active')
|
|
.expectStatus(200)
|
|
.matchBodySnapshot({
|
|
members: new Array(6).fill(memberMatcherShallowIncludesForNewsletters)
|
|
})
|
|
.matchHeaderSnapshot({
|
|
'content-version': anyContentVersion,
|
|
etag: anyEtag
|
|
});
|
|
});
|
|
|
|
it('Can fetch members who are NOT subscribed', async function () {
|
|
await agent
|
|
.get('/members/?filter=newsletters.status:-active')
|
|
.expectStatus(200)
|
|
.matchBodySnapshot({
|
|
members: new Array(2).fill(memberMatcherShallowIncludesForNewsletters)
|
|
})
|
|
.matchHeaderSnapshot({
|
|
'content-version': anyContentVersion,
|
|
etag: anyEtag
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('Members API - With Newsletters - compat mode', function () {
|
|
before(async function () {
|
|
agent = await agentProvider.getAdminAPIAgent();
|
|
await fixtureManager.init('newsletters', 'members:newsletters');
|
|
await agent.loginAsOwner();
|
|
});
|
|
|
|
afterEach(function () {
|
|
mockManager.restore();
|
|
});
|
|
|
|
// List Members
|
|
|
|
it('Can fetch members who are subscribed', async function () {
|
|
await agent
|
|
.get('/members/?filter=subscribed:true')
|
|
.expectStatus(200)
|
|
.matchBodySnapshot({
|
|
members: new Array(6).fill(memberMatcherShallowIncludesForNewsletters)
|
|
})
|
|
.matchHeaderSnapshot({
|
|
'content-version': anyContentVersion,
|
|
etag: anyEtag
|
|
});
|
|
});
|
|
|
|
it('Can fetch members who are NOT subscribed', async function () {
|
|
await agent
|
|
.get('/members/?filter=subscribed:false')
|
|
.expectStatus(200)
|
|
.matchBodySnapshot({
|
|
members: new Array(2).fill(memberMatcherShallowIncludesForNewsletters)
|
|
})
|
|
.matchHeaderSnapshot({
|
|
'content-version': anyContentVersion,
|
|
etag: anyEtag
|
|
});
|
|
});
|
|
});
|