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;
case 'lt':
expectedRecords = unfilteredRecords.filter(
(record) =>
(toFloat ? parseFloat(record[title]) : record[title]) <
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]) <=
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
);

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