diff --git a/packages/ui/src/elements/PublishMany/index.tsx b/packages/ui/src/elements/PublishMany/index.tsx index 1c6b7e85e..4471d5364 100644 --- a/packages/ui/src/elements/PublishMany/index.tsx +++ b/packages/ui/src/elements/PublishMany/index.tsx @@ -56,7 +56,7 @@ export const PublishMany: React.FC = (props) => { setSubmitted(true) await requests .patch( - `${serverURL}${api}/${slug}${getQueryParams({ _status: { not_equals: 'published' } })}`, + `${serverURL}${api}/${slug}${getQueryParams({ _status: { not_equals: 'published' } })}&draft=true`, { body: JSON.stringify({ _status: 'published', diff --git a/test/versions/collections/Autosave.ts b/test/versions/collections/Autosave.ts index 11a76126e..9ba1f8089 100644 --- a/test/versions/collections/Autosave.ts +++ b/test/versions/collections/Autosave.ts @@ -10,7 +10,7 @@ const AutosavePosts: CollectionConfig = { }, admin: { useAsTitle: 'title', - defaultColumns: ['title', 'description', 'createdAt'], + defaultColumns: ['title', 'description', 'createdAt', '_status'], preview: () => 'https://payloadcms.com', }, versions: { diff --git a/test/versions/e2e.spec.ts b/test/versions/e2e.spec.ts index 7529be565..d1de2483a 100644 --- a/test/versions/e2e.spec.ts +++ b/test/versions/e2e.spec.ts @@ -118,6 +118,7 @@ describe('versions', () => { autosaveURL = new AdminUrlUtil(serverURL, autosaveCollectionSlug) disablePublishURL = new AdminUrlUtil(serverURL, disablePublishSlug) customIDURL = new AdminUrlUtil(serverURL, customIDSlug) + postURL = new AdminUrlUtil(serverURL, postCollectionSlug) }) // This test has to run before bulk updates that will rename the title @@ -155,6 +156,38 @@ describe('versions', () => { await expect(findTableCell(page, '_status', 'Draft Title')).toContainText('Published') }) + test('bulk publish with autosave documents', async () => { + const title = 'autosave title' + const description = 'autosave description' + await page.goto(autosaveURL.create) + + // fill the fields + await page.locator('#field-title').fill(title) + await page.locator('#field-description').fill(description) + + // wait for autosave + await waitForAutoSaveToRunAndComplete(page) + + // go to list + await page.goto(autosaveURL.list) + + // expect the status to be draft + await expect(findTableCell(page, '_status', title)).toContainText('Draft') + + // select the row + // await page.locator('.row-1 .select-row__checkbox').click() + await selectTableRow(page, title) + + // click the publish many + await page.locator('.publish-many__toggle').click() + + // confirm the dialog + await page.locator('#confirm-publish').click() + + // expect the status to be published + await expect(findTableCell(page, '_status', title)).toContainText('Published') + }) + test('bulk update - should unpublish many', async () => { await page.goto(url.list) @@ -539,15 +572,6 @@ describe('versions', () => { await expect(page.locator('#action-save')).not.toBeAttached() }) - }) - describe('posts collection', () => { - beforeAll(() => { - url = new AdminUrlUtil(serverURL, draftCollectionSlug) - autosaveURL = new AdminUrlUtil(serverURL, autosaveCollectionSlug) - disablePublishURL = new AdminUrlUtil(serverURL, disablePublishSlug) - customIDURL = new AdminUrlUtil(serverURL, customIDSlug) - postURL = new AdminUrlUtil(serverURL, postCollectionSlug) - }) test('should show documents title in relationship even if draft document', async () => { await payload.create({