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. 26
      packages/nocodb/tests/unit/rest/tests/filter.test.ts
  2. 11
      tests/playwright/tests/filters.spec.ts

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

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

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

@ -144,13 +144,18 @@ test.describe('Filter Tests: Numerical', () => {
{
op: '<',
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: '<=',
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,
},
];

Loading…
Cancel
Save