mirror of https://github.com/nocodb/nocodb
DarkPhoenix2704
10 months ago
18 changed files with 460 additions and 144 deletions
@ -0,0 +1,46 @@
|
||||
import { expect, Locator } from '@playwright/test'; |
||||
import BasePage from '../../Base'; |
||||
import { CalendarPage } from './index'; |
||||
|
||||
export class CalendarMonthPage extends BasePage { |
||||
readonly parent: CalendarPage; |
||||
|
||||
constructor(parent: CalendarPage) { |
||||
super(parent.rootPage); |
||||
this.parent = parent; |
||||
} |
||||
|
||||
get() { |
||||
return this.rootPage.getByTestId('nc-calendar-day-view'); |
||||
} |
||||
|
||||
getRecordContainer() { |
||||
return this.get().getByTestId('nc-calendar-day-record-container'); |
||||
} |
||||
|
||||
async dragAndDrop({ record, to }: { record: string; to: { rowIndex: number; columnIndex: number } }) { |
||||
const recordContainer = this.getRecordContainer(); |
||||
const recordCard = recordContainer.getByTestId(`nc-calendar-month-record-${record}`); |
||||
const toDay = this.get().getByTestId('nc-calendar-month-day').nth(to.columnIndex).nth(to.rowIndex); |
||||
const cord = await toDay.boundingBox(); |
||||
|
||||
await recordCard.hover(); |
||||
await this.rootPage.mouse.down({ button: 'right' }); |
||||
|
||||
await this.rootPage.mouse.move(cord.x + cord.width / 2, cord.y + cord.height / 2); |
||||
await this.rootPage.mouse.up(); |
||||
} |
||||
|
||||
async selectDate({ rowIndex, columnIndex }: { rowIndex: number; columnIndex: number }) { |
||||
const week = this.get().getByTestId('nc-calendar-month-week'); |
||||
|
||||
const day = week.nth(rowIndex).getByTestId('nc-calendar-month-day').nth(columnIndex); |
||||
await day.click({ |
||||
force: true, |
||||
position: { |
||||
x: 0, |
||||
y: 1, |
||||
}, |
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,46 @@
|
||||
import { expect, Locator } from '@playwright/test'; |
||||
import BasePage from '../../Base'; |
||||
import { CalendarPage } from './index'; |
||||
|
||||
export class CalendarMonthPage extends BasePage { |
||||
readonly parent: CalendarPage; |
||||
|
||||
constructor(parent: CalendarPage) { |
||||
super(parent.rootPage); |
||||
this.parent = parent; |
||||
} |
||||
|
||||
get() { |
||||
return this.rootPage.getByTestId('nc-calendar-month-view'); |
||||
} |
||||
|
||||
getRecordContainer() { |
||||
return this.get().getByTestId('nc-calendar-month-record-container'); |
||||
} |
||||
|
||||
async dragAndDrop({ record, to }: { record: string; to: { rowIndex: number; columnIndex: number } }) { |
||||
const recordContainer = this.getRecordContainer(); |
||||
const recordCard = recordContainer.getByTestId(`nc-calendar-month-record-${record}`); |
||||
const toDay = this.get().getByTestId('nc-calendar-month-day').nth(to.columnIndex).nth(to.rowIndex); |
||||
const cord = await toDay.boundingBox(); |
||||
|
||||
await recordCard.hover(); |
||||
await this.rootPage.mouse.down({ button: 'right' }); |
||||
|
||||
await this.rootPage.mouse.move(cord.x + cord.width / 2, cord.y + cord.height / 2); |
||||
await this.rootPage.mouse.up(); |
||||
} |
||||
|
||||
async selectDate({ rowIndex, columnIndex }: { rowIndex: number; columnIndex: number }) { |
||||
const week = this.get().getByTestId('nc-calendar-month-week'); |
||||
|
||||
const day = week.nth(rowIndex).getByTestId('nc-calendar-month-day').nth(columnIndex); |
||||
await day.click({ |
||||
force: true, |
||||
position: { |
||||
x: 0, |
||||
y: 1, |
||||
}, |
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,38 @@
|
||||
import { expect, Locator } from '@playwright/test'; |
||||
import BasePage from '../../Base'; |
||||
import { CalendarPage } from './index'; |
||||
|
||||
export class CalendarSideMenuPage extends BasePage { |
||||
readonly parent: CalendarPage; |
||||
|
||||
readonly new_record_btn: Locator; |
||||
|
||||
constructor(parent: CalendarPage) { |
||||
super(parent.rootPage); |
||||
this.parent = parent; |
||||
|
||||
this.new_record_btn = this.get().getByTestId('nc-calendar-side-menu-new-btn'); |
||||
} |
||||
|
||||
get() { |
||||
return this.rootPage.getByTestId('nc-calendar-side-menu'); |
||||
} |
||||
|
||||
async updateFilter({ filter }: { filter: string }) { |
||||
const filterInput = this.get().getByTestId('nc-calendar-sidebar-filter'); |
||||
await filterInput.click(); |
||||
await this.rootPage.locator('.rc-virtual-list-holder-inner > div').locator(`text="${filter}"`).click(); |
||||
} |
||||
|
||||
async verifySideBarRecords({ records }: { records: string[] }) { |
||||
const sideBar = this.get().getByTestId('nc-calendar-side-menu-list'); |
||||
|
||||
const sideBarRecords = await sideBar.getByTestId('nc-sidebar-record-card'); |
||||
|
||||
await expect(sideBarRecords).toHaveCount(records.length); |
||||
|
||||
for (let i = 0; i < records.length; i++) { |
||||
await expect(sideBarRecords.nth(i)).toContainText(records[i]); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,26 @@
|
||||
import { expect, Locator } from '@playwright/test'; |
||||
import BasePage from '../../Base'; |
||||
import { CalendarPage } from './index'; |
||||
|
||||
export class CalendarYearPage extends BasePage { |
||||
readonly parent: CalendarPage; |
||||
|
||||
constructor(parent: CalendarPage) { |
||||
super(parent.rootPage); |
||||
this.parent = parent; |
||||
} |
||||
|
||||
get() { |
||||
return this.rootPage.getByTestId('nc-calendar-year-view'); |
||||
} |
||||
|
||||
getMonth({ index }: { index: number }) { |
||||
return this.get().getByTestId('nc-calendar-year-view-month-selector').nth(index); |
||||
} |
||||
|
||||
async selectDate({ monthIndex, dayIndex }: { monthIndex: number; dayIndex: number }) { |
||||
const month = this.getMonth({ index: monthIndex }); |
||||
const day = month.getByTestId('nc-calendar-date').nth(dayIndex); |
||||
await day.click({ force: true }); |
||||
} |
||||
} |
Loading…
Reference in new issue