mirror of https://github.com/nocodb/nocodb
7 changed files with 153 additions and 20 deletions
@ -0,0 +1,90 @@
|
||||
// playwright-dev-page.ts
|
||||
import { Locator, Page, expect } from "@playwright/test"; |
||||
import { DashboardPage } from ".."; |
||||
import BasePage from "../../Base"; |
||||
|
||||
export class ViewSidebarPage extends BasePage { |
||||
readonly project: any; |
||||
readonly dashboard: DashboardPage; |
||||
readonly createGalleryButton: Locator; |
||||
readonly createGridButton: Locator; |
||||
readonly createFormButton: Locator; |
||||
readonly createKanbanButton: Locator; |
||||
|
||||
constructor(dashboard: DashboardPage) { |
||||
super(dashboard.rootPage); |
||||
this.dashboard = dashboard; |
||||
this.createGalleryButton = this.get().locator('.nc-create-gallery-view'); |
||||
this.createGridButton = this.get().locator('.nc-create-grid-view'); |
||||
this.createFormButton = this.get().locator('.nc-create-form-view'); |
||||
this.createKanbanButton = this.get().locator('.nc-create-kanban-view'); |
||||
} |
||||
|
||||
get() { |
||||
return this.dashboard.get().locator('.nc-view-sidebar'); |
||||
} |
||||
|
||||
private async createView({ title, locator }: { title: string, locator: Locator }) { |
||||
await locator.click(); |
||||
await this.rootPage.locator('input[id="form_item_title"]').fill(title); |
||||
await this.rootPage.locator('.ant-modal-content').locator('button:has-text("Submit")').click(); |
||||
await this.toastWait({ message: 'View created successfully'}); |
||||
} |
||||
|
||||
async createGalleryView({ title }: { title: string }) { |
||||
await this.createView({ title, locator: this.createGalleryButton }); |
||||
} |
||||
|
||||
async createGridView({ title }: { title: string }) { |
||||
await this.createView({ title, locator: this.createGridButton }); |
||||
} |
||||
|
||||
async createFormView({ title }: { title: string }) { |
||||
await this.createView({ title, locator: this.createFormButton }); |
||||
} |
||||
|
||||
async createKanbanView({ title }: { title: string }) { |
||||
await this.createView({ title, locator: this.createKanbanButton }); |
||||
} |
||||
|
||||
async verifyView({ title, index }: { title: string, index: number }) { |
||||
return await this.assertInnerTextWithRetry({ |
||||
locator: this.get().locator(`.nc-views-menu`).locator('.ant-menu-title-content').nth(index), |
||||
text: title, |
||||
}) |
||||
} |
||||
|
||||
async verifyViewNotPresent({ title, index }: { title: string, index: number }) { |
||||
const viewList = this.get().locator(`.nc-views-menu`).locator('.ant-menu-title-content'); |
||||
if(await viewList.count() <= index) { |
||||
return true |
||||
} |
||||
|
||||
return await this.assertNotInnerTextWithRetry({ |
||||
locator: this.get().locator(`.nc-views-menu`).locator('.ant-menu-title-content').nth(index), |
||||
text: title, |
||||
}) |
||||
} |
||||
|
||||
async reorderViews({sourceView, destinationView}: { |
||||
sourceView: string, |
||||
destinationView: string, |
||||
}) { |
||||
|
||||
await this.dashboard.get().locator(`[pw-data="view-sidebar-drag-handle-${sourceView}"]`).dragTo( |
||||
this.get().locator(`[pw-data="view-sidebar-view-${destinationView}"]`), |
||||
); |
||||
} |
||||
|
||||
async deleteView({ title }: { title: string }) { |
||||
await this.get().locator(`[pw-data="view-sidebar-view-${title}"]`).hover(); |
||||
await this.get() |
||||
.locator(`[pw-data="view-sidebar-view-actions-${title}"]`) |
||||
.locator('.nc-view-delete-icon') |
||||
.click(); |
||||
|
||||
await this.rootPage.locator('.nc-modal-view-delete').locator('button:has-text("Submit")').click(); |
||||
await this.rootPage.locator('.nc-modal-view-delete').locator('button:has-text("Submit")').waitFor({ state: 'detached' }); |
||||
await this.toastWait({ message: 'View deleted successfully'}); |
||||
} |
||||
} |
@ -1,20 +1,45 @@
|
||||
import { test } from '@playwright/test'; |
||||
import { DashboardPage } from '../pages/Dashboard'; |
||||
import { SettingsPage } from '../pages/Dashboard/Settings'; |
||||
import setup from '../setup'; |
||||
|
||||
|
||||
test.describe.skip('Views', () => { |
||||
let dashboard: DashboardPage, settings: SettingsPage; |
||||
test.describe('Views', () => { |
||||
let dashboard: DashboardPage; |
||||
let context: any; |
||||
|
||||
test.beforeEach(async ({page}) => { |
||||
context = await setup({ page }); |
||||
dashboard = new DashboardPage(page, context.project); |
||||
settings = new SettingsPage(page); |
||||
}) |
||||
|
||||
test('Create, and delete table, verify in audit tab, rename City table and reorder tables', async () => { |
||||
test('Create views, reorder and delete', async () => { |
||||
await dashboard.treeView.openTable({title: "City"}); |
||||
|
||||
await dashboard.viewSidebar.createGridView({title: "CityGrid"}); |
||||
await dashboard.viewSidebar.verifyView({title: "CityGrid", index: 1}); |
||||
|
||||
await dashboard.viewSidebar.createFormView({title: "CityForm"}); |
||||
await dashboard.viewSidebar.verifyView({title: "CityForm", index: 2}); |
||||
|
||||
await dashboard.viewSidebar.createGalleryView({title: "CityGallery"}); |
||||
await dashboard.viewSidebar.verifyView({title: "CityGallery", index: 3}); |
||||
|
||||
await dashboard.viewSidebar.reorderViews({ |
||||
sourceView: "CityGrid", |
||||
destinationView: "CityForm" |
||||
}); |
||||
await dashboard.viewSidebar.verifyView({title: "CityGrid", index: 2}); |
||||
await dashboard.viewSidebar.verifyView({title: "CityForm", index: 1}); |
||||
|
||||
await dashboard.viewSidebar.deleteView({title: "CityForm"}); |
||||
await dashboard.viewSidebar.verifyViewNotPresent({title: "CityForm", index: 1}); |
||||
|
||||
// todo: Delete form view is deleting grid view. Probably a bug.
|
||||
// await dashboard.viewSidebar.deleteView({title: "CityGrid"});
|
||||
// await dashboard.viewSidebar.verifyViewNotPresent({title: "CityGrid", index: 1});
|
||||
|
||||
await dashboard.viewSidebar.deleteView({title: "CityGallery"}); |
||||
await dashboard.viewSidebar.verifyViewNotPresent({title: "CityGallery", index: 1}); |
||||
}); |
||||
|
||||
}); |
||||
|
Loading…
Reference in new issue