Browse Source

feat(test): Added test for clipboard support(disabled for now)

pull/4514/head
Muhammed Mustafa 2 years ago committed by Pranav C
parent
commit
f75c256935
  1. 2
      tests/playwright/pages/Dashboard/Grid/Column/index.ts
  2. 35
      tests/playwright/pages/Dashboard/common/Cell/DateCell.ts
  3. 10
      tests/playwright/pages/Dashboard/common/Cell/index.ts
  4. 110
      tests/playwright/tests/gridOperations.spec.ts

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

@ -155,7 +155,7 @@ export class ColumnPageObject extends BasePage {
await this.get().locator('.ant-select-selection-search-input[aria-expanded="true"]').fill(type);
// Select column type
await this.rootPage.locator(`text=${type}`).nth(1).click();
await this.rootPage.locator('.rc-virtual-list-holder-inner > div').locator(`text="${type}"`).click();
}
async changeReferencedColumnForQrCode({ titleOfReferencedColumn }: { titleOfReferencedColumn: string }) {

35
tests/playwright/pages/Dashboard/common/Cell/DateCell.ts

@ -0,0 +1,35 @@
import { CellPageObject } from '.';
import BasePage from '../../../Base';
export class DateCellPageObject 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 open({ index, columnHeader }: { index: number; columnHeader: string }) {
await this.cell.dblclick({
index,
columnHeader,
});
}
async selectDate({
// date in format `YYYY-MM-DD`
date,
}: {
date: string;
}) {
await this.rootPage.locator(`td[title="${date}"]`).click();
}
async close() {
await this.rootPage.keyboard.press('Escape');
}
}

10
tests/playwright/pages/Dashboard/common/Cell/index.ts

@ -6,6 +6,7 @@ import { SelectOptionCellPageObject } from './SelectOptionCell';
import { SharedFormPage } from '../../../SharedForm';
import { CheckboxCellPageObject } from './CheckboxCell';
import { RatingCellPageObject } from './RatingCell';
import { DateCellPageObject } from './DateCell';
export class CellPageObject extends BasePage {
readonly parent: GridPage | SharedFormPage;
@ -13,6 +14,8 @@ export class CellPageObject extends BasePage {
readonly attachment: AttachmentCellPageObject;
readonly checkbox: CheckboxCellPageObject;
readonly rating: RatingCellPageObject;
readonly date: DateCellPageObject;
constructor(parent: GridPage | SharedFormPage) {
super(parent.rootPage);
this.parent = parent;
@ -20,6 +23,7 @@ export class CellPageObject extends BasePage {
this.attachment = new AttachmentCellPageObject(this);
this.checkbox = new CheckboxCellPageObject(this);
this.rating = new RatingCellPageObject(this);
this.date = new DateCellPageObject(this);
}
get({ index, columnHeader }: { index?: number; columnHeader: string }): Locator {
@ -179,4 +183,10 @@ export class CellPageObject extends BasePage {
param.role === 'creator' || param.role === 'editor' ? 1 : 0
);
}
async copyToClipboard({ index, columnHeader }: { index: number; columnHeader: string }) {
await this.get({ index, columnHeader }).click();
await this.get({ index, columnHeader }).press('Control+C');
}
}

110
tests/playwright/tests/gridOperations.spec.ts

@ -0,0 +1,110 @@
import { expect, test } from '@playwright/test';
import { DashboardPage } from '../pages/Dashboard';
import setup from '../setup';
test.describe('Grid operations', () => {
let dashboard: DashboardPage;
let context: any;
test.beforeEach(async ({ page }) => {
context = await setup({ page });
dashboard = new DashboardPage(page, context.project);
});
test.skip('Clipboard support', async () => {
// close 'Team & Auth' tab
await dashboard.closeTab({ title: 'Team & Auth' });
await dashboard.treeView.createTable({ title: 'Sheet1' });
await dashboard.grid.column.create({
title: 'Number',
type: 'Number',
});
await dashboard.grid.column.create({
title: 'Checkbox',
type: 'Checkbox',
});
await dashboard.grid.column.create({
title: 'Date',
type: 'Date',
});
await dashboard.grid.column.create({
title: 'Attachment',
type: 'Attachment',
});
await dashboard.grid.addNewRow({
index: 0,
});
await dashboard.grid.cell.click({
index: 0,
columnHeader: 'Number',
});
await dashboard.grid.cell.fillText({
index: 0,
columnHeader: 'Number',
text: '123',
});
await dashboard.grid.cell.click({
index: 0,
columnHeader: 'Checkbox',
});
const today = new Date().toISOString().slice(0, 10);
await dashboard.grid.cell.date.open({
index: 0,
columnHeader: 'Date',
});
await dashboard.grid.cell.date.selectDate({
date: today,
});
await dashboard.grid.cell.date.close();
await dashboard.grid.cell.attachment.addFile({
index: 0,
columnHeader: 'Attachment',
filePath: `${process.cwd()}/fixtures/sampleFiles/1.json`,
});
await dashboard.grid.cell.copyToClipboard({
index: 0,
columnHeader: 'Title',
});
expect(await dashboard.grid.cell.getClipboardText()).toBe('Row 0');
await dashboard.grid.cell.copyToClipboard({
index: 0,
columnHeader: 'Number',
});
expect(await dashboard.grid.cell.getClipboardText()).toBe('123');
await dashboard.grid.cell.copyToClipboard({
index: 0,
columnHeader: 'Checkbox',
});
expect(await dashboard.grid.cell.getClipboardText()).toBe('true');
await dashboard.grid.cell.click({
index: 0,
columnHeader: 'Checkbox',
});
await dashboard.grid.cell.copyToClipboard({
index: 0,
columnHeader: 'Checkbox',
});
expect(await dashboard.grid.cell.getClipboardText()).toBe('false');
await dashboard.grid.cell.copyToClipboard({
index: 0,
columnHeader: 'Date',
});
expect(await dashboard.grid.cell.getClipboardText()).toBe(today);
await dashboard.grid.cell.copyToClipboard({
index: 0,
columnHeader: 'Attachment',
});
expect(await dashboard.grid.cell.getClipboardText()).toBe('1.json');
});
});
Loading…
Cancel
Save