Browse Source

test: update unit tests

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/6470/head
Pranav C 1 year ago
parent
commit
d5c5df7621
  1. 80
      packages/nocodb/tests/unit/rest/tests/newDataApis.test.ts
  2. 14
      tests/playwright/tests/db/features/verticalFillHandle.spec.ts
  3. 4
      tests/playwright/tests/utils/general.ts

80
packages/nocodb/tests/unit/rest/tests/newDataApis.test.ts

@ -1231,92 +1231,92 @@ function numberBased() {
const recordsPg = [ const recordsPg = [
{ {
Id: 1, Id: 1,
Number: '33', Number: 33,
Decimal: '33.3', Decimal: 33.3,
Currency: '33.3', Currency: 33.3,
Percent: 33, Percent: 33,
Duration: '10', Duration: 10,
Rating: 0, Rating: 0,
}, },
{ {
Id: 2, Id: 2,
Number: null, Number: null,
Decimal: '456.34', Decimal: 456.34,
Currency: '456.34', Currency: 456.34,
Percent: null, Percent: null,
Duration: '20', Duration: 20,
Rating: 1, Rating: 1,
}, },
{ {
Id: 3, Id: 3,
Number: '456', Number: 456,
Decimal: '333.3', Decimal: 333.3,
Currency: '333.3', Currency: 333.3,
Percent: 456, Percent: 456,
Duration: '30', Duration: 30,
Rating: 2, Rating: 2,
}, },
{ {
Id: 4, Id: 4,
Number: '333', Number: 333,
Decimal: null, Decimal: null,
Currency: null, Currency: null,
Percent: 333, Percent: 333,
Duration: '40', Duration: 40,
Rating: 3, Rating: 3,
}, },
{ {
Id: 5, Id: 5,
Number: '267', Number: 267,
Decimal: '267.5674', Decimal: 267.5674,
Currency: '267.5674', Currency: 267.5674,
Percent: 267, Percent: 267,
Duration: '50', Duration: 50,
Rating: null, Rating: null,
}, },
{ {
Id: 6, Id: 6,
Number: '34', Number: 34,
Decimal: '34', Decimal: 34,
Currency: '34', Currency: 34,
Percent: 34, Percent: 34,
Duration: '60', Duration: 60,
Rating: 0, Rating: 0,
}, },
{ {
Id: 7, Id: 7,
Number: '8754', Number: 8754,
Decimal: '8754', Decimal: 8754,
Currency: '8754', Currency: 8754,
Percent: 8754, Percent: 8754,
Duration: null, Duration: null,
Rating: 4, Rating: 4,
}, },
{ {
Id: 8, Id: 8,
Number: '3234', Number: 3234,
Decimal: '3234.547', Decimal: 3234.547,
Currency: '3234.547', Currency: 3234.547,
Percent: 3234, Percent: 3234,
Duration: '70', Duration: 70,
Rating: 5, Rating: 5,
}, },
{ {
Id: 9, Id: 9,
Number: '44', Number: 44,
Decimal: '44.2647', Decimal: 44.2647,
Currency: '44.2647', Currency: 44.2647,
Percent: 44, Percent: 44,
Duration: '80', Duration: 80,
Rating: 0, Rating: 0,
}, },
{ {
Id: 10, Id: 10,
Number: '33', Number: 33,
Decimal: '33.98', Decimal: 33.98,
Currency: '33.98', Currency: 33.98,
Percent: 33, Percent: 33,
Duration: '90', Duration: 90,
Rating: 1, Rating: 1,
}, },
]; ];
@ -1382,11 +1382,11 @@ function numberBased() {
Rating: 5, Rating: 5,
}; };
const updatedRecordPg = { const updatedRecordPg = {
Number: '55', Number: 55,
Decimal: '55.5', Decimal: 55.5,
Currency: '55.5', Currency: 55.5,
Percent: 55, Percent: 55,
Duration: '55', Duration: 55,
Rating: 5, Rating: 5,
}; };

14
tests/playwright/tests/db/features/verticalFillHandle.spec.ts

@ -97,14 +97,14 @@ test.describe('Fill Handle', () => {
await unsetup(p.context); await unsetup(p.context);
}); });
test('Number based', async () => { test.only('Number based', async () => {
const fields = [ const fields = [
{ title: 'Number', value: '33', type: 'text' }, { title: 'Number', value: 33, type: 'text' },
{ title: 'Decimal', value: '33.3', type: 'text' }, { title: 'Decimal', value: 33.3, type: 'text' },
{ title: 'Currency', value: '33.30', type: 'text' }, { title: 'Currency', value: 33.3, type: 'text' },
{ title: 'Percent', value: '33', type: 'text' }, { title: 'Percent', value: 33, type: 'text' },
{ title: 'Duration', value: '00:01', type: 'text' }, { title: 'Duration', value: '00:01', type: 'text' },
{ title: 'Rating', value: '3', type: 'rating' }, { title: 'Rating', value: 3, type: 'rating' },
{ title: 'Year', value: '2023', type: 'year' }, { title: 'Year', value: '2023', type: 'year' },
{ title: 'Time', value: '02:02', type: 'time' }, { title: 'Time', value: '02:02', type: 'time' },
]; ];
@ -170,7 +170,7 @@ test.describe('Fill Handle', () => {
await dragDrop({ firstColumn: 'SingleSelect', lastColumn: 'MultiSelect', params: p }); await dragDrop({ firstColumn: 'SingleSelect', lastColumn: 'MultiSelect', params: p });
await new Promise((r) => setTimeout(r, 500)); await new Promise(r => setTimeout(r, 500));
// verify data on grid // verify data on grid
const displayOptions = ['jan', 'feb', 'mar']; const displayOptions = ['jan', 'feb', 'mar'];

4
tests/playwright/tests/utils/general.ts

@ -37,10 +37,8 @@ function isSubset(obj, potentialSubset) {
if (!isSubset(objValue, potentialValue)) { if (!isSubset(objValue, potentialValue)) {
return false; return false;
} }
// skip strict type check since different database returns number values in string/number type
// todo: revert back to strict type check once we are consistent with type
// eslint-disable-next-line no-prototype-builtins // eslint-disable-next-line no-prototype-builtins
} else if (!obj.hasOwnProperty(prop) || objValue != potentialValue) { } else if (!obj.hasOwnProperty(prop) || objValue !== potentialValue) {
return false; return false;
} }
} }

Loading…
Cancel
Save