2024-07-13 18:23:11 +03:00
|
|
|
import { type Locator, type Page } from '@playwright/test'
|
|
|
|
import { CalendarPage } from '../calendar-page'
|
|
|
|
import { NewDocument } from '../types'
|
2024-08-29 18:22:44 +03:00
|
|
|
|
2024-07-13 18:23:11 +03:00
|
|
|
export class DocumentsPage extends CalendarPage {
|
|
|
|
readonly page: Page
|
|
|
|
readonly buttonCreateDocument: Locator
|
|
|
|
readonly buttonPopupNextStep: Locator
|
|
|
|
readonly buttonSpaceSelector: Locator
|
|
|
|
readonly buttonParentSelector: Locator
|
|
|
|
readonly inputNewDocumentTitle: Locator
|
|
|
|
readonly inputNewDocumentDescription: Locator
|
|
|
|
readonly inputNewDocumentCreateDaft: Locator
|
2024-07-31 19:59:12 +03:00
|
|
|
readonly category: Locator
|
|
|
|
readonly search: Locator
|
|
|
|
readonly nextStep: Locator
|
|
|
|
readonly addMember: Locator
|
|
|
|
readonly newMember: Locator
|
2024-08-29 18:22:44 +03:00
|
|
|
readonly changeSpaceButton: Locator
|
2024-07-13 18:23:11 +03:00
|
|
|
|
|
|
|
constructor (page: Page) {
|
|
|
|
super(page)
|
|
|
|
this.page = page
|
|
|
|
this.buttonCreateDocument = page.locator(
|
|
|
|
'div[data-float="navigator"] button[type="submit"]:not([class*="only-icon"])'
|
|
|
|
)
|
|
|
|
this.buttonPopupNextStep = page.locator('div.popup button[type="submit"]')
|
|
|
|
this.buttonSpaceSelector = page.locator('button[id="space.selector"]')
|
|
|
|
this.buttonParentSelector = page.locator('div.parentSelector span[class*="label"]')
|
|
|
|
this.inputNewDocumentTitle = page.locator('div[id="doc-title"] input')
|
|
|
|
this.inputNewDocumentDescription = page.locator('div[id="doc-description"] input')
|
|
|
|
this.inputNewDocumentCreateDaft = page.locator('div.footer div.footerButtons button[type="button"]')
|
2024-07-31 19:59:12 +03:00
|
|
|
this.category = page.locator(
|
|
|
|
"xpath=//button[@class='antiButton no-border small jf-center sh-no-shape bs-solid gap-medium iconR']"
|
|
|
|
)
|
|
|
|
this.search = page.getByPlaceholder('Search...')
|
|
|
|
this.nextStep = page.getByRole('button', { name: 'Next step' })
|
|
|
|
this.addMember = page.getByText('Add member')
|
|
|
|
this.newMember = page.getByRole('button', { name: 'AJ Appleseed John' })
|
2024-08-29 18:22:44 +03:00
|
|
|
this.changeSpaceButton = page.locator('[id="space\\.selector"]')
|
2024-07-13 18:23:11 +03:00
|
|
|
}
|
|
|
|
|
2024-09-11 13:54:17 +03:00
|
|
|
async createDocument (
|
|
|
|
data: NewDocument,
|
|
|
|
startSecondStep: boolean = false,
|
|
|
|
changeSpaceInCreateDocument: string = 'Quality documents'
|
|
|
|
): Promise<void> {
|
2024-07-13 18:23:11 +03:00
|
|
|
if (data.location != null) {
|
|
|
|
await this.buttonSpaceSelector.click()
|
|
|
|
await this.selectListItemWithSearch(this.page, data.location.space ?? '')
|
|
|
|
|
|
|
|
await this.page.locator('div.parentSelector span[class*="label"]', { hasText: data.location.parent }).click()
|
|
|
|
}
|
|
|
|
|
|
|
|
// template
|
|
|
|
if (!startSecondStep) {
|
2024-09-11 13:54:17 +03:00
|
|
|
await this.changeSpaceInCreateDocumentForm(changeSpaceInCreateDocument)
|
2024-07-13 18:23:11 +03:00
|
|
|
await this.buttonPopupNextStep.click()
|
|
|
|
}
|
|
|
|
await this.page.locator('div.templates div.tmpHeader', { hasText: data.template }).click()
|
|
|
|
|
|
|
|
// title
|
|
|
|
await this.buttonPopupNextStep.click()
|
|
|
|
await this.inputNewDocumentTitle.fill(data.title)
|
|
|
|
await this.inputNewDocumentDescription.fill(data.description)
|
|
|
|
|
|
|
|
if (data.reason != null) {
|
|
|
|
await this.page.locator('div.radio label', { hasText: data.reason }).click()
|
|
|
|
}
|
|
|
|
|
|
|
|
// team
|
|
|
|
await this.buttonPopupNextStep.click()
|
|
|
|
|
|
|
|
await this.inputNewDocumentCreateDaft.click()
|
|
|
|
}
|
|
|
|
|
2024-08-29 18:22:44 +03:00
|
|
|
async changeSpaceInCreateDocumentForm (space: string): Promise<void> {
|
|
|
|
await this.changeSpaceButton.click()
|
|
|
|
await this.page
|
|
|
|
.locator(`div.list-container.flex-col.flex-grow.svelte-15na0wa >> text=${space}`)
|
|
|
|
.click({ force: true })
|
|
|
|
}
|
|
|
|
|
|
|
|
async createTemplate (title: string, description: string, category: string, spaceName: string): Promise<void> {
|
|
|
|
await this.changeSpaceInCreateDocumentForm(spaceName)
|
2024-07-31 19:59:12 +03:00
|
|
|
await this.buttonPopupNextStep.click()
|
|
|
|
await this.inputNewDocumentTitle.fill(title)
|
|
|
|
await this.inputNewDocumentDescription.fill(description)
|
|
|
|
await this.category.click()
|
|
|
|
await this.search.fill(category)
|
|
|
|
await this.page.getByRole('button', { name: category }).click()
|
|
|
|
await this.nextStep.click()
|
|
|
|
await this.addMember.nth(2).click()
|
|
|
|
await this.newMember.click()
|
|
|
|
await this.page.keyboard.press('Escape')
|
|
|
|
await this.inputNewDocumentCreateDaft.click()
|
|
|
|
}
|
|
|
|
|
2024-07-13 18:23:11 +03:00
|
|
|
async openDocument (name: string): Promise<void> {
|
|
|
|
await this.page.locator('button.hulyNavItem-container > span[class*="label"]', { hasText: name }).click()
|
|
|
|
}
|
|
|
|
|
|
|
|
async executeMoreActionsOnDocument (documentName: string, action: string): Promise<void> {
|
|
|
|
await this.page.locator('button.hulyNavItem-container > span[class*="label"]', { hasText: documentName }).hover()
|
|
|
|
await this.page
|
|
|
|
.locator('button.hulyNavItem-container > span[class*="label"]', { hasText: documentName })
|
|
|
|
.locator('xpath=..')
|
|
|
|
.locator('div[class*="actions"]:not([class*="arrow"])')
|
|
|
|
.click()
|
|
|
|
await this.selectFromDropdown(this.page, action)
|
|
|
|
}
|
|
|
|
}
|