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.
141 lines
5.6 KiB
141 lines
5.6 KiB
2 years ago
|
import { expect } from '@playwright/test';
|
||
2 years ago
|
import { DashboardPage } from '..';
|
||
|
import BasePage from '../../Base';
|
||
|
import { ToolbarPage } from '../common/Toolbar';
|
||
2 years ago
|
|
||
|
export class KanbanPage extends BasePage {
|
||
|
readonly dashboard: DashboardPage;
|
||
|
readonly toolbar: ToolbarPage;
|
||
|
|
||
|
constructor(dashboard: DashboardPage) {
|
||
|
super(dashboard.rootPage);
|
||
|
this.dashboard = dashboard;
|
||
|
this.toolbar = new ToolbarPage(this);
|
||
|
}
|
||
|
|
||
|
get() {
|
||
2 years ago
|
return this.dashboard.get().locator('[data-nc="nc-kanban-wrapper"]');
|
||
2 years ago
|
}
|
||
|
|
||
|
card(index: number) {
|
||
|
return this.get().locator(`.ant-card`).nth(index);
|
||
|
}
|
||
|
|
||
|
async openExpandedRow({ index }: { index: number }) {
|
||
|
await this.card(index).click();
|
||
2 years ago
|
await (await this.rootPage.locator('.ant-drawer-body').elementHandle())?.waitForElementState('stable');
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
// todo: Implement
|
||
2 years ago
|
async addOption() {}
|
||
|
|
||
2 years ago
|
// todo: Implement
|
||
2 years ago
|
async dragDropCard(param: { from: string; to: string }) {
|
||
|
// const { from, to } = param;
|
||
|
// const srcStack = await this.get().locator(`.nc-kanban-stack`).nth(1);
|
||
|
// const dstStack = await this.get().locator(`.nc-kanban-stack`).nth(2);
|
||
|
// const fromCard = await srcStack.locator(`.nc-kanban-item`).nth(1);
|
||
|
// const toCard = await dstStack.locator(`.nc-kanban-item`).nth(1);
|
||
|
// const [fromCard, toCard] = await Promise.all([
|
||
|
// srcStack.locator(`.nc-kanban-item[data-draggable="true"]`).nth(0),
|
||
|
// dstStack.locator(`.nc-kanban-item[data-draggable="true"]`).nth(0),
|
||
|
// ]);
|
||
|
// const fromCard = await this.get().locator(`.nc-kanban-item`).nth(0);
|
||
|
// const toCard = await this.get().locator(`.nc-kanban-item`).nth(25);
|
||
|
// await fromCard.dragTo(toCard);
|
||
|
}
|
||
|
|
||
|
async dragDropStack(param: { from: number; to: number }) {
|
||
|
const { from, to } = param;
|
||
|
const [fromStack, toStack] = await Promise.all([
|
||
|
this.rootPage.locator(`.nc-kanban-stack-head`).nth(from),
|
||
|
this.rootPage.locator(`.nc-kanban-stack-head`).nth(to),
|
||
|
]);
|
||
|
await fromStack.dragTo(toStack);
|
||
|
}
|
||
|
|
||
|
async verifyStackCount(param: { count: number }) {
|
||
|
const { count } = param;
|
||
2 years ago
|
await expect(this.get().locator(`.nc-kanban-stack`)).toHaveCount(count);
|
||
2 years ago
|
}
|
||
|
|
||
|
async verifyStackOrder(param: { order: string[] }) {
|
||
|
const { order } = param;
|
||
|
const stacks = await this.get().locator(`.nc-kanban-stack`).count();
|
||
|
for (let i = 0; i < stacks; i++) {
|
||
|
const stack = await this.get().locator(`.nc-kanban-stack`).nth(i);
|
||
2 years ago
|
// Since otherwise stack title will be repeated as title is in two divs, with one having hidden class
|
||
2 years ago
|
const stackTitle = await stack.locator(`.nc-kanban-stack-head >> [data-nc="truncate-label"]`);
|
||
2 years ago
|
await expect(stackTitle).toHaveText(order[i], { ignoreCase: true });
|
||
2 years ago
|
}
|
||
|
}
|
||
|
|
||
|
async verifyStackFooter(param: { count: number[] }) {
|
||
|
const { count } = param;
|
||
|
const stacks = await this.get().locator(`.nc-kanban-stack`).count();
|
||
|
for (let i = 0; i < stacks; i++) {
|
||
|
const stack = await this.get().locator(`.nc-kanban-stack`).nth(i);
|
||
2 years ago
|
const stackFooter = await stack.locator(`.nc-kanban-data-count`).innerText();
|
||
|
await expect(stackFooter).toContain(`${count[i]} record${count[i] !== 1 ? 's' : ''}`);
|
||
2 years ago
|
}
|
||
|
}
|
||
|
|
||
|
async verifyCardCount(param: { count: number[] }) {
|
||
|
const { count } = param;
|
||
|
const stacks = await this.get().locator(`.nc-kanban-stack`).count();
|
||
|
for (let i = 0; i < stacks; i++) {
|
||
|
const stack = await this.get().locator(`.nc-kanban-stack`).nth(i);
|
||
2 years ago
|
const stackCards = stack.locator(`.nc-kanban-item`);
|
||
|
await expect(stackCards).toHaveCount(count[i]);
|
||
2 years ago
|
}
|
||
|
}
|
||
|
|
||
|
async verifyCardOrder(param: { order: string[]; stackIndex: number }) {
|
||
|
const { order, stackIndex } = param;
|
||
|
const stack = await this.get().locator(`.nc-kanban-stack`).nth(stackIndex);
|
||
|
for (let i = 0; i < order.length; i++) {
|
||
|
const card = await stack.locator(`.nc-kanban-item`).nth(i);
|
||
2 years ago
|
const cardTitle = await card.locator(`.nc-cell`);
|
||
|
await expect(cardTitle).toHaveText(order[i]);
|
||
2 years ago
|
}
|
||
|
}
|
||
|
|
||
2 years ago
|
// todo: Wait for render to complete
|
||
2 years ago
|
async waitLoading() {
|
||
|
await this.rootPage.waitForTimeout(1000);
|
||
|
}
|
||
2 years ago
|
|
||
|
async addNewStack(param: { title: string }) {
|
||
|
await this.toolbar.clickAddEditStack();
|
||
|
await this.toolbar.addEditStack.addOption({ title: param.title });
|
||
|
}
|
||
|
|
||
|
async collapseStack(param: { index: number }) {
|
||
|
await this.get().locator(`.nc-kanban-stack-head`).nth(param.index).click();
|
||
2 years ago
|
const modal = await this.rootPage.locator(`.nc-dropdown-kanban-stack-context-menu`);
|
||
|
await modal.locator('.ant-dropdown-menu-item:has-text("Collapse Stack")').click();
|
||
2 years ago
|
}
|
||
|
|
||
|
async expandStack(param: { index: number }) {
|
||
2 years ago
|
await this.rootPage.locator(`.nc-kanban-collapsed-stack`).nth(param.index).click();
|
||
2 years ago
|
}
|
||
|
|
||
|
async verifyCollapseStackCount(param: { count: number }) {
|
||
2 years ago
|
await expect(this.rootPage.locator('.nc-kanban-collapsed-stack')).toHaveCount(param.count);
|
||
2 years ago
|
}
|
||
|
|
||
|
async addCard(param: { stackIndex: number }) {
|
||
2 years ago
|
await this.get().locator(`.nc-kanban-stack-head`).nth(param.stackIndex).click();
|
||
|
const modal = await this.rootPage.locator(`.nc-dropdown-kanban-stack-context-menu`);
|
||
|
await modal.locator('.ant-dropdown-menu-item:has-text("Add new record")').click();
|
||
2 years ago
|
}
|
||
|
|
||
|
async deleteStack(param: { index: number }) {
|
||
|
await this.get().locator(`.nc-kanban-stack-head`).nth(param.index).click();
|
||
2 years ago
|
const modal = await this.rootPage.locator(`.nc-dropdown-kanban-stack-context-menu`);
|
||
|
await modal.locator('.ant-dropdown-menu-item:has-text("Delete Stack")').click();
|
||
|
const confirmationModal = await this.rootPage.locator(`.nc-modal-kanban-delete-stack`);
|
||
2 years ago
|
await confirmationModal.locator(`button:has-text("Delete")`).click();
|
||
|
}
|
||
2 years ago
|
}
|