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.
91 lines
3.2 KiB
91 lines
3.2 KiB
2 years ago
|
import { Page, expect } from "@playwright/test";
|
||
2 years ago
|
import { BasePage } from "../../../Base";
|
||
2 years ago
|
import {SelectOptionColumnPageObject} from "./SelectOptionColumn";
|
||
|
|
||
|
export class ColumnPageObject {
|
||
|
readonly page: Page;
|
||
|
readonly basePage: BasePage;
|
||
|
readonly selectOption: SelectOptionColumnPageObject;
|
||
|
|
||
|
constructor(page: Page) {
|
||
|
this.page = page;
|
||
|
this.selectOption = new SelectOptionColumnPageObject(this);
|
||
|
this.basePage = new BasePage(this.page);
|
||
|
}
|
||
|
|
||
2 years ago
|
get() {
|
||
|
return this.page.locator('[data-pw="add-or-edit-column"]');
|
||
|
}
|
||
|
|
||
|
async create({title, type = "SingleLineText"}: {title: string, type?: string}) {
|
||
2 years ago
|
await this.page.locator('.nc-column-add').click();
|
||
|
|
||
|
await this.page.locator('form[data-pw="add-or-edit-column"]').waitFor();
|
||
|
|
||
2 years ago
|
await this.fillTitle({title});
|
||
|
|
||
|
await this.selectType({type});
|
||
2 years ago
|
|
||
|
switch (type) {
|
||
2 years ago
|
case "SingleTextLine":
|
||
|
break;
|
||
2 years ago
|
case 'SingleSelect':
|
||
|
case 'MultiSelect':
|
||
|
await this.selectOption.addOption({index: 0, option: 'Option 1', skipColumnModal: true});
|
||
|
await this.selectOption.addOption({index: 1, option: 'Option 2', skipColumnModal: true});
|
||
|
break;
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
|
||
2 years ago
|
await this.save();
|
||
|
}
|
||
|
|
||
|
async fillTitle({title}: {title: string}) {
|
||
2 years ago
|
await this.page.locator('.nc-column-name-input').fill(title);
|
||
2 years ago
|
}
|
||
2 years ago
|
|
||
2 years ago
|
async selectType({type}: {type: string}) {
|
||
|
await this.get().locator('.ant-select-selector > .ant-select-selection-item').click();
|
||
|
|
||
|
await this.get().locator('.ant-select-selection-search-input[aria-expanded="true"]').waitFor();
|
||
|
await this.get().locator('.ant-select-selection-search-input[aria-expanded="true"]').fill(type);
|
||
|
|
||
|
// Select column type
|
||
|
await this.page.locator(`text=${type}`).nth(1).click();
|
||
2 years ago
|
}
|
||
|
|
||
|
async delete({title}: {title: string}) {
|
||
2 years ago
|
await this.page.locator(`th[data-title="${title}"] >> svg.ant-dropdown-trigger`).click();
|
||
2 years ago
|
await this.page.locator('li[role="menuitem"]:has-text("Delete")').waitFor()
|
||
|
await this.page.locator('li[role="menuitem"]:has-text("Delete")').click();
|
||
|
|
||
|
await this.page.locator('button:has-text("Delete")').click();
|
||
|
|
||
|
// wait till modal is closed
|
||
|
await this.page.locator('.nc-modal-column-delete').waitFor({state: 'hidden'});
|
||
|
}
|
||
|
|
||
|
async openEdit({title}: {title: string}) {
|
||
|
await this.page.locator(`text=#Title${title} >> svg >> nth=3`).click();
|
||
|
await this.page.locator('li[role="menuitem"]:has-text("Edit")').waitFor()
|
||
|
await this.page.locator('li[role="menuitem"]:has-text("Edit")').click();
|
||
|
|
||
|
await this.page.locator('form[data-pw="add-or-edit-column"]').waitFor();
|
||
|
}
|
||
|
|
||
|
async save({isUpdated}: {isUpdated?: boolean} = {}) {
|
||
|
await this.page.locator('button:has-text("Save")').click();
|
||
|
|
||
|
await this.basePage.toastWait({message: isUpdated ? 'Column updated' : 'Column created'});
|
||
2 years ago
|
await this.page.locator('form[data-pw="add-or-edit-column"]').waitFor({state: 'hidden'});
|
||
|
await this.page.waitForTimeout(200);
|
||
2 years ago
|
}
|
||
2 years ago
|
|
||
|
async verify({title, isDeleted}: {title: string, isDeleted?: boolean}) {
|
||
|
if(isDeleted) {
|
||
|
return expect(await this.page.locator(`th[data-title="${title}"]`).count()).toBe(0);
|
||
|
}
|
||
|
await expect(this.page.locator(`th[data-title="${title}"]`)).toHaveText(title);
|
||
|
}
|
||
2 years ago
|
}
|