fix(payload, db-mongodb): querying relationships with in & not_in (#6773)
## Description Fixes #6741 - [x] I have read and understand the [CONTRIBUTING.md](https://github.com/payloadcms/payload/blob/main/CONTRIBUTING.md) document in this repository. ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) ## Checklist: - [x] I have added tests that prove my fix is effective or that my feature works - [x] Existing test suite passes locally with my changes
This commit is contained in:
@@ -1973,6 +1973,69 @@ describe('fields', () => {
|
||||
|
||||
await expect(page.locator(tableRowLocator)).toHaveCount(1)
|
||||
})
|
||||
|
||||
// TODO: properly handle polymorphic relationship handling with the postgres adapter
|
||||
test('should allow filtering by relationship field / is_in', async () => {
|
||||
const textDoc = await createTextFieldDoc()
|
||||
await createRelationshipFieldDoc({ value: textDoc.id, relationTo: 'text-fields' })
|
||||
|
||||
await page.goto(url.list)
|
||||
|
||||
await page.locator('.list-controls__toggle-columns').click()
|
||||
await page.locator('.list-controls__toggle-where').click()
|
||||
await page.waitForSelector('.list-controls__where.rah-static--height-auto')
|
||||
await page.locator('.where-builder__add-first-filter').click()
|
||||
|
||||
const conditionField = page.locator('.condition__field')
|
||||
await conditionField.click()
|
||||
|
||||
const dropdownFieldOptions = conditionField.locator('.rs__option')
|
||||
await dropdownFieldOptions.locator('text=Relationship').nth(0).click()
|
||||
|
||||
const operatorField = page.locator('.condition__operator')
|
||||
await operatorField.click()
|
||||
|
||||
const dropdownOperatorOptions = operatorField.locator('.rs__option')
|
||||
await dropdownOperatorOptions.locator('text=is in').click()
|
||||
|
||||
const valueField = page.locator('.condition__value')
|
||||
await valueField.click()
|
||||
const dropdownValueOptions = valueField.locator('.rs__option')
|
||||
await dropdownValueOptions.locator('text=some text').click()
|
||||
|
||||
await expect(page.locator(tableRowLocator)).toHaveCount(1)
|
||||
})
|
||||
|
||||
test('should allow filtering by relationship field / not_in', async () => {
|
||||
const textDoc = await createTextFieldDoc()
|
||||
await createRelationshipFieldDoc({ value: textDoc.id, relationTo: 'text-fields' })
|
||||
|
||||
await page.goto(url.list)
|
||||
|
||||
await page.locator('.list-controls__toggle-columns').click()
|
||||
await page.locator('.list-controls__toggle-where').click()
|
||||
await page.waitForSelector('.list-controls__where.rah-static--height-auto')
|
||||
await page.locator('.where-builder__add-first-filter').click()
|
||||
|
||||
const conditionField = page.locator('.condition__field')
|
||||
await conditionField.click()
|
||||
|
||||
const dropdownFieldOptions = conditionField.locator('.rs__option')
|
||||
await dropdownFieldOptions.locator('text=Relationship').nth(0).click()
|
||||
|
||||
const operatorField = page.locator('.condition__operator')
|
||||
await operatorField.click()
|
||||
|
||||
const dropdownOperatorOptions = operatorField.locator('.rs__option')
|
||||
await dropdownOperatorOptions.locator('text=is not in').click()
|
||||
|
||||
const valueField = page.locator('.condition__value')
|
||||
await valueField.click()
|
||||
const dropdownValueOptions = valueField.locator('.rs__option')
|
||||
await dropdownValueOptions.locator('text=some text').click()
|
||||
|
||||
await expect(page.locator(tableRowLocator)).toHaveCount(0)
|
||||
})
|
||||
})
|
||||
|
||||
describe('upload', () => {
|
||||
|
||||
Reference in New Issue
Block a user