Browse Source

test: handling of rating null values as 0

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
pull/5106/head
Raju Udava 2 years ago
parent
commit
d7f1d683a1
  1. 18
      packages/nocodb/tests/unit/rest/tests/filter.test.ts
  2. 11
      tests/playwright/tests/filters.spec.ts

18
packages/nocodb/tests/unit/rest/tests/filter.test.ts

@ -96,17 +96,23 @@ async function retrieveRecordsAndValidate(
); );
break; break;
case 'lt': case 'lt':
expectedRecords = unfilteredRecords.filter( expectedRecords = unfilteredRecords.filter((record) =>
(record) => title === 'Rating'
(toFloat ? parseFloat(record[title]) : record[title]) < ? (toFloat ? parseFloat(record[title]) : record[title]) <
(toFloat ? parseFloat(filter.value) : filter.value) ||
record[title] === null
: (toFloat ? parseFloat(record[title]) : record[title]) <
(toFloat ? parseFloat(filter.value) : filter.value) && (toFloat ? parseFloat(filter.value) : filter.value) &&
record[title] !== null record[title] !== null
); );
break; break;
case 'lte': case 'lte':
expectedRecords = unfilteredRecords.filter( expectedRecords = unfilteredRecords.filter((record) =>
(record) => title === 'Rating'
(toFloat ? parseFloat(record[title]) : record[title]) <= ? (toFloat ? parseFloat(record[title]) : record[title]) <=
(toFloat ? parseFloat(filter.value) : filter.value) ||
record[title] === null
: (toFloat ? parseFloat(record[title]) : record[title]) <=
(toFloat ? parseFloat(filter.value) : filter.value) && (toFloat ? parseFloat(filter.value) : filter.value) &&
record[title] !== null record[title] !== null
); );

11
tests/playwright/tests/filters.spec.ts

@ -144,13 +144,18 @@ test.describe('Filter Tests: Numerical', () => {
{ {
op: '<', op: '<',
value: isLikeString, value: isLikeString,
rowCount: records.list.filter(r => r[dataType] < parseFloat(isLikeStringDerived) && r[dataType] != null).length, rowCount:
dataType === 'Rating'
? records.list.filter(r => r[dataType] < parseFloat(isLikeStringDerived)).length
: records.list.filter(r => r[dataType] < parseFloat(isLikeStringDerived) && r[dataType] != null).length,
}, },
{ {
op: '<=', op: '<=',
value: isLikeString, value: isLikeString,
rowCount: records.list.filter(r => r[dataType] <= parseFloat(isLikeStringDerived) && r[dataType] != null) rowCount:
.length, dataType === 'Rating'
? records.list.filter(r => r[dataType] <= parseFloat(isLikeStringDerived)).length
: records.list.filter(r => r[dataType] <= parseFloat(isLikeStringDerived) && r[dataType] != null).length,
}, },
]; ];

Loading…
Cancel
Save