Skip to content

Commit 0bd3353

Browse files
authored
fix: greater than equal admin filter not working (#3306)
1 parent e8e1ba0 commit 0bd3353

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

src/admin/components/elements/WhereBuilder/field-types.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const numeric = [
4141
},
4242
{
4343
label: 'isGreaterThanOrEqualTo',
44-
value: 'greater_than_equals',
44+
value: 'greater_than_equal',
4545
},
4646
];
4747

test/fields/config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ export default buildConfigWithDefaults({
137137
await payload.create({ collection: 'rich-text-fields', data: richTextBulletsDoc });
138138
await payload.create({ collection: 'rich-text-fields', data: richTextDocWithRelationship });
139139

140+
await payload.create({ collection: 'number-fields', data: { number: 2 } });
141+
await payload.create({ collection: 'number-fields', data: { number: 3 } });
140142
await payload.create({ collection: 'number-fields', data: numberDoc });
141143

142144
const blocksDocWithRichText = { ...blocksDoc };

test/fields/e2e.spec.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,43 @@ describe('fields', () => {
8080
.toHaveText(String(numberDoc.number));
8181
});
8282

83+
84+
test('should filter Number fields in the collection view - greaterThanOrEqual', async () => {
85+
await page.goto(url.list);
86+
87+
// should have 3 entries
88+
await expect(page.locator('table >> tbody >> tr')).toHaveCount(3);
89+
90+
// open the filter options
91+
await page.locator('.list-controls__toggle-where').click();
92+
await expect(page.locator('.list-controls__where.rah-static--height-auto')).toBeVisible();
93+
await page.locator('.where-builder__add-first-filter').click();
94+
95+
const initialField = page.locator('.condition__field');
96+
const operatorField = page.locator('.condition__operator');
97+
const valueField = page.locator('.condition__value >> input');
98+
99+
// select Number field to filter on
100+
await initialField.click();
101+
const initialFieldOptions = initialField.locator('.rs__option');
102+
await initialFieldOptions.locator('text=number').first().click();
103+
expect(initialField.locator('.rs__single-value')).toContainText('Number');
104+
105+
// select >= operator
106+
await operatorField.click();
107+
const operatorOptions = operatorField.locator('.rs__option');
108+
await operatorOptions.last().click();
109+
expect(operatorField.locator('.rs__single-value')).toContainText('is greater than or equal to');
110+
111+
// enter value of 3
112+
await valueField.fill('3');
113+
await expect(valueField).toHaveValue('3');
114+
await wait(300);
115+
116+
// should have 2 entries after filtering
117+
await expect(page.locator('table >> tbody >> tr')).toHaveCount(2);
118+
});
119+
83120
test('should create', async () => {
84121
const input = 5;
85122

0 commit comments

Comments
 (0)