Refactored basic edit test case

refs https://github.com/TryGhost/Team/issues/3260

- We need to have a reusable collection to edit throughout the describe, so we don't do repeatable work over and over
This commit is contained in:
Naz 2023-05-25 11:46:20 +07:00 committed by naz
parent 988f7e69c2
commit c7954fa695

View File

@ -105,7 +105,9 @@ describe('Collections API', function () {
});
describe('edit', function () {
it('Can edit a Collection', async function () {
let collectionToEdit;
before(async function () {
const collection = {
title: 'Test Collection to Edit'
};
@ -115,20 +117,14 @@ describe('Collections API', function () {
.body({
collections: [collection]
})
.expectStatus(201)
.matchHeaderSnapshot({
'content-version': anyContentVersion,
etag: anyEtag,
location: anyLocationFor('collections')
})
.matchBodySnapshot({
collections: [matchCollection]
.expectStatus(201);
collectionToEdit = addResponse.body.collections[0];
});
const collectionId = addResponse.body.collections[0].id;
it('Can edit a Collection', async function () {
const editResponse = await agent
.put(`/collections/${collectionId}/`)
.put(`/collections/${collectionToEdit.id}/`)
.body({
collections: [{
title: 'Test Collection Edited'