From 6d7916248d3c1d74c77cba8b0b71c15524b76a94 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Thu, 4 Jan 2024 13:19:27 +0000 Subject: [PATCH] test: corrections --- .../unit/model/tests/baseModelSql.test.ts | 8 ++--- .../rest/tests/columnTypeSpecific.test.ts | 4 +-- .../tests/unit/rest/tests/newDataApis.test.ts | 35 ++++++++++++++++--- 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/packages/nocodb/tests/unit/model/tests/baseModelSql.test.ts b/packages/nocodb/tests/unit/model/tests/baseModelSql.test.ts index d694b04169..fe030a6bfa 100644 --- a/packages/nocodb/tests/unit/model/tests/baseModelSql.test.ts +++ b/packages/nocodb/tests/unit/model/tests/baseModelSql.test.ts @@ -98,12 +98,8 @@ function baseModelSqlTests() { bulkData.forEach((inputData: any, index) => { if (isPg(context)) { - inputData.CreatedAt = new Date(inputData.CreatedAt).toISOString(); - inputData.UpdatedAt = new Date(inputData.UpdatedAt).toISOString(); - } else if (isSqlite(context)) { - // append +00:00 to the date string - inputData.CreatedAt = `${inputData.CreatedAt}+00:00`; - inputData.UpdatedAt = `${inputData.UpdatedAt}+00:00`; + inputData.CreatedAt = insertedRows[index].CreatedAt + inputData.UpdatedAt = insertedRows[index].UpdatedAt } expect(insertedRows[index]).to.include(inputData); }); diff --git a/packages/nocodb/tests/unit/rest/tests/columnTypeSpecific.test.ts b/packages/nocodb/tests/unit/rest/tests/columnTypeSpecific.test.ts index 1299eda23f..33c6ede84e 100644 --- a/packages/nocodb/tests/unit/rest/tests/columnTypeSpecific.test.ts +++ b/packages/nocodb/tests/unit/rest/tests/columnTypeSpecific.test.ts @@ -197,10 +197,10 @@ function columnTypeSpecificTests() { // calculate difference between current date time and stored date time const difference = currentDateTime.getTime() - storedDateTime.getTime(); - expect(difference).to.be.lessThan(1000); + expect(difference).to.be.lessThan(2000); expect(unfilteredRecords[0].CreatedAt).to.not.equal(null); - expect(unfilteredRecords[0].LastModifiedAt).to.equal(null); + expect(unfilteredRecords[0].UpdatedAt).to.equal(null); }); it('Modify record: verify last-modified-at is updated', async () => { diff --git a/packages/nocodb/tests/unit/rest/tests/newDataApis.test.ts b/packages/nocodb/tests/unit/rest/tests/newDataApis.test.ts index 15f9005df6..f6421c2bb0 100644 --- a/packages/nocodb/tests/unit/rest/tests/newDataApis.test.ts +++ b/packages/nocodb/tests/unit/rest/tests/newDataApis.test.ts @@ -741,10 +741,15 @@ function textBased() { }); // fetch records from view - const rsp = await ncAxiosGet({ query: { viewId: gridView.id } }); + const rsp = await ncAxiosGet({ + query: { viewId: gridView.id }, + }); expect(rsp.body.pageInfo.totalRows).to.equal(61); const displayColumns = columns.filter( - (c) => c.title !== 'MultiLineText' && c.title !== 'Email', + (c) => + c.title !== 'MultiLineText' && + c.title !== 'Email' && + !isCreatedTimeOrUpdatedTimeCol(c), ); expect(verifyColumnsInRsp(rsp.body.list[0], displayColumns)).to.equal(true); return gridView; @@ -761,7 +766,10 @@ function textBased() { }, }); const displayColumns = columns.filter( - (c) => c.title !== 'MultiLineText' && c.title !== 'Email', + (c) => + c.title !== 'MultiLineText' && + c.title !== 'Email' && + !isCreatedTimeOrUpdatedTimeCol(c), ); expect(rsp.body.pageInfo.totalRows).to.equal(61); expect(verifyColumnsInRsp(rsp.body.list[0], displayColumns)).to.equal(true); @@ -780,7 +788,10 @@ function textBased() { }, }); const displayColumns = columns.filter( - (c) => c.title !== 'MultiLineText' && c.title !== 'Email', + (c) => + c.title !== 'MultiLineText' && + c.title !== 'Email' && + !isCreatedTimeOrUpdatedTimeCol(c), ); expect(rsp.body.pageInfo.totalRows).to.equal(7); expect(verifyColumnsInRsp(rsp.body.list[0], displayColumns)).to.equal(true); @@ -1007,6 +1018,9 @@ function textBased() { it('Update: partial', async function () { const recordBeforeUpdate = await ncAxiosGet({ url: `/api/v2/tables/${table.id}/records/1`, + query: { + fields: 'Id,SingleLineText,MultiLineText', + }, }); const rsp = await ncAxiosPatch({ @@ -1022,6 +1036,9 @@ function textBased() { const recordAfterUpdate = await ncAxiosGet({ url: `/api/v2/tables/${table.id}/records/1`, + query: { + fields: 'Id,SingleLineText,MultiLineText', + }, }); expect(recordAfterUpdate.body).to.deep.equal({ ...recordBeforeUpdate.body, @@ -1251,6 +1268,7 @@ function numberBased() { let rsp = await ncAxiosGet({ query: { limit: 10, + fields: 'Id,Number,Decimal,Currency,Percent,Duration,Rating', }, }); const pageInfo = { @@ -1284,6 +1302,9 @@ function numberBased() { // read record with Id 401 rsp = await ncAxiosGet({ url: `/api/v2/tables/${table.id}/records/401`, + query: { + fields: 'Id,Number,Decimal,Currency,Percent,Duration,Rating', + }, }); expect(rsp.body).to.deep.equal({ ...records[0], Id: 401 }); @@ -1329,6 +1350,7 @@ function numberBased() { query: { limit: 4, offset: 400, + fields: 'Id,Number,Decimal,Currency,Percent,Duration,Rating', }, }); @@ -1442,6 +1464,7 @@ function selectBased() { let rsp = await ncAxiosGet({ query: { limit: 10, + fields: 'Id,SingleSelect,MultiSelect', }, }); const pageInfo = { @@ -1475,6 +1498,9 @@ function selectBased() { // read record with Id 401 rsp = await ncAxiosGet({ url: `/api/v2/tables/${table.id}/records/401`, + query: { + fields: 'Id,SingleSelect,MultiSelect', + }, }); expect(rsp.body).to.deep.equal({ Id: 401, ...records[0] }); @@ -1515,6 +1541,7 @@ function selectBased() { query: { limit: 4, offset: 400, + fields: 'Id,SingleSelect,MultiSelect', }, }); expect(rsp.body.list).to.deep.equal(updatedRecords);