Files
payload/test/helpers/e2e/reorderBlocks.ts
Alessio Gravili 319d3355de feat: improve turbopack compatibility (#11376)
This PR introduces a few changes to improve turbopack compatibility and
ensure e2e tests pass with turbopack enabled

## Changes to improve turbopack compatibility
- Use correct sideEffects configuration to fix scss issues
- Import scss directly instead of duplicating our scss rules
- Fix some scss rules that are not supported by turbopack
- Bump Next.js and all other dependencies used to build payload

## Changes to get tests to pass

For an unknown reason, flaky tests flake a lot more often in turbopack.
This PR does the following to get them to pass:
- add more `wait`s
- fix actual flakes by ensuring previous operations are properly awaited

## Blocking turbopack bugs
- [X] https://github.com/vercel/next.js/issues/76464
  - Fix PR: https://github.com/vercel/next.js/pull/76545
  - Once fixed: change `"sideEffectsDisabled":` back to `"sideEffects":`
  
## Non-blocking turbopack bugs
- [ ] https://github.com/vercel/next.js/issues/76956

## Related PRs

https://github.com/payloadcms/payload/pull/12653
https://github.com/payloadcms/payload/pull/12652
2025-06-02 22:01:07 +00:00

44 lines
1.3 KiB
TypeScript

import type { Page } from '@playwright/test'
import { expect } from '@playwright/test'
import { wait } from 'payload/shared'
export const reorderBlocks = async ({
page,
fromBlockIndex = 1,
toBlockIndex = 2,
fieldName = 'blocks',
}: {
fieldName?: string
fromBlockIndex: number
page: Page
toBlockIndex: number
}) => {
// Ensure blocks are loaded
await expect(page.locator('.shimmer-effect')).toHaveCount(0)
const blocksField = page.locator(`#field-${fieldName}`).first()
const fromField = blocksField.locator(`[id^="${fieldName}-row-${fromBlockIndex}"]`)
const fromBoundingBox = await fromField.locator(`.collapsible__drag`).boundingBox()
const toField = blocksField.locator(`[id^="${fieldName}-row-${toBlockIndex}"]`)
const toBoundingBox = await toField.locator(`.collapsible__drag`).boundingBox()
if (!fromBoundingBox || !toBoundingBox) {
return
}
// drag the "from" column to the left of the "to" column
await page.mouse.move(fromBoundingBox.x + 2, fromBoundingBox.y + 2, { steps: 10 })
await page.mouse.down()
await wait(300)
await page.mouse.move(toBoundingBox.x - 2, toBoundingBox.y - 2, { steps: 10 })
await page.mouse.up()
// Ensure blocks are loaded
await expect(page.locator('.shimmer-effect')).toHaveCount(0)
}