Browse Source

test: datetime formula

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
pull/5659/head
Raju Udava 1 year ago
parent
commit
2714657590
  1. 2
      tests/playwright/package.json
  2. 110
      tests/playwright/tests/db/timezone.spec.ts

2
tests/playwright/package.json

@ -11,7 +11,7 @@
"test:repeat": "TRACE=true npx playwright test --workers=4 --repeat-each=12",
"test:quick": "TRACE=true PW_QUICK_TEST=1 npx playwright test --workers=4",
"test:debug": "./startPlayWrightServer.sh; PW_TEST_REUSE_CONTEXT=1 PW_TEST_CONNECT_WS_ENDPOINT=ws://127.0.0.1:31000/ PWDEBUG=console npx playwright test -c playwright.config.ts --headed --project=chromium --retries 0 --timeout 0 --workers 1 --max-failures=1",
"test:debug:interllJ": "TRACE=true PWDEBUG=console npx playwright test --trace on -c playwright.config.ts --headed --project=chromium --retries 0 --workers 1 --max-failures=1",
"test:debug:intelliJ": "TRACE=true PWDEBUG=console npx playwright test --trace on -c playwright.config.ts --headed --project=chromium --retries 0 --workers 1 --max-failures=1",
"test:debug:watch": "npx nodemon -e ts -w ./ -x \"npm run test:debug\"",
"test:debug:quick:sqlite": "./startPlayWrightServer.sh; PW_QUICK_TEST=1 PW_TEST_REUSE_CONTEXT=1 PW_TEST_CONNECT_WS_ENDPOINT=ws://127.0.0.1:31000/ PWDEBUG=console npx playwright test -c playwright.config.ts --headed --project=chromium --retries 0 --timeout 5 --workers 1 --max-failures=1",
"ci:test": "npx playwright test --workers=2",

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

@ -558,11 +558,29 @@ test.describe.serial('External DB - DateTime column', async () => {
await createTableWithDateTimeColumn(context.dbType);
});
test.skip('Formula, verify display value', async () => {
test('Formula, verify display value', async () => {
await connectToExtDb(context);
await dashboard.rootPage.reload();
await dashboard.rootPage.waitForTimeout(2000);
// insert a record to work with formula experiments
//
await dashboard.treeView.openBase({ title: 'datetimetable' });
await dashboard.treeView.openTable({ title: 'MyTable' });
// Insert new row
await dashboard.grid.cell.dateTime.setDateTime({
index: 2,
columnHeader: 'DatetimeWithoutTz',
dateTime: '2023-04-27 10:00:00',
});
await dashboard.rootPage.waitForTimeout(1000);
await dashboard.grid.cell.dateTime.setDateTime({
index: 2,
columnHeader: 'DatetimeWithTz',
dateTime: '2023-04-27 10:00:00',
});
// Create formula column (dummy)
api = new Api({
baseURL: `http://localhost:8080/`,
headers: {
@ -571,40 +589,90 @@ test.describe.serial('External DB - DateTime column', async () => {
});
const projectList = await api.project.list();
const table = await api.dbTable.list(projectList.list[0].id);
await api.dbTableColumn.create(table.list[0].id, {
let table_data: any;
table_data = await api.dbTableColumn.create(table.list[0].id, {
title: 'formula-1',
uidt: UITypes.Formula,
formula_raw: 'DATEADD(DatetimeWithoutTz, 1, "day")',
formula_raw: '0',
});
const table2 = await api.dbTableColumn.create(table.list[0].id, {
table_data = await api.dbTableColumn.create(table.list[0].id, {
title: 'formula-2',
uidt: UITypes.Formula,
formula_raw: 'DATEADD(DatetimeWithTz, 1, "day")',
formula_raw: '0',
});
await api.dbTableColumn.update(table2.columns[3].id, {
title: 'formula-23',
column_name: 'formula-23',
uidt: UITypes.Formula,
formula_raw: 'DATEADD(DatetimeWithTz, 1, "month")',
});
async function verifyFormula({
formula,
expectedDisplayValue,
}: {
formula: string[];
expectedDisplayValue: string[];
}) {
// Update formula column to compute "month" instead of "day"
await api.dbTableColumn.update(table_data.columns[3].id, {
title: 'formula-1',
column_name: 'formula-1',
uidt: UITypes.Formula,
formula_raw: formula[0],
});
await dashboard.rootPage.waitForTimeout(1000);
await api.dbTableColumn.update(table_data.columns[4].id, {
title: 'formula-2',
column_name: 'formula-2',
uidt: UITypes.Formula,
formula_raw: formula[1],
});
await dashboard.treeView.openBase({ title: 'datetimetable' });
await dashboard.treeView.openTable({ title: 'MyTable' });
// Insert new row
await dashboard.grid.cell.dateTime.setDateTime({
index: 2,
columnHeader: 'DatetimeWithoutTz',
dateTime: '2023-04-27 10:00:00',
// reload page
await dashboard.rootPage.reload();
await dashboard.grid.cell.verify({
index: 2,
columnHeader: 'formula-1',
value: expectedDisplayValue[0],
});
await dashboard.grid.cell.verify({
index: 2,
columnHeader: 'formula-2',
value: expectedDisplayValue[1],
});
}
// verify display value for formula columns (formula-1, formula-2)
await verifyFormula({
formula: ['DATEADD(DatetimeWithoutTz, 1, "day")', 'DATEADD(DatetimeWithTz, 1, "day")'],
expectedDisplayValue: ['2023-04-28 10:00', '2023-04-28 10:00'],
});
await dashboard.rootPage.waitForTimeout(1000);
await verifyFormula({
formula: ['DATEADD(DatetimeWithoutTz, 1, "month")', 'DATEADD(DatetimeWithTz, 1, "month")'],
expectedDisplayValue: ['2023-05-28 10:00', '2023-05-28 10:00'],
});
await verifyFormula({
formula: ['DATEADD(DatetimeWithoutTz, 1, "year")', 'DATEADD(DatetimeWithTz, 1, "year")'],
expectedDisplayValue: ['2024-05-28 10:00', '2024-05-28 10:00'],
});
await dashboard.grid.cell.dateTime.setDateTime({
index: 2,
columnHeader: 'DatetimeWithTz',
dateTime: '2023-04-27 10:00:00',
dateTime: '2024-04-27 10:00:00',
});
console.log(table);
await verifyFormula({
formula: [
'DATETIME_DIFF({DatetimeWithoutTz}, {DatetimeWithTz}, "days")',
'DATETIME_DIFF({DatetimeWithTz}, {DatetimeWithoutTz}, "days")',
],
expectedDisplayValue: ['-366', '366'],
});
await verifyFormula({
formula: [
'DATETIME_DIFF({DatetimeWithoutTz}, {DatetimeWithTz}, "months")',
'DATETIME_DIFF({DatetimeWithTz}, {DatetimeWithoutTz}, "months")',
],
expectedDisplayValue: ['-12', '12'],
});
});
test('Verify display value, UI insert, API response', async () => {

Loading…
Cancel
Save