Browse Source

test: common routine for browser timezone

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
pull/5719/head
Raju Udava 1 year ago
parent
commit
7d3e9b3a98
  1. 13
      tests/playwright/tests/db/timezone.spec.ts
  2. 12
      tests/playwright/tests/utils/general.ts

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

@ -6,6 +6,7 @@ import { Api, UITypes } from 'nocodb-sdk';
import { ProjectsPage } from '../../pages/ProjectsPage';
import { isMysql, isPg, isSqlite } from '../../setup/db';
import { getKnexConfig } from '../utils/config';
import { getBrowserTimezoneOffset } from '../utils/general';
let api: Api<any>, records: any[];
const columns = [
@ -680,11 +681,7 @@ test.describe.serial('External DB - DateTime column', async () => {
await dashboard.rootPage.waitForTimeout(2000);
// get timezone offset
const timezoneOffset = new Date().getTimezoneOffset();
const hours = Math.floor(Math.abs(timezoneOffset) / 60);
const minutes = Math.abs(timezoneOffset % 60);
const sign = timezoneOffset <= 0 ? '+' : '-';
const formattedOffset = `${sign}${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`;
const formattedOffset = getBrowserTimezoneOffset();
await dashboard.treeView.openBase({ title: 'datetimetable' });
await dashboard.treeView.openTable({ title: 'MyTable' });
@ -844,11 +841,7 @@ test.describe('Ext DB MySQL : DB Timezone configured as HKT', () => {
}
// get timezone offset
const timezoneOffset = new Date().getTimezoneOffset();
const hours = Math.floor(Math.abs(timezoneOffset) / 60);
const minutes = Math.abs(timezoneOffset % 60);
const sign = timezoneOffset <= 0 ? '+' : '-';
const formattedOffset = `${sign}${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`;
const formattedOffset = getBrowserTimezoneOffset();
// connect after timezone is set
await connectToExtDb(context);

12
tests/playwright/tests/utils/general.ts

@ -50,4 +50,14 @@ function getDefaultPwd() {
return 'Password123.';
}
export { getTextExcludeIconText, isSubset, getIconText, getDefaultPwd };
function getBrowserTimezoneOffset() {
// get timezone offset
const timezoneOffset = new Date().getTimezoneOffset();
const hours = Math.floor(Math.abs(timezoneOffset) / 60);
const minutes = Math.abs(timezoneOffset % 60);
const sign = timezoneOffset <= 0 ? '+' : '-';
const formattedOffset = `${sign}${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`;
return formattedOffset;
}
export { getTextExcludeIconText, isSubset, getIconText, getDefaultPwd, getBrowserTimezoneOffset };

Loading…
Cancel
Save