Browse Source

feat(playwright): add tests for datetime

pull/4593/head
Wing-Kam Wong 2 years ago
parent
commit
a290876657
  1. 24
      tests/playwright/pages/Dashboard/Grid/Column/index.ts
  2. 69
      tests/playwright/tests/columnDateTime.spec.ts

24
tests/playwright/pages/Dashboard/Grid/Column/index.ts

@ -35,6 +35,8 @@ export class ColumnPageObject extends BasePage {
relationType = '', relationType = '',
rollupType = '', rollupType = '',
format = '', format = '',
dateFormat = '',
timeFormat = '',
insertAfterColumnTitle, insertAfterColumnTitle,
insertBeforeColumnTitle, insertBeforeColumnTitle,
}: { }: {
@ -47,6 +49,8 @@ export class ColumnPageObject extends BasePage {
relationType?: string; relationType?: string;
rollupType?: string; rollupType?: string;
format?: string; format?: string;
dateFormat?: string;
timeFormat?: string;
insertBeforeColumnTitle?: string; insertBeforeColumnTitle?: string;
insertAfterColumnTitle?: string; insertAfterColumnTitle?: string;
}) { }) {
@ -88,6 +92,14 @@ export class ColumnPageObject extends BasePage {
}) })
.click(); .click();
break; break;
case 'DateTime':
// Date Format
await this.get().locator('.nc-date-select').click();
await this.rootPage.locator('.ant-select-item').locator(`text="${dateFormat}"`).click();
// Time Format
await this.get().locator('.nc-time-select').click();
await this.rootPage.locator('.ant-select-item').locator(`text="${timeFormat}"`).click();
break;
case 'Formula': case 'Formula':
await this.get().locator('.nc-formula-input').fill(formula); await this.get().locator('.nc-formula-input').fill(formula);
break; break;
@ -220,11 +232,15 @@ export class ColumnPageObject extends BasePage {
type = 'SingleLineText', type = 'SingleLineText',
formula = '', formula = '',
format, format,
dateFormat = '',
timeFormat = '',
}: { }: {
title: string; title: string;
type?: string; type?: string;
formula?: string; formula?: string;
format?: string; format?: string;
dateFormat?: string;
timeFormat?: string;
}) { }) {
await this.getColumnHeader(title).locator('.nc-ui-dt-dropdown').click(); await this.getColumnHeader(title).locator('.nc-ui-dt-dropdown').click();
await this.rootPage.locator('li[role="menuitem"]:has-text("Edit")').click(); await this.rootPage.locator('li[role="menuitem"]:has-text("Edit")').click();
@ -243,6 +259,14 @@ export class ColumnPageObject extends BasePage {
}) })
.click(); .click();
break; break;
case 'DateTime':
// Date Format
await this.get().locator('.nc-date-select').click();
await this.rootPage.locator('.ant-select-item').locator(`text="${dateFormat}"`).click();
// Time Format
await this.get().locator('.nc-time-select').click();
await this.rootPage.locator('.ant-select-item').locator(`text="${timeFormat}"`).click();
break;
default: default:
break; break;
} }

69
tests/playwright/tests/columnDateTime.spec.ts

@ -0,0 +1,69 @@
import { test } from '@playwright/test';
import { DashboardPage } from '../pages/Dashboard';
import setup from '../setup';
// Storing one additional dummy value "10" at end of every input array
// this will trigger update to previously committed data
const dateTimeData = [
{
dateFormat: 'YYYY-MM-DD',
timeFormat: 'HH:mm',
date: '2022-12-12',
hour: '10',
minute: '20',
},
{
dateFormat: 'YYYY-MM-DD',
timeFormat: 'HH:mm:ss',
date: '2022-12-12',
hour: '10',
minute: '20',
second: '30',
},
];
test.describe('DateTime Column', () => {
let dashboard: DashboardPage;
let context: any;
test.beforeEach(async ({ page }) => {
context = await setup({ page });
dashboard = new DashboardPage(page, context.project);
});
test.only('Create DateTime Column', async () => {
await dashboard.treeView.createTable({ title: 'test_datetime' });
// Create DateTime column
await dashboard.grid.column.create({
title: 'NC_DATETIME_0',
type: 'DateTime',
dateFormat: dateTimeData[0].dateFormat,
timeFormat: dateTimeData[0].timeFormat,
});
await dashboard.grid.cell.dateTime.open({
index: 0,
columnHeader: 'NC_DATETIME_0',
});
await dashboard.grid.cell.dateTime.selectDate({
date: dateTimeData[0],
});
await dashboard.grid.cell.dateTime.selectTime({
hour: dateTimeData[0].hour,
minute: dateTimeData[0].minute,
});
await dashboard.grid.cell.dateTime.close();
for (let i = 0; i < dateTimeData.length; i++) {
// Edit DateTime column
await dashboard.grid.column.openEdit({
title: 'NC_DATETIME_0',
type: 'DateTime',
dateFormat: dateTimeData[i].dateFormat,
timeFormat: dateTimeData[i].timeFormat,
});
// TODO: ...
}
});
});
Loading…
Cancel
Save