Skip to content

Commit

Permalink
fix: publishing parent doc should not publish child doc
Browse files Browse the repository at this point in the history
  • Loading branch information
JessChowdhury committed Dec 13, 2024
1 parent b101fec commit 50b7e49
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 1 addition & 2 deletions packages/plugin-nested-docs/src/hooks/resaveChildren.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ type ResaveArgs = {
const resave = async ({ collection, doc, draft, pluginConfig, req }: ResaveArgs) => {
const parentSlug = pluginConfig?.parentFieldSlug || 'parent'
const parentDocIsPublished = doc._status === 'published'

const children = await req.payload.find({
collection: collection.slug,
depth: 0,
draft,
draft: true,
locale: req.locale,
req,
where: {
Expand Down
15 changes: 15 additions & 0 deletions test/plugin-nested-docs/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,20 @@ describe('Nested Docs Plugin', () => {
// TODO: add back when error states are fixed
// await expect(parentSlugInChild).toHaveValue('/parent-slug-draft')
})

test('Publishing parent doc should not publish child', async () => {
await page.goto(url.edit(childId))
await page.locator(slugClass).nth(0).fill('child-updated-draft')
await page.locator(draftButtonClass).nth(0).click()

await page.goto(url.edit(parentId))
await page.locator(slugClass).nth(0).fill('parent-updated-published')
await page.locator(publishButtonClass).nth(0).click()
await page.goto(url.edit(childId))
await page.locator(slugClass).nth(0).fill('child-updated-draft')

await page.locator(draftButtonClass).nth(0).click()
await expect(page.locator(slugClass).nth(0)).toHaveValue('child-updated-draft')
})
})
})

0 comments on commit 50b7e49

Please sign in to comment.