From c60e93278c28c651e0a31798767f7558fb23ae64 Mon Sep 17 00:00:00 2001 From: Raju Udava <86527202+dstala@users.noreply.github.com> Date: Wed, 29 Mar 2023 17:00:53 +0530 Subject: [PATCH 1/3] test: use dayjs Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> --- tests/playwright/package-lock.json | 11 ++++++++ tests/playwright/package.json | 1 + tests/playwright/tests/filters.spec.ts | 38 ++++++++++++++------------ 3 files changed, 33 insertions(+), 17 deletions(-) diff --git a/tests/playwright/package-lock.json b/tests/playwright/package-lock.json index c0ac282152..046cacca2a 100644 --- a/tests/playwright/package-lock.json +++ b/tests/playwright/package-lock.json @@ -10,6 +10,7 @@ "license": "ISC", "dependencies": { "body-parser": "^1.20.1", + "dayjs": "^1.11.7", "express": "^4.18.2", "nocodb-sdk": "file:../../packages/nocodb-sdk", "xlsx": "^0.18.5" @@ -1183,6 +1184,11 @@ "node": ">= 8" } }, + "node_modules/dayjs": { + "version": "1.11.7", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.7.tgz", + "integrity": "sha512-+Yw9U6YO5TQohxLcIkrXBeY73WP3ejHWVvx8XCk3gxvQDCTEmS48ZrSZCKciI7Bhl/uCMyxYtE9UqRILmFphkQ==" + }, "node_modules/debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", @@ -5796,6 +5802,11 @@ "which": "^2.0.1" } }, + "dayjs": { + "version": "1.11.7", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.7.tgz", + "integrity": "sha512-+Yw9U6YO5TQohxLcIkrXBeY73WP3ejHWVvx8XCk3gxvQDCTEmS48ZrSZCKciI7Bhl/uCMyxYtE9UqRILmFphkQ==" + }, "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", diff --git a/tests/playwright/package.json b/tests/playwright/package.json index 2fddfa4331..16b9708480 100644 --- a/tests/playwright/package.json +++ b/tests/playwright/package.json @@ -44,6 +44,7 @@ }, "dependencies": { "body-parser": "^1.20.1", + "dayjs": "^1.11.7", "express": "^4.18.2", "nocodb-sdk": "file:../../packages/nocodb-sdk", "xlsx": "^0.18.5" diff --git a/tests/playwright/tests/filters.spec.ts b/tests/playwright/tests/filters.spec.ts index facc81e7a0..87afa19387 100644 --- a/tests/playwright/tests/filters.spec.ts +++ b/tests/playwright/tests/filters.spec.ts @@ -5,6 +5,7 @@ import { ToolbarPage } from '../pages/Dashboard/common/Toolbar'; import { UITypes } from 'nocodb-sdk'; import { Api } from 'nocodb-sdk'; import { rowMixedValue } from '../setup/xcdb-records'; +import dayjs from 'dayjs'; let dashboard: DashboardPage, toolbar: ToolbarPage; let context: any; @@ -654,19 +655,23 @@ test.describe('Filter Tests: Select based', () => { // Date & Time related // -test.describe('Filter Tests: Date based', () => { - const today = new Date().setHours(0, 0, 0, 0); - const tomorrow = new Date(new Date().setDate(new Date().getDate() + 1)).setHours(0, 0, 0, 0); - const yesterday = new Date(new Date().setDate(new Date().getDate() - 1)).setHours(0, 0, 0, 0); - const oneWeekAgo = new Date(new Date().setDate(new Date().getDate() - 7)).setHours(0, 0, 0, 0); - const oneWeekFromNow = new Date(new Date().setDate(new Date().getDate() + 7)).setHours(0, 0, 0, 0); - const oneMonthAgo = new Date(new Date().setMonth(new Date().getMonth() - 1)).setHours(0, 0, 0, 0); - const oneMonthFromNow = new Date(new Date().setMonth(new Date().getMonth() + 1)).setHours(0, 0, 0, 0); - const daysAgo45 = new Date(new Date().setDate(new Date().getDate() - 45)).setHours(0, 0, 0, 0); - const daysFromNow45 = new Date(new Date().setDate(new Date().getDate() + 45)).setHours(0, 0, 0, 0); - const thisMonth15 = new Date(new Date().setDate(15)).setHours(0, 0, 0, 0); - const oneYearAgo = new Date(new Date().setFullYear(new Date().getFullYear() - 1)).setHours(0, 0, 0, 0); - const oneYearFromNow = new Date(new Date().setFullYear(new Date().getFullYear() + 1)).setHours(0, 0, 0, 0); +function getUTCEpochTime(date) { + return Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), 0, 0, 0, 0); +} + +test.describe.only('Filter Tests: Date based', () => { + const today = getUTCEpochTime(new Date()); + const tomorrow = getUTCEpochTime(new Date(new Date().setDate(new Date().getDate() + 1))); + const yesterday = getUTCEpochTime(new Date(new Date().setDate(new Date().getDate() - 1))); + const oneWeekAgo = getUTCEpochTime(new Date(new Date().setDate(new Date().getDate() - 7))); + const oneWeekFromNow = getUTCEpochTime(new Date(new Date().setDate(new Date().getDate() + 7))); + const oneMonthAgo = getUTCEpochTime(dayjs().subtract(1, 'month').toDate()); + const oneMonthFromNow = getUTCEpochTime(dayjs().add(1, 'month').toDate()); + const daysAgo45 = getUTCEpochTime(new Date(new Date().setDate(new Date().getDate() - 45))); + const daysFromNow45 = getUTCEpochTime(new Date(new Date().setDate(new Date().getDate() + 45))); + const thisMonth15 = getUTCEpochTime(new Date(new Date().setDate(15))); + const oneYearAgo = getUTCEpochTime(new Date(new Date().setFullYear(new Date().getFullYear() - 1))); + const oneYearFromNow = getUTCEpochTime(new Date(new Date().setFullYear(new Date().getFullYear() + 1))); async function dateTimeBasedFilterTest(dataType, setCount) { await dashboard.closeTab({ title: 'Team & Auth' }); @@ -679,8 +684,7 @@ test.describe('Filter Tests: Date based', () => { // records array with time set to 00:00:00; store time in unix epoch const recordsTimeSetToZero = records.list.map(r => { const date = new Date(r[dataType]); - date.setHours(0, 0, 0, 0); - return date.getTime(); + return getUTCEpochTime(date); }); const isFilterList = [ @@ -977,11 +981,11 @@ test.describe('Filter Tests: Date based', () => { }); test('Date : filters-1', async () => { - await dateTimeBasedFilterTest('Date', 1); + await dateTimeBasedFilterTest('Date', 0); }); test('Date : filters-2', async () => { - await dateTimeBasedFilterTest('Date', 2); + await dateTimeBasedFilterTest('Date', 1); }); }); From 0fab004a46704ae9b8d4af160d039efd5258f12f Mon Sep 17 00:00:00 2001 From: Raju Udava <86527202+dstala@users.noreply.github.com> Date: Wed, 29 Mar 2023 17:10:10 +0530 Subject: [PATCH 2/3] test: disable .only Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> --- tests/playwright/tests/filters.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/playwright/tests/filters.spec.ts b/tests/playwright/tests/filters.spec.ts index 87afa19387..f3a16de396 100644 --- a/tests/playwright/tests/filters.spec.ts +++ b/tests/playwright/tests/filters.spec.ts @@ -659,7 +659,7 @@ function getUTCEpochTime(date) { return Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), 0, 0, 0, 0); } -test.describe.only('Filter Tests: Date based', () => { +test.describe('Filter Tests: Date based', () => { const today = getUTCEpochTime(new Date()); const tomorrow = getUTCEpochTime(new Date(new Date().setDate(new Date().getDate() + 1))); const yesterday = getUTCEpochTime(new Date(new Date().setDate(new Date().getDate() - 1))); From efeb30f26252ef4791ef2a02d83827b7f0c45462 Mon Sep 17 00:00:00 2001 From: Raju Udava <86527202+dstala@users.noreply.github.com> Date: Wed, 29 Mar 2023 18:07:31 +0530 Subject: [PATCH 3/3] test: treeview width fix Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> --- tests/playwright/pages/Dashboard/TreeView.ts | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/tests/playwright/pages/Dashboard/TreeView.ts b/tests/playwright/pages/Dashboard/TreeView.ts index 9cc622b461..75c02c04f3 100644 --- a/tests/playwright/pages/Dashboard/TreeView.ts +++ b/tests/playwright/pages/Dashboard/TreeView.ts @@ -23,10 +23,24 @@ export class TreeViewPage extends BasePage { } async verifyVisibility({ isVisible }: { isVisible: boolean }) { - if (isVisible) { - await expect(this.get()).toBeVisible(); + await this.rootPage.waitForTimeout(1000); + + const domElement = await this.get(); + // get width of treeview dom element + const width = (await domElement.boundingBox()).width; + + // if (isVisible) { + // await expect(this.get()).toBeVisible(); + // } else { + // await expect(this.get()).not.toBeVisible(); + // } + + // border for treeview is 1px + // if not-visible, width should be < 5; + if (!isVisible) { + expect(width).toBeLessThan(5); } else { - await expect(this.get()).not.toBeVisible(); + expect(width).toBeGreaterThan(5); } }