mirror of https://github.com/nocodb/nocodb
12 changed files with 194 additions and 160 deletions
@ -1,19 +1,20 @@
|
||||
// playwright-dev-page.ts
|
||||
import { Page, expect } from '@playwright/test'; |
||||
import { Page, expect, Locator } from "@playwright/test"; |
||||
|
||||
export class BasePage { |
||||
readonly page: Page; |
||||
export default abstract class BasePage { |
||||
readonly rootPage: Page; |
||||
|
||||
constructor(page: Page) { |
||||
this.page = page; |
||||
abstract get(args: any): Locator; |
||||
|
||||
constructor(rootPage: Page) { |
||||
this.rootPage = rootPage; |
||||
} |
||||
|
||||
async toastWait({message}: {message: string}) { |
||||
async toastWait ({message}: {message: string}){ |
||||
// const toast = await this.page.locator('.ant-message .ant-message-notice-content', {hasText: message}).last();
|
||||
// await toast.waitFor({state: 'visible'});
|
||||
|
||||
|
||||
// todo: text of toastr shows old one in the test assertion
|
||||
await this.page.locator('.ant-message .ant-message-notice-content', {hasText: message}).last().textContent() |
||||
await this.rootPage.locator('.ant-message .ant-message-notice-content', {hasText: message}).last().textContent() |
||||
.then((text) => expect(text).toContain(message)); |
||||
} |
||||
} |
@ -0,0 +1,32 @@
|
||||
// playwright-dev-page.ts
|
||||
import { Locator } from '@playwright/test'; |
||||
import BasePage from '../../Base'; |
||||
import { DashboardPage } from '..'; |
||||
|
||||
export class ExpandedFormPage extends BasePage { |
||||
readonly dashboard: DashboardPage; |
||||
readonly addNewTableButton: Locator; |
||||
|
||||
constructor(dashboard: DashboardPage) { |
||||
super(dashboard.rootPage); |
||||
this.dashboard = dashboard; |
||||
this.addNewTableButton = this.dashboard.get().locator('.nc-add-new-table'); |
||||
} |
||||
|
||||
get() { |
||||
return this.dashboard.get().locator(`.nc-drawer-expanded-form`); |
||||
} |
||||
|
||||
async fillField({columnTitle, value}: {columnTitle: string, value: string}) { |
||||
const field = this.get().locator(`[pw-data="nc-expand-col-${columnTitle}"]`); |
||||
await field.locator('input').fill(value); |
||||
} |
||||
|
||||
async save() { |
||||
await this.get().locator('button:has-text("Save Row")').click(); |
||||
await this.get().press('Escape'); |
||||
await this.get().waitFor({state: 'hidden'}); |
||||
await this.toastWait({message: `updated successfully.`}); |
||||
await this.get().locator('[pw-data="grid-load-spinner"]').waitFor({ state: 'hidden' }); |
||||
} |
||||
} |
@ -1,32 +0,0 @@
|
||||
// playwright-dev-page.ts
|
||||
import { Locator, Page } from '@playwright/test'; |
||||
import { BasePage } from '../../../Base'; |
||||
|
||||
export class ExpandedFormPage { |
||||
readonly page: Page; |
||||
readonly addNewTableButton: Locator; |
||||
readonly base: BasePage; |
||||
|
||||
constructor(page: Page) { |
||||
this.page = page; |
||||
this.addNewTableButton = page.locator('.nc-add-new-table'); |
||||
this.base = new BasePage(page); |
||||
} |
||||
|
||||
get() { |
||||
return this.page.locator(`.nc-drawer-expanded-form`); |
||||
} |
||||
|
||||
async fillField({columnTitle, value}: {columnTitle: string, value: string}) { |
||||
const field = this.get().locator(`[pw-data="nc-expand-col-${columnTitle}"]`); |
||||
await field.locator('input').fill(value); |
||||
} |
||||
|
||||
async save() { |
||||
await this.get().locator('button:has-text("Save Row")').click(); |
||||
await this.get().press('Escape'); |
||||
await this.get().waitFor({state: 'hidden'}); |
||||
await this.base.toastWait({message: `updated successfully.`}); |
||||
await this.page.locator('[pw-data="grid-load-spinner"]').waitFor({ state: 'hidden' }); |
||||
} |
||||
} |
Loading…
Reference in new issue