mirror of https://github.com/nocodb/nocodb
Raju Udava
1 year ago
committed by
GitHub
48 changed files with 750 additions and 487 deletions
@ -0,0 +1,107 @@ |
|||||||
|
import BasePage from '../../Base'; |
||||||
|
import { expect, Locator } from '@playwright/test'; |
||||||
|
import { DetailsPage } from './index'; |
||||||
|
|
||||||
|
export class ErdPage extends BasePage { |
||||||
|
readonly detailsPage: DetailsPage; |
||||||
|
|
||||||
|
readonly contextMenuBase: Locator; |
||||||
|
readonly contextMenu = {}; |
||||||
|
|
||||||
|
readonly btn_fullScreen: Locator; |
||||||
|
readonly btn_zoomIn: Locator; |
||||||
|
readonly btn_zoomOut: Locator; |
||||||
|
|
||||||
|
constructor(details: DetailsPage) { |
||||||
|
super(details.rootPage); |
||||||
|
this.detailsPage = details; |
||||||
|
this.btn_fullScreen = this.get().locator('.nc-erd-histogram > .nc-icon'); |
||||||
|
this.btn_zoomIn = this.get().locator('.nc-erd-zoom-btn').nth(0); |
||||||
|
this.btn_zoomOut = this.get().locator('.nc-erd-zoom-btn').nth(1); |
||||||
|
|
||||||
|
this.contextMenuBase = this.get().locator('.nc-erd-context-menu'); |
||||||
|
this.contextMenu['Show Columns'] = this.contextMenuBase.locator('.ant-checkbox-wrapper').nth(0); |
||||||
|
this.contextMenu['Show Primary and Foreign Keys'] = this.contextMenuBase.locator('.ant-checkbox-wrapper').nth(1); |
||||||
|
this.contextMenu['Show SQL Views'] = this.contextMenuBase.locator('.ant-checkbox-wrapper').nth(2); |
||||||
|
} |
||||||
|
|
||||||
|
get() { |
||||||
|
// pop up when triggered from data sources page
|
||||||
|
return this.rootPage.locator('.vue-flow'); |
||||||
|
} |
||||||
|
|
||||||
|
async verifyNode({ |
||||||
|
tableName, |
||||||
|
columnName, |
||||||
|
columnNameShouldNotExist, |
||||||
|
}: { |
||||||
|
tableName: string; |
||||||
|
columnName?: string; |
||||||
|
columnNameShouldNotExist?: string; |
||||||
|
}) { |
||||||
|
await this.get().locator(`.nc-erd-table-node-${tableName}`).waitFor({ state: 'visible' }); |
||||||
|
if (columnName) { |
||||||
|
await this.get().locator(`.nc-erd-table-node-${tableName}-column-${columnName}`).waitFor({ state: 'visible' }); |
||||||
|
} |
||||||
|
if (columnNameShouldNotExist) { |
||||||
|
await this.get() |
||||||
|
.locator(`.nc-erd-table-node-${tableName}-column-${columnNameShouldNotExist}`) |
||||||
|
.waitFor({ state: 'hidden' }); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
async verifyNodeDoesNotExist({ tableName }: { tableName: string }) { |
||||||
|
await this.get().locator(`.nc-erd-table-node-${tableName}`).waitFor({ state: 'hidden' }); |
||||||
|
} |
||||||
|
|
||||||
|
async verifyColumns({ tableName, columns }: { tableName: string; columns: string[] }) { |
||||||
|
for (const column of columns) { |
||||||
|
await this.verifyNode({ tableName, columnName: column }); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
async verifyNodesCount(count: number) { |
||||||
|
await expect(this.get().locator('.nc-erd-table-node')).toHaveCount(count); |
||||||
|
} |
||||||
|
|
||||||
|
async verifyEdgesCount({ |
||||||
|
count, |
||||||
|
circleCount, |
||||||
|
rectangleCount, |
||||||
|
}: { |
||||||
|
count: number; |
||||||
|
circleCount: number; |
||||||
|
rectangleCount: number; |
||||||
|
}) { |
||||||
|
await expect(this.get().locator('.vue-flow__edge')).toHaveCount(count); |
||||||
|
await expect(this.get().locator('.nc-erd-edge-circle')).toHaveCount(circleCount); |
||||||
|
await expect(this.get().locator('.nc-erd-edge-rect')).toHaveCount(rectangleCount); |
||||||
|
} |
||||||
|
|
||||||
|
async verifyJunctionTableLabel({ tableTitle, tableName }: { tableName: string; tableTitle: string }) { |
||||||
|
await this.get().locator(`.nc-erd-table-label-${tableTitle}-${tableName}`).waitFor({ |
||||||
|
state: 'visible', |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
async clickShowColumnNames() { |
||||||
|
await this.contextMenu['Show Columns'].click(); |
||||||
|
await (await this.get().elementHandle())?.waitForElementState('stable'); |
||||||
|
} |
||||||
|
|
||||||
|
async clickShowPkAndFk() { |
||||||
|
await this.contextMenu['Show Primary and Foreign Keys'].click(); |
||||||
|
await (await this.get().elementHandle())?.waitForElementState('stable'); |
||||||
|
} |
||||||
|
|
||||||
|
async clickShowSqlViews() { |
||||||
|
await this.contextMenu['Show SQL Views'].click(); |
||||||
|
await (await this.get().elementHandle())?.waitForElementState('stable'); |
||||||
|
} |
||||||
|
|
||||||
|
async close() { |
||||||
|
await this.get().click(); |
||||||
|
await this.rootPage.keyboard.press('Escape'); |
||||||
|
await this.get().waitFor({ state: 'hidden' }); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,46 @@ |
|||||||
|
import { GridPage } from '../Grid'; |
||||||
|
import BasePage from '../../Base'; |
||||||
|
import { expect, Locator } from '@playwright/test'; |
||||||
|
|
||||||
|
export class ColumnHeaderPageObject extends BasePage { |
||||||
|
readonly grid: GridPage; |
||||||
|
|
||||||
|
readonly btn_addColumn: Locator; |
||||||
|
readonly btn_selectAll: Locator; |
||||||
|
|
||||||
|
constructor(grid: GridPage) { |
||||||
|
super(grid.rootPage); |
||||||
|
this.grid = grid; |
||||||
|
|
||||||
|
this.btn_addColumn = this.get().locator(`.nc-grid-add-edit-column`); |
||||||
|
this.btn_selectAll = this.get().locator(`[data-testid="nc-check-all"]`); |
||||||
|
} |
||||||
|
|
||||||
|
get() { |
||||||
|
return this.rootPage.locator('.nc-grid-header'); |
||||||
|
} |
||||||
|
|
||||||
|
async getColumnHeader({ title }: { title: string }) { |
||||||
|
return this.get().locator(`th[data-title="${title}"]`); |
||||||
|
} |
||||||
|
|
||||||
|
async getColumnHeaderContextMenu({ title }: { title: string }) { |
||||||
|
return (await this.getColumnHeader({ title })).locator(`.nc-ui-dt-dropdown`); |
||||||
|
} |
||||||
|
|
||||||
|
async verifyLockMode() { |
||||||
|
// add column button
|
||||||
|
await expect(this.btn_addColumn).toBeVisible({ visible: false }); |
||||||
|
|
||||||
|
// column header context menu
|
||||||
|
expect(await this.get().locator('.nc-ui-dt-dropdown').count()).toBe(0); |
||||||
|
} |
||||||
|
|
||||||
|
async verifyCollaborativeMode() { |
||||||
|
// add column button
|
||||||
|
await expect(this.btn_addColumn).toBeVisible({ visible: true }); |
||||||
|
|
||||||
|
// column header context menu
|
||||||
|
expect(await this.get().locator('.nc-ui-dt-dropdown').count()).toBeGreaterThan(1); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,76 @@ |
|||||||
|
import { expect } from '@playwright/test'; |
||||||
|
import BasePage from '../../Base'; |
||||||
|
import { DataSourcePage } from './DataSourcePage'; |
||||||
|
|
||||||
|
export class AuditPage extends BasePage { |
||||||
|
constructor(dataSource: DataSourcePage) { |
||||||
|
super(dataSource.rootPage); |
||||||
|
} |
||||||
|
|
||||||
|
get() { |
||||||
|
return this.rootPage.locator('div.ant-modal-content'); |
||||||
|
} |
||||||
|
async verifyRow({ |
||||||
|
index, |
||||||
|
opType, |
||||||
|
opSubtype, |
||||||
|
description, |
||||||
|
user, |
||||||
|
created, |
||||||
|
}: { |
||||||
|
index: number; |
||||||
|
opType?: string; |
||||||
|
opSubtype?: string; |
||||||
|
description?: string; |
||||||
|
user?: string; |
||||||
|
created?: string; |
||||||
|
}) { |
||||||
|
const table = this.get().locator('[data-testid="audit-tab-table"]'); |
||||||
|
const row = table.locator(`tr.ant-table-row`).nth(index); |
||||||
|
|
||||||
|
if (opType) { |
||||||
|
await row |
||||||
|
.locator(`td.ant-table-cell`) |
||||||
|
.nth(0) |
||||||
|
.textContent() |
||||||
|
.then(async text => expect(text).toContain(opType)); |
||||||
|
} |
||||||
|
|
||||||
|
if (opSubtype) { |
||||||
|
await row |
||||||
|
.locator(`td.ant-table-cell`) |
||||||
|
.nth(1) |
||||||
|
.textContent() |
||||||
|
.then(async text => expect(text).toContain(opSubtype)); |
||||||
|
} |
||||||
|
|
||||||
|
if (description) { |
||||||
|
await row |
||||||
|
.locator(`td.ant-table-cell`) |
||||||
|
.nth(2) |
||||||
|
.textContent() |
||||||
|
.then(async text => expect(text).toContain(description)); |
||||||
|
} |
||||||
|
|
||||||
|
if (user) { |
||||||
|
await row |
||||||
|
.locator(`td.ant-table-cell`) |
||||||
|
.nth(3) |
||||||
|
.textContent() |
||||||
|
.then(async text => expect(text).toContain(user)); |
||||||
|
} |
||||||
|
|
||||||
|
if (created) { |
||||||
|
await row |
||||||
|
.locator(`td.ant-table-cell`) |
||||||
|
.nth(4) |
||||||
|
.textContent() |
||||||
|
.then(async text => expect(text).toContain(created)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
async close() { |
||||||
|
await this.get().click(); |
||||||
|
await this.rootPage.keyboard.press('Escape'); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue