Skip to content

Commit

Permalink
test(core): fixes flaky test with document publish (#6595)
Browse files Browse the repository at this point in the history
* test(core): fixes flaky test with document publish

* test(core): use more realistic fix for flaky test
  • Loading branch information
binoy14 committed May 7, 2024
1 parent 0835774 commit 2a8375a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export function DocumentStatus({absoluteDate, draft, published, singleLine}: Doc
return (
<Flex
align={singleLine ? 'center' : 'flex-start'}
data-testid="pane-footer-document-status"
direction={singleLine ? 'row' : 'column'}
gap={2}
wrap="nowrap"
Expand Down
11 changes: 8 additions & 3 deletions test/e2e/tests/inputs/text.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,25 @@ test.describe('inputs: text', () => {
await createDraftDocument('/test/content/book')

const titleInput = page.getByTestId('field-title').getByTestId('string-input')
const paneFooter = page.getByTestId('pane-footer')
const paneFooter = page.getByTestId('pane-footer-document-status')
const publishButton = page.getByTestId('action-Publish')

await titleInput.fill('Title A')

// generally waiting for timeouts is not a good idea but for this specific instance
// since we are using `.fill` and `.click` they can cause the draft creation and publish to happen at the same exact time.
// We are waiting for 1s to make sure the draft actually gets created and click action is not too eager
await page.waitForTimeout(1000)

// Wait for the document to be published.
publishButton.click()
await expect(paneFooter).toContainText('Published just now')
expect(await paneFooter.textContent()).toMatch(/published/i)

// Change the title.
await titleInput.fill('Title B')

// Wait for the document to be published.
publishButton.click()
await expect(paneFooter).toContainText('Published just now')
expect(await paneFooter.textContent()).toMatch(/published/i)
})
})

0 comments on commit 2a8375a

Please sign in to comment.