Browse Source

test: corrections

pull/7304/head
Pranav C 8 months ago
parent
commit
6d7916248d
  1. 8
      packages/nocodb/tests/unit/model/tests/baseModelSql.test.ts
  2. 4
      packages/nocodb/tests/unit/rest/tests/columnTypeSpecific.test.ts
  3. 35
      packages/nocodb/tests/unit/rest/tests/newDataApis.test.ts

8
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);
});

4
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 () => {

35
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);

Loading…
Cancel
Save