mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 19:33:02 +03:00
Added bulk post unpublishing test
refs https://github.com/TryGhost/Team/issues/2925
This commit is contained in:
parent
1ff71dc36c
commit
9fc98417b5
@ -113,3 +113,18 @@ Object {
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Posts Bulk API Edit Can unpublish posts 1: [body] 1`] = `
|
||||
Object {
|
||||
"bulk": Object {
|
||||
"meta": Object {
|
||||
"errors": Array [],
|
||||
"stats": Object {
|
||||
"successful": 11,
|
||||
"unsuccessful": 0,
|
||||
},
|
||||
"unsuccessfulData": Array [],
|
||||
},
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
@ -255,6 +255,30 @@ describe('Posts Bulk API', function () {
|
||||
assert(tags.find(t => t.id === newTagModel.id), `Expect post ${post.id} to have new tag ${newTagModel.id}`);
|
||||
}
|
||||
});
|
||||
|
||||
it('Can unpublish posts', async function () {
|
||||
const filter = 'status:[published]';
|
||||
const changedPosts = await models.Post.findPage({filter, limit: 1, status: 'all'});
|
||||
const amount = changedPosts.meta.pagination.total;
|
||||
|
||||
assert(amount > 0, 'Expect at least one post to be affected for this test to work');
|
||||
|
||||
const response = await agent
|
||||
.put('/posts/bulk/?filter=' + encodeURIComponent(filter))
|
||||
.body({
|
||||
bulk: {
|
||||
action: 'unpublish'
|
||||
}
|
||||
})
|
||||
.expectStatus(200)
|
||||
.matchBodySnapshot();
|
||||
|
||||
assert.equal(response.body.bulk.meta.stats.successful, amount, `Expect all matching posts (${amount}) to be unpublished, got ${response.body.bulk.meta.stats.successful} instead`);
|
||||
|
||||
// Fetch all posts and check if they are unpublished
|
||||
const posts = await models.Post.findAll({filter, status: 'all'});
|
||||
assert.equal(posts.length, 0, `Expect all matching posts (${amount}) to be unpublished`);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Delete', function () {
|
||||
|
Loading…
Reference in New Issue
Block a user