From e099a812404a4085367c0270efc40e160aa9c239 Mon Sep 17 00:00:00 2001 From: Raju Udava <86527202+dstala@users.noreply.github.com> Date: Wed, 15 Mar 2023 22:58:04 +0530 Subject: [PATCH] test: filters test for Time Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> --- .../pages/Dashboard/common/Toolbar/Filter.ts | 15 +++++++++++++++ tests/playwright/setup/xcdb-records.ts | 15 +++++++++++++++ tests/playwright/tests/filters.spec.ts | 11 +++++++++++ 3 files changed, 41 insertions(+) diff --git a/tests/playwright/pages/Dashboard/common/Toolbar/Filter.ts b/tests/playwright/pages/Dashboard/common/Toolbar/Filter.ts index c692b0f5e9..ee69da6728 100644 --- a/tests/playwright/pages/Dashboard/common/Toolbar/Filter.ts +++ b/tests/playwright/pages/Dashboard/common/Toolbar/Filter.ts @@ -95,6 +95,21 @@ export class ToolbarFilterPage extends BasePage { await this.rootPage.locator(`.ant-picker-dropdown:visible`); await this.rootPage.locator(`.ant-picker-cell-inner:has-text("${value}")`).click(); break; + case UITypes.Time: + // eslint-disable-next-line no-case-declarations + const time = value.split(':'); + await this.get().locator('.nc-filter-value-select').click(); + await this.rootPage.locator(`.ant-picker-dropdown:visible`); + await this.rootPage + .locator(`.ant-picker-time-panel-column:nth-child(1)`) + .locator(`.ant-picker-time-panel-cell:has-text("${time[0]}")`) + .click(); + await this.rootPage + .locator(`.ant-picker-time-panel-column:nth-child(2)`) + .locator(`.ant-picker-time-panel-cell:has-text("${time[1]}")`) + .click(); + await this.rootPage.locator(`.ant-btn-primary:has-text("Ok")`).click(); + break; case UITypes.Date: if (opSubType === 'exact date') { await this.get().locator('.nc-filter-value-select').click(); diff --git a/tests/playwright/setup/xcdb-records.ts b/tests/playwright/setup/xcdb-records.ts index 61b4bf3e20..a6f3040973 100644 --- a/tests/playwright/setup/xcdb-records.ts +++ b/tests/playwright/setup/xcdb-records.ts @@ -40,6 +40,19 @@ const rowMixedValue = (column: ColumnType, index: number) => { 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 = [ + '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, + ]; 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]; @@ -134,6 +147,8 @@ const rowMixedValue = (column: ColumnType, index: number) => { return multiSelect[index % multiSelect.length]; case UITypes.Year: return years[index % years.length]; + case UITypes.Time: + return time[index % time.length]; default: return `test-${index}`; } diff --git a/tests/playwright/tests/filters.spec.ts b/tests/playwright/tests/filters.spec.ts index 6ce1d09474..9addd9244b 100644 --- a/tests/playwright/tests/filters.spec.ts +++ b/tests/playwright/tests/filters.spec.ts @@ -19,6 +19,7 @@ const skipList = { Currency: ['is null', 'is not null'], Rating: ['is null', 'is not null', 'is blank', 'is not blank'], Duration: ['is null', 'is not null'], + Time: ['is null', 'is not null'], SingleLineText: [], MultiLineText: [], Email: [], @@ -261,6 +262,11 @@ test.describe('Filter Tests: Numerical', () => { title: 'Year', uidt: UITypes.Year, }, + { + column_name: 'Time', + title: 'Time', + uidt: UITypes.Time, + }, ]; try { @@ -281,6 +287,7 @@ test.describe('Filter Tests: Numerical', () => { Duration: rowMixedValue(columns[5], i), Rating: rowMixedValue(columns[6], i), Year: rowMixedValue(columns[7], i), + Time: rowMixedValue(columns[8], i), }; rowAttributes.push(row); } @@ -319,6 +326,10 @@ test.describe('Filter Tests: Numerical', () => { test('Filter: Year', async () => { await numBasedFilterTest('Year', '2023', '2024'); }); + + test('Filter: Time', async () => { + await numBasedFilterTest('Time', '02:02:00', '04:04:00'); + }); }); // Text based filters