diff --git a/packages/payload/src/admin/components/elements/WhereBuilder/field-types.tsx b/packages/payload/src/admin/components/elements/WhereBuilder/field-types.tsx index 48ca3c485d..55598af862 100644 --- a/packages/payload/src/admin/components/elements/WhereBuilder/field-types.tsx +++ b/packages/payload/src/admin/components/elements/WhereBuilder/field-types.tsx @@ -41,7 +41,7 @@ const numeric = [ }, { label: 'isGreaterThanOrEqualTo', - value: 'greater_than_equals', + value: 'greater_than_equal', }, ] diff --git a/test/fields/config.ts b/test/fields/config.ts index 0fb3e1a92e..711e001b05 100644 --- a/test/fields/config.ts +++ b/test/fields/config.ts @@ -139,6 +139,8 @@ export default buildConfigWithDefaults({ await payload.create({ collection: 'rich-text-fields', data: richTextBulletsDoc }) await payload.create({ collection: 'rich-text-fields', data: richTextDocWithRelationship }) + await payload.create({ collection: 'number-fields', data: { number: 2 } }); + await payload.create({ collection: 'number-fields', data: { number: 3 } }); await payload.create({ collection: 'number-fields', data: numberDoc }) const blocksDocWithRichText = { ...blocksDoc } diff --git a/test/fields/e2e.spec.ts b/test/fields/e2e.spec.ts index 4299e1b225..579741ef8f 100644 --- a/test/fields/e2e.spec.ts +++ b/test/fields/e2e.spec.ts @@ -79,6 +79,43 @@ describe('fields', () => { await expect(textCell).toHaveText(String(numberDoc.number)) }) + + test('should filter Number fields in the collection view - greaterThanOrEqual', async () => { + await page.goto(url.list); + + // should have 3 entries + await expect(page.locator('table >> tbody >> tr')).toHaveCount(3); + + // open the filter options + await page.locator('.list-controls__toggle-where').click(); + await expect(page.locator('.list-controls__where.rah-static--height-auto')).toBeVisible(); + await page.locator('.where-builder__add-first-filter').click(); + + const initialField = page.locator('.condition__field'); + const operatorField = page.locator('.condition__operator'); + const valueField = page.locator('.condition__value >> input'); + + // select Number field to filter on + await initialField.click(); + const initialFieldOptions = initialField.locator('.rs__option'); + await initialFieldOptions.locator('text=number').first().click(); + expect(initialField.locator('.rs__single-value')).toContainText('Number'); + + // select >= operator + await operatorField.click(); + const operatorOptions = operatorField.locator('.rs__option'); + await operatorOptions.last().click(); + expect(operatorField.locator('.rs__single-value')).toContainText('is greater than or equal to'); + + // enter value of 3 + await valueField.fill('3'); + await expect(valueField).toHaveValue('3'); + await wait(300); + + // should have 2 entries after filtering + await expect(page.locator('table >> tbody >> tr')).toHaveCount(2); + }); + test('should create', async () => { const input = 5