Browse Source

test: extDB for PG

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
pull/5601/head
Raju Udava 2 years ago
parent
commit
644a002758
  1. 32
      tests/playwright/tests/db/timezone.spec.ts

32
tests/playwright/tests/db/timezone.spec.ts

@ -4,7 +4,7 @@ import setup from '../../setup';
import { knex } from 'knex'; import { knex } from 'knex';
import { Api, UITypes } from 'nocodb-sdk'; import { Api, UITypes } from 'nocodb-sdk';
import { ProjectsPage } from '../../pages/ProjectsPage'; import { ProjectsPage } from '../../pages/ProjectsPage';
import { isSqlite } from '../../setup/db'; import { isMysql, isPg, isSqlite } from '../../setup/db';
let api: Api<any>, records: any[]; let api: Api<any>, records: any[];
const columns = [ const columns = [
@ -460,7 +460,7 @@ async function createTableWithDateTimeColumn(database: string) {
} }
} }
test.describe.skip('External DB - DateTime column', async () => { test.describe('External DB - DateTime column', async () => {
let dashboard: DashboardPage; let dashboard: DashboardPage;
let context: any; let context: any;
@ -482,22 +482,27 @@ test.describe.skip('External DB - DateTime column', async () => {
await createTableWithDateTimeColumn(context.dbType); await createTableWithDateTimeColumn(context.dbType);
if (isPg(context)) {
await api.base.create(context.project.id, { await api.base.create(context.project.id, {
alias: 'datetimetable', alias: 'datetimetable',
type: 'mysql2', type: 'pg',
config: { config: {
client: 'mysql', client: 'pg',
connection: { connection: {
host: 'localhost', host: 'localhost',
port: '3306', port: '5432',
user: 'root', user: 'postgres',
password: 'password', password: 'password',
database: 'datetimetable', database: 'datetimetable',
}, },
searchPath: ['public'],
}, },
inflection_column: 'camelize', inflection_column: 'camelize',
inflection_table: 'camelize', inflection_table: 'camelize',
}); });
} else if (isMysql(context)) {
} else if (isSqlite(context)) {
}
await dashboard.rootPage.reload(); await dashboard.rootPage.reload();
}); });
@ -542,6 +547,19 @@ test.describe.skip('External DB - DateTime column', async () => {
dateTime: '2023-04-27 12:30:00', dateTime: '2023-04-27 12:30:00',
}); });
// reload page & verify if inserted values are shown correctly
await dashboard.rootPage.reload();
await dashboard.grid.cell.verifyDateCell({
index: 2,
columnHeader: 'DatetimeWithoutTz',
value: '2023-04-27 10:00',
});
await dashboard.grid.cell.verifyDateCell({
index: 2,
columnHeader: 'DatetimeWithTz',
value: '2023-04-27 12:30',
});
// verify API response // verify API response
// Note that, for UI inserted records - second part of datetime may be non-zero (though not shown in UI) // Note that, for UI inserted records - second part of datetime may be non-zero (though not shown in UI)
// Hence, we skip seconds from API response // Hence, we skip seconds from API response
@ -552,12 +570,14 @@ test.describe.skip('External DB - DateTime column', async () => {
const expectedDateTimeWithoutTz = ['2023-04-27 10:00:00', '2023-04-27 10:00:00', '2023-04-27 10:00:00']; const expectedDateTimeWithoutTz = ['2023-04-27 10:00:00', '2023-04-27 10:00:00', '2023-04-27 10:00:00'];
const expectedDateTimeWithTz = ['2023-04-27T04:30:00.000Z', '2023-04-27T04:30:00.000Z', '2023-04-27T04:30:00.000Z']; const expectedDateTimeWithTz = ['2023-04-27T04:30:00.000Z', '2023-04-27T04:30:00.000Z', '2023-04-27T04:30:00.000Z'];
// reset seconds to 0
dateTimeWithoutTz = dateTimeWithoutTz.map(dateTimeStr => { dateTimeWithoutTz = dateTimeWithoutTz.map(dateTimeStr => {
const [datePart, timePart] = dateTimeStr.split(' '); const [datePart, timePart] = dateTimeStr.split(' ');
const updatedTimePart = timePart.split(':').slice(0, 2).join(':') + ':00'; const updatedTimePart = timePart.split(':').slice(0, 2).join(':') + ':00';
return `${datePart} ${updatedTimePart}`; return `${datePart} ${updatedTimePart}`;
}); });
// reset seconds to 0
dateTimeWithTz = dateTimeWithTz.map(dateTimeStr => { dateTimeWithTz = dateTimeWithTz.map(dateTimeStr => {
const dateObj = new Date(dateTimeStr); const dateObj = new Date(dateTimeStr);
dateObj.setSeconds(0); dateObj.setSeconds(0);

Loading…
Cancel
Save