Skip to content

Commit

Permalink
test(e2e): ensure custom publish action can patch document before pub…
Browse files Browse the repository at this point in the history
…lication
  • Loading branch information
juice49 committed Jun 18, 2024
1 parent c384922 commit 26ffe77
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/e2e/tests/document-actions/publish.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,30 @@ test(`document panel displays correct title for published document`, async ({
// Ensure the correct title is displayed after publishing.
expect(page.getByTestId('document-panel-document-title')).toHaveText(title)
})

test(`custom publish action can patch document before publication`, async ({
page,
createDraftDocument,
}) => {
const title = 'Test Title'

const publishKeypress = () => page.locator('body').press('Control+Alt+p')
const documentStatus = page.getByTestId('pane-footer-document-status')
const titleInput = page.getByTestId('field-title').getByTestId('string-input')
const publishedAtInput = page.getByTestId('field-publishedAt').getByTestId('date-input')

await createDraftDocument('/test/content/input-debug;documentActionsTest')
await titleInput.fill(title)

// Wait for the document to be published.
//
// Note: This is invoked using the publish keyboard shortcut, because the publish document action
// has been overridden for the `documentActionsTest` type, and is not visible without opening the
// document actions menu.
await page.waitForTimeout(1_000)
await publishKeypress()
await expect(documentStatus).toContainText('Published just now')

// Ensure the custom publish action succeeded in setting the `publishedAt` field.
await expect(publishedAtInput).toHaveValue(/.*/)
})

0 comments on commit 26ffe77

Please sign in to comment.