Files
payloadcms/test/helpers/folders/clickFolderCard.ts
Jarrod Flesch 12539c61d4 feat(ui): supports collection scoped folders (#12797)
As discussed in [this
RFC](https://github.com/payloadcms/payload/discussions/12729), this PR
supports collection-scoped folders. You can scope folders to multiple
collection types or just one.

This unlocks the possibility to have folders on a per collection instead
of always being shared on every collection. You can combine this feature
with the `browseByFolder: false` to completely isolate a collection from
other collections.

Things left to do:
- [x] ~~Create a custom react component for the selecting of
collectionSlugs to filter out available options based on the current
folders parameters~~


https://github.com/user-attachments/assets/14cb1f09-8d70-4cb9-b1e2-09da89302995


---
- To see the specific tasks where the Asana app for GitHub is being
used, see below:
  - https://app.asana.com/0/0/1210564397815557
2025-07-17 13:24:22 -04:00

38 lines
944 B
TypeScript

import type { Locator, Page } from '@playwright/test'
import { expect } from '@playwright/test'
type Args = {
doubleClick?: boolean
folderName: string
page: Page
rootLocator?: Locator
}
export async function clickFolderCard({
page,
folderName,
doubleClick = false,
rootLocator,
}: Args): Promise<void> {
const folderCard = (rootLocator || page)
.locator('div[role="button"].draggable-with-click')
.filter({
has: page.locator('.folder-file-card__name', { hasText: folderName }),
})
.first()
await folderCard.waitFor({ state: 'visible' })
if (doubleClick) {
// Release any modifier keys that might be held down from previous tests
await page.keyboard.up('Shift')
await page.keyboard.up('Control')
await page.keyboard.up('Alt')
await page.keyboard.up('Meta')
await folderCard.dblclick()
await expect(folderCard).toBeHidden()
} else {
await folderCard.click()
}
}