Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(plugin-nested-docs): publishing parent doc should not publish child doc #9958

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
13 changes: 13 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,18 @@ describe('Nested Docs Plugin', () => {
// TODO: add back when error states are fixed
// await expect(parentSlugInChild).toHaveValue('/parent-slug-draft')
})

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have probably used an int.spec. They tend to run faster and are easier to debug.

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 expect(page.locator(slugClass).nth(0)).toHaveValue('child-updated-draft')
})
})
})
Loading