Browse Source

feat(playwright): Added tests for Currency, Duration, Rating

pull/4552/head
Muhammed Mustafa 2 years ago
parent
commit
295d0deaa8
  1. 16
      tests/playwright/pages/Dashboard/Grid/Column/index.ts
  2. 8
      tests/playwright/pages/Dashboard/common/Cell/RatingCell.ts
  3. 60
      tests/playwright/tests/keyboardShortcuts.spec.ts

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

@ -34,7 +34,7 @@ export class ColumnPageObject extends BasePage {
childColumn = '',
relationType = '',
rollupType = '',
format = '',
format,
insertAfterColumnTitle,
insertBeforeColumnTitle,
}: {
@ -81,12 +81,14 @@ export class ColumnPageObject extends BasePage {
});
break;
case 'Duration':
await this.get().locator('.ant-select-single').nth(1).click();
await this.rootPage
.locator(`.ant-select-item`, {
hasText: format,
})
.click();
if (format) {
await this.get().locator('.ant-select-single').nth(1).click();
await this.rootPage
.locator(`.ant-select-item`, {
hasText: format,
})
.click();
}
break;
case 'Formula':
await this.get().locator('.nc-formula-input').fill(formula);

8
tests/playwright/pages/Dashboard/common/Cell/RatingCell.ts

@ -14,6 +14,14 @@ export class RatingCellPageObject extends BasePage {
return this.cell.get({ index, columnHeader });
}
async select({ index, columnHeader, rating }: { index?: number; columnHeader: string; rating: number }) {
await this.waitForResponse({
uiAction: this.get({ index, columnHeader }).locator('.ant-rate-star > div').nth(rating).click(),
httpMethodsToMatch: ['POST', 'PATCH'],
requestUrlPathToMatch: 'api/v1/db/data/noco/',
});
}
async verify({ index, columnHeader, rating }: { index?: number; columnHeader: string; rating: number }) {
await expect(await this.get({ index, columnHeader }).locator(`div[role="radio"][aria-checked="true"]`)).toHaveCount(
rating

60
tests/playwright/tests/keyboardShortcuts.spec.ts

@ -140,6 +140,18 @@ test.describe('Verify shortcuts', () => {
title: 'Percent',
type: 'Percent',
});
await dashboard.grid.column.create({
title: 'Currency',
type: 'Currency',
});
await dashboard.grid.column.create({
title: 'Duration',
type: 'Duration',
});
await dashboard.grid.column.create({
title: 'Rating',
type: 'Rating',
});
await dashboard.grid.column.create({
title: 'SingleSelect',
type: 'SingleSelect',
@ -258,6 +270,31 @@ test.describe('Verify shortcuts', () => {
text: '80',
});
await dashboard.grid.cell.click({
index: 0,
columnHeader: 'Currency',
});
await dashboard.grid.cell.fillText({
index: 0,
columnHeader: 'Currency',
text: '20',
});
await dashboard.grid.cell.click({
index: 0,
columnHeader: 'Duration',
});
await dashboard.grid.cell.fillText({
index: 0,
columnHeader: 'Duration',
text: '0008',
});
await dashboard.grid.cell.rating.select({
index: 0,
columnHeader: 'Rating',
rating: 3,
});
await dashboard.grid.cell.click({
index: 0,
columnHeader: 'Checkbox',
@ -279,7 +316,7 @@ test.describe('Verify shortcuts', () => {
filePath: `${process.cwd()}/fixtures/sampleFiles/1.json`,
});
// // ########################################
// ########################################
await dashboard.grid.cell.copyToClipboard({
index: 0,
@ -354,6 +391,27 @@ test.describe('Verify shortcuts', () => {
});
expect(await dashboard.grid.cell.getClipboardText()).toBe('80');
await dashboard.grid.cell.copyToClipboard({
index: 0,
columnHeader: 'Currency',
});
expect(await dashboard.grid.cell.getClipboardText()).toBe('20');
await dashboard.grid.cell.copyToClipboard({
index: 0,
columnHeader: 'Duration',
});
expect(await dashboard.grid.cell.getClipboardText()).toBe('480');
await dashboard.grid.cell.copyToClipboard(
{
index: 0,
columnHeader: 'Rating',
},
{ position: { x: 1, y: 1 } }
);
expect(await dashboard.grid.cell.getClipboardText()).toBe('4');
await dashboard.grid.cell.copyToClipboard(
{
index: 0,

Loading…
Cancel
Save