-
Notifications
You must be signed in to change notification settings - Fork 614
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ensure published entries are fully deleted (#4265)
- Loading branch information
Showing
2 changed files
with
74 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
packages/api-headless-cms/__tests__/contentAPI/contentEntriesDeletion.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { useTestModelHandler } from "~tests/testHelpers/useTestModelHandler"; | ||
import { identityA } from "./security/utils"; | ||
|
||
describe("Content entries - Entry Deletion", () => { | ||
const { manage, read } = useTestModelHandler({ | ||
identity: identityA | ||
}); | ||
|
||
beforeEach(async () => { | ||
await manage.setup(); | ||
}); | ||
|
||
test("MANAGE/READ GraphQL APIs should reflect revision deletions correctly", async () => { | ||
const { data: revision1 } = await manage.createTestEntry({ data: { title: "Revision 1" } }); | ||
|
||
const { data: revision2 } = await manage.createTestEntryFrom({ | ||
revision: revision1.id, | ||
data: { title: "Revision 2" } | ||
}); | ||
|
||
const { data: revision3 } = await manage.createTestEntryFrom({ | ||
revision: revision2.id, | ||
data: { title: "Revision 3" } | ||
}); | ||
|
||
await manage.publishTestEntry({ | ||
revision: revision3.id | ||
}); | ||
|
||
let { data: manageEntriesList } = await manage.listTestEntries(); | ||
let { data: readEntriesList } = await read.listTestEntries(); | ||
|
||
expect(manageEntriesList).toHaveLength(1); | ||
expect(manageEntriesList).toMatchObject([ | ||
{ id: revision3.id, title: "Revision 3", meta: { status: "published" } } | ||
]); | ||
|
||
expect(readEntriesList).toHaveLength(1); | ||
expect(readEntriesList).toMatchObject([{ id: revision3.id, title: "Revision 3" }]); | ||
|
||
await manage.deleteTestEntry({ revision: revision3.id }); | ||
|
||
({ data: manageEntriesList } = await manage.listTestEntries()); | ||
({ data: readEntriesList } = await read.listTestEntries()); | ||
|
||
expect(manageEntriesList).toHaveLength(1); | ||
expect(manageEntriesList).toMatchObject([ | ||
{ id: revision2.id, title: "Revision 2", meta: { status: "draft" } } | ||
]); | ||
|
||
expect(readEntriesList).toHaveLength(0); | ||
|
||
await manage.deleteTestEntry({ revision: revision2.id }); | ||
|
||
({ data: manageEntriesList } = await manage.listTestEntries()); | ||
({ data: readEntriesList } = await read.listTestEntries()); | ||
|
||
expect(manageEntriesList).toHaveLength(1); | ||
expect(manageEntriesList).toMatchObject([ | ||
{ id: revision1.id, title: "Revision 1", meta: { status: "draft" } } | ||
]); | ||
|
||
expect(readEntriesList).toHaveLength(0); | ||
|
||
await manage.deleteTestEntry({ revision: revision1.id }); | ||
|
||
({ data: manageEntriesList } = await manage.listTestEntries()); | ||
({ data: readEntriesList } = await read.listTestEntries()); | ||
|
||
expect(manageEntriesList).toHaveLength(0); | ||
expect(readEntriesList).toHaveLength(0); | ||
}); | ||
}); |