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.
79 lines
2.3 KiB
79 lines
2.3 KiB
2 years ago
|
import { ColumnPageObject } from '.';
|
||
|
import BasePage from '../../../Base';
|
||
2 years ago
|
|
||
2 years ago
|
export class SelectOptionColumnPageObject extends BasePage {
|
||
2 years ago
|
readonly column: ColumnPageObject;
|
||
|
|
||
|
constructor(column: ColumnPageObject) {
|
||
2 years ago
|
super(column.rootPage);
|
||
2 years ago
|
this.column = column;
|
||
|
}
|
||
|
|
||
2 years ago
|
get() {
|
||
|
return this.column.get();
|
||
|
}
|
||
|
|
||
2 years ago
|
async addOption({
|
||
|
index,
|
||
|
columnTitle,
|
||
|
option,
|
||
|
skipColumnModal,
|
||
|
}: {
|
||
|
index: number;
|
||
|
option: string;
|
||
|
skipColumnModal?: boolean;
|
||
|
columnTitle?: string;
|
||
|
}) {
|
||
|
if (!skipColumnModal && columnTitle) await this.column.openEdit({ title: columnTitle });
|
||
2 years ago
|
|
||
2 years ago
|
await this.column.get().locator('button:has-text("Add option")').click();
|
||
2 years ago
|
|
||
|
// Fill text=Select options can't be nullAdd option >> input[type="text"]
|
||
2 years ago
|
await this.column.get().locator(`[data-testid="select-column-option-input-${index}"]`).click();
|
||
|
await this.column.get().locator(`[data-testid="select-column-option-input-${index}"]`).fill(option);
|
||
2 years ago
|
|
||
2 years ago
|
if (!skipColumnModal && columnTitle) await this.column.save({ isUpdated: true });
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
async editOption({ columnTitle, index, newOption }: { index: number; columnTitle: string; newOption: string }) {
|
||
|
await this.column.openEdit({ title: columnTitle });
|
||
2 years ago
|
|
||
2 years ago
|
await this.column.get().locator(`[data-testid="select-column-option-input-${index}"]`).click();
|
||
|
await this.column.get().locator(`[data-testid="select-column-option-input-${index}"]`).fill(newOption);
|
||
2 years ago
|
|
||
2 years ago
|
await this.column.save({ isUpdated: true });
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
async deleteOption({ columnTitle, index }: { index: number; columnTitle: string }) {
|
||
|
await this.column.openEdit({ title: columnTitle });
|
||
2 years ago
|
|
||
2 years ago
|
await this.column.get().locator(`svg[data-testid="select-column-option-remove-${index}"]`).click();
|
||
2 years ago
|
|
||
2 years ago
|
await this.column.save({ isUpdated: true });
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
async reorderOption({
|
||
|
columnTitle,
|
||
|
sourceOption,
|
||
|
destinationOption,
|
||
|
}: {
|
||
|
columnTitle: string;
|
||
|
sourceOption: string;
|
||
|
destinationOption: string;
|
||
|
}) {
|
||
|
await this.column.openEdit({ title: columnTitle });
|
||
2 years ago
|
|
||
2 years ago
|
await this.column.rootPage.waitForTimeout(150);
|
||
2 years ago
|
|
||
2 years ago
|
await this.column.rootPage.dragAndDrop(
|
||
2 years ago
|
`svg[data-testid="select-option-column-handle-icon-${sourceOption}"]`,
|
||
|
`svg[data-testid="select-option-column-handle-icon-${destinationOption}"]`,
|
||
2 years ago
|
{
|
||
|
force: true,
|
||
|
}
|
||
|
);
|
||
2 years ago
|
|
||
2 years ago
|
await this.column.save({ isUpdated: true });
|
||
2 years ago
|
}
|
||
2 years ago
|
}
|