Files
nocodb/tests/playwright/pages/Dashboard/common/Cell/TimeCell.ts
Ramesh Mane 56b5264177 Nc feat/new date time cell UI (#8546)
* feat(nc-gui): new date picker setup

* feat(nc-gui): new date picker

* fix(nc-gui): date cell form view validation issue

* fix(nc-gui): disable date cell type support in mobile view

* fix(nc-gui): small changes

* feat(nc-gui): new cell year and month picker

* fix(nc-gui): add updated date time picker setup

* feat: update date time cell picker

* fix(nc-gui): add now option in time picker

* fix(nc-gui): small changes

* fix(nc-gui): add support to update month, year from date picker

* fix(nc-gui): update date picker select mont/year flow

* fix(test): date selector test case

* fix(nc-gui): update dateTime cell time picker

* fix(test): update time picker test case

* chore(nc-gui): lint

* fix(nc-gui): invalid date issue

* fix(nc-gui): date time picker tab issue

* fix(nc-gui): year cell test fail issue

* fix(nc-gui): date picker filter test fail issue

* fix(test): survey form test fail issue

* fix(test): update year field fill handler test case

* fix(test): update bulk update test

* fix(nc-gui): datetime multiple api call issue

* fix(test): update timezone related test

* fix(test): timezone related test update

* fix(nc-gui): tab focus issue

* fix(test): filter datetime test udpate

* fix(test): ai review changes

* fix(nc-gui): date picker font weight issue

* fix(nc-gui): update year picker font weight

* fix(nc-gui): show full date from date time cell instead of truncate

* fix(nc-gui): date time picker ui changes

* fix(nc-gui): date time cell width issue

* fix(nc-gui): update datetime time option width according to time format

* fix(nc-gui): disable datetime input if cell is readonly

* fic(nc-gui): add new time picker

* feat(nc-gui): update time picker

* chore(nc-gui): cleanup unwanted code

* fix(test): update time cell test cases

* fix(nc-gui): multiple api calls

* fix(test): update time cell filter & bulk update test cases

* fix(test): revert unrelated changes

* fix(nc-gui): pr review changes

* fix(nc-gui): add clear datetime cell icon in non grid view
2024-05-23 18:18:24 +05:30

79 lines
2.4 KiB
TypeScript

import { CellPageObject } from '.';
import BasePage from '../../../Base';
import { expect, Locator } from '@playwright/test';
export class TimeCellPageObject extends BasePage {
readonly cell: CellPageObject;
constructor(cell: CellPageObject) {
super(cell.rootPage);
this.cell = cell;
}
get({ index, columnHeader }: { index?: number; columnHeader: string }) {
return this.cell.get({ index, columnHeader });
}
async verify({ index, columnHeader, value }: { index: number; columnHeader: string; value: string }) {
const cell = this.get({ index, columnHeader });
await cell.scrollIntoViewIfNeeded();
await cell.locator(`.nc-time-picker[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,
fillValue,
locator,
selectFromPicker = false,
}: {
hour: number;
minute: number;
fillValue: string;
locator: Locator;
selectFromPicker?: boolean;
}) {
const timeInput = locator.locator('.nc-time-input');
await timeInput.click();
const dropdown = this.rootPage.locator('.nc-picker-time.active');
await dropdown.waitFor({ state: 'visible' });
if (!selectFromPicker) {
await timeInput.fill(fillValue);
await this.rootPage.keyboard.press('Shift+Enter');
await this.rootPage.keyboard.press('Escape');
} else {
await dropdown
.locator(`[data-testid="time-option-${String(hour).padStart(2, '0')}:${String(minute).padStart(2, '0')}"]`)
.scrollIntoViewIfNeeded();
await dropdown
.locator(`[data-testid="time-option-${String(hour).padStart(2, '0')}:${String(minute).padStart(2, '0')}"]`)
.click();
}
await dropdown.waitFor({ state: 'hidden' });
}
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 }).dblclick();
await this.selectTime({
hour: +hour,
minute: +minute,
fillValue: value,
locator: this.get({ index, columnHeader }),
selectFromPicker: +minute === 0 || +minute === 30,
});
}
}