mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
101 lines
3.3 KiB
101 lines
3.3 KiB
2 years ago
|
import { expect } from '@playwright/test';
|
||
|
import { CellPageObject } from '.';
|
||
|
import BasePage from '../../../Base';
|
||
2 years ago
|
|
||
2 years ago
|
export class SelectOptionCellPageObject extends BasePage {
|
||
2 years ago
|
readonly cell: CellPageObject;
|
||
2 years ago
|
|
||
2 years ago
|
constructor(cell: CellPageObject) {
|
||
2 years ago
|
super(cell.rootPage);
|
||
2 years ago
|
this.cell = cell;
|
||
|
}
|
||
|
|
||
2 years ago
|
get({ index, columnHeader }: { index: number; columnHeader: string }) {
|
||
|
return this.cell.get({ index, columnHeader });
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
async select({
|
||
|
index,
|
||
|
columnHeader,
|
||
|
option,
|
||
|
multiSelect,
|
||
|
}: {
|
||
|
index: number;
|
||
|
columnHeader: string;
|
||
|
option: string;
|
||
|
multiSelect?: boolean;
|
||
|
}) {
|
||
|
await this.get({ index, columnHeader }).click();
|
||
2 years ago
|
|
||
2 years ago
|
await this.rootPage.locator(`[data-nc="select-option-${columnHeader}-${index}"]`, { hasText: option }).click();
|
||
2 years ago
|
|
||
2 years ago
|
if (multiSelect) await this.get({ index, columnHeader }).click();
|
||
2 years ago
|
|
||
2 years ago
|
await this.rootPage
|
||
2 years ago
|
.locator(`[data-nc="select-option-${columnHeader}-${index}"]`, { hasText: option })
|
||
2 years ago
|
.waitFor({ state: 'hidden' });
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
async clear({ index, columnHeader, multiSelect }: { index: number; columnHeader: string; multiSelect?: boolean }) {
|
||
|
if (multiSelect) {
|
||
|
await this.cell.get({ index, columnHeader }).click();
|
||
|
await this.cell.get({ index, columnHeader }).click();
|
||
2 years ago
|
|
||
2 years ago
|
const optionCount = await this.cell.get({ index, columnHeader }).locator('.ant-tag').count();
|
||
2 years ago
|
|
||
2 years ago
|
for (let i = 0; i < optionCount; i++) {
|
||
|
await this.cell.get({ index, columnHeader }).locator('.ant-tag > .ant-tag-close-icon').first().click();
|
||
2 years ago
|
// wait till number of options is less than before
|
||
2 years ago
|
await this.cell
|
||
|
.get({ index, columnHeader })
|
||
|
.locator('.ant-tag')
|
||
|
.nth(optionCount - i - 1)
|
||
|
.waitFor({ state: 'hidden' });
|
||
2 years ago
|
}
|
||
2 years ago
|
return;
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
await this.get({ index, columnHeader }).click();
|
||
2 years ago
|
await this.rootPage.locator('.ant-select-single > .ant-select-clear').click();
|
||
2 years ago
|
await this.cell.get({ index, columnHeader }).click();
|
||
|
await this.rootPage.locator(`.nc-dropdown-single-select-cell`).waitFor({ state: 'hidden' });
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
async verify({
|
||
|
index,
|
||
|
columnHeader,
|
||
|
option,
|
||
|
multiSelect,
|
||
|
}: {
|
||
|
index: number;
|
||
|
columnHeader: string;
|
||
|
option: string;
|
||
|
multiSelect?: boolean;
|
||
|
}) {
|
||
|
if (multiSelect) {
|
||
|
return await expect(this.cell.get({ index, columnHeader })).toContainText(option, { useInnerText: true });
|
||
2 years ago
|
}
|
||
2 years ago
|
return await expect(
|
||
|
this.cell.get({ index, columnHeader }).locator('.ant-select-selection-item > .ant-tag')
|
||
|
).toHaveText(option, { useInnerText: true });
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
async verifyNoOptionsSelected({ index, columnHeader }: { index: number; columnHeader: string }) {
|
||
|
return await expect(
|
||
|
this.cell.get({ index, columnHeader }).locator('.ant-select-selection-item > .ant-tag')
|
||
|
).toBeHidden();
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
async verifyOptions({ index, columnHeader, options }: { index: number; columnHeader: string; options: string[] }) {
|
||
|
await this.get({ index, columnHeader }).click();
|
||
2 years ago
|
|
||
|
let counter = 0;
|
||
|
for (const option of options) {
|
||
2 years ago
|
await expect(this.rootPage.locator(`div.ant-select-item-option`).nth(counter)).toHaveText(option);
|
||
2 years ago
|
counter++;
|
||
|
}
|
||
2 years ago
|
await this.get({ index, columnHeader }).click();
|
||
|
await this.rootPage.locator(`.nc-dropdown-single-select-cell`).nth(index).waitFor({ state: 'hidden' });
|
||
2 years ago
|
}
|
||
2 years ago
|
}
|