From 431f0ed8420f92d23e6318eb3ab5aeb53c98a456 Mon Sep 17 00:00:00 2001 From: "Fabien \"egg\" O'Carroll" Date: Tue, 25 Jul 2023 16:40:48 +0200 Subject: [PATCH] Fixed the "Can add a Collection" test The test was addign an extra collection, but not cleaning it up - which makes it hard to reason about other tests, especially when running them in isolation and the state is different. This just cleans up the test and updates the browse test to match the right snapshot. --- .../__snapshots__/collections.test.js.snap | 17 +++-------------- .../core/test/e2e-api/admin/collections.test.js | 7 +++++-- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/ghost/core/test/e2e-api/admin/__snapshots__/collections.test.js.snap b/ghost/core/test/e2e-api/admin/__snapshots__/collections.test.js.snap index 380fee99e4..bc95dfdac7 100644 --- a/ghost/core/test/e2e-api/admin/__snapshots__/collections.test.js.snap +++ b/ghost/core/test/e2e-api/admin/__snapshots__/collections.test.js.snap @@ -1145,26 +1145,15 @@ Object { "type": "automatic", "updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/, }, - Object { - "created_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/, - "description": "Test Collection Description", - "feature_image": null, - "filter": null, - "id": StringMatching /\\[a-f0-9\\]\\{24\\}/, - "slug": "test-collection", - "title": "Test Collection", - "type": "manual", - "updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/, - }, ], "meta": Object { "pagination": Object { - "limit": 3, + "limit": 2, "next": null, "page": 1, "pages": 1, "prev": null, - "total": 3, + "total": 2, }, }, } @@ -1174,7 +1163,7 @@ exports[`Collections API Browse Can browse Collections 2: [headers] 1`] = ` Object { "access-control-allow-origin": "http://127.0.0.1:2369", "cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0", - "content-length": "838", + "content-length": "578", "content-type": "application/json; charset=utf-8", "content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/, "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/, diff --git a/ghost/core/test/e2e-api/admin/collections.test.js b/ghost/core/test/e2e-api/admin/collections.test.js index 322e18bdb7..6832c706ec 100644 --- a/ghost/core/test/e2e-api/admin/collections.test.js +++ b/ghost/core/test/e2e-api/admin/collections.test.js @@ -66,7 +66,7 @@ describe('Collections API', function () { description: 'Test Collection Description' }; - await agent + const {body: {collections: [{id: collectionId}]}} = await agent .post('/collections/') .body({ collections: [collection] @@ -80,6 +80,10 @@ describe('Collections API', function () { .matchBodySnapshot({ collections: [matchCollection] }); + + await agent + .delete(`/collections/${collectionId}/`) + .expectStatus(204); }); describe('Browse', function () { @@ -93,7 +97,6 @@ describe('Collections API', function () { }) .matchBodySnapshot({ collections: [ - matchCollection, matchCollection, matchCollection ]