From 7aceae951ed20789c4a960a934954ed326ae48ab Mon Sep 17 00:00:00 2001 From: Raju Udava <86527202+dstala@users.noreply.github.com> Date: Fri, 30 Jun 2023 16:28:15 +0530 Subject: [PATCH] test: hardwire time on first cell Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> --- .../pages/Dashboard/common/Cell/TimeCell.ts | 32 +++++++++++++++ tests/playwright/setup/xcdb-records.ts | 41 ++++++------------- .../tests/db/verticalFillHandle.spec.ts | 3 ++ 3 files changed, 48 insertions(+), 28 deletions(-) diff --git a/tests/playwright/pages/Dashboard/common/Cell/TimeCell.ts b/tests/playwright/pages/Dashboard/common/Cell/TimeCell.ts index 737d7b3d8d..897fd91a67 100644 --- a/tests/playwright/pages/Dashboard/common/Cell/TimeCell.ts +++ b/tests/playwright/pages/Dashboard/common/Cell/TimeCell.ts @@ -20,4 +20,36 @@ export class TimeCellPageObject extends BasePage { await cell.locator(`input[title="${value}"]`).waitFor({ state: 'visible' }); await expect(cell.locator(`[title="${value}"]`)).toBeVisible(); } + + async selectTime({ + // hour: 0 - 23 + // minute: 0 - 59 + // second: 0 - 59 + hour, + minute, + }: { + hour: number; + minute: number; + }) { + const timePanel = await this.rootPage.locator('.ant-picker-time-panel-column'); + await timePanel.nth(0).locator('.ant-picker-time-panel-cell').nth(hour).click(); + await timePanel.nth(1).locator('.ant-picker-time-panel-cell').nth(minute).click(); + if (hour < 12) { + await timePanel.nth(2).locator('.ant-picker-time-panel-cell').nth(0).click(); + } else { + await timePanel.nth(2).locator('.ant-picker-time-panel-cell').nth(1).click(); + } + } + + async save() { + await this.rootPage.locator('button:has-text("Ok"):visible').click(); + } + + async set({ index, columnHeader, value }: { index: number; columnHeader: string; value: string }) { + const [hour, minute, _second] = value.split(':'); + await this.get({ index, columnHeader }).click(); + await this.get({ index, columnHeader }).click(); + await this.selectTime({ hour: +hour, minute: +minute }); + await this.save(); + } } diff --git a/tests/playwright/setup/xcdb-records.ts b/tests/playwright/setup/xcdb-records.ts index 279592ac79..75df0bb2fa 100644 --- a/tests/playwright/setup/xcdb-records.ts +++ b/tests/playwright/setup/xcdb-records.ts @@ -48,34 +48,19 @@ const rowMixedValue = (column: ColumnType, index: number, db?: string) => { const numbers = [33, null, 456, 333, 267, 34, 8754, 3234, 44, 33, null]; const decimals = [33.3, 456.34, 333.3, null, 267.5674, 34.0, 8754.0, 3234.547, 44.2647, 33.98, null]; const duration = [60, 120, 180, 3600, 3660, 3720, null, 3780, 60, 120, null]; - const time = - db === 'mysql' - ? [ - `02:02:00`, - `20:20:20`, - `04:04:00`, - `02:02:00`, - `20:20:20`, - `18:18:18`, - null, - `02:02:00`, - `20:20:20`, - `18:18:18`, - null, - ] - : [ - `1999-01-01 02:02:00${timezoneOffset}`, - `1999-01-01 20:20:20${timezoneOffset}`, - `1999-01-01 04:04:00${timezoneOffset}`, - `1999-01-01 02:02:00${timezoneOffset}`, - `1999-01-01 20:20:20${timezoneOffset}`, - `1999-01-01 18:18:18${timezoneOffset}`, - null, - `1999-01-01 02:02:00${timezoneOffset}`, - `1999-01-01 20:20:20${timezoneOffset}`, - `1999-01-01 18:18:18${timezoneOffset}`, - null, - ]; + const time = [ + `1999-01-01 02:02:00${timezoneOffset}`, + `1999-01-01 20:20:20${timezoneOffset}`, + `1999-01-01 04:04:00${timezoneOffset}`, + `1999-01-01 02:02:00${timezoneOffset}`, + `1999-01-01 20:20:20${timezoneOffset}`, + `1999-01-01 18:18:18${timezoneOffset}`, + null, + `1999-01-01 02:02:00${timezoneOffset}`, + `1999-01-01 20:20:20${timezoneOffset}`, + `1999-01-01 18:18:18${timezoneOffset}`, + null, + ]; const rating = [0, 1, 2, 3, null, 0, 4, 5, 0, 1, null]; const years = [2023, null, 1956, 2023, 1967, 2024, 1954, 1924, 2044, 1923, null]; diff --git a/tests/playwright/tests/db/verticalFillHandle.spec.ts b/tests/playwright/tests/db/verticalFillHandle.spec.ts index 90f57721f9..7d62ea3784 100644 --- a/tests/playwright/tests/db/verticalFillHandle.spec.ts +++ b/tests/playwright/tests/db/verticalFillHandle.spec.ts @@ -89,6 +89,9 @@ test.describe('Fill Handle', () => { { title: 'Time', value: '02:02', type: 'time' }, ]; + // kludge: insert time from browser until mysql issue with timezone is fixed + await dashboard.grid.cell.time.set({ index: 0, columnHeader: 'Time', value: '02:02' }); + // set rating for first record await dashboard.grid.cell.rating.select({ index: 0, columnHeader: 'Rating', rating: 2 });