mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-22 02:51:54 +03:00
1d3299e384
Some checks are pending
CI / build (push) Waiting to run
CI / svelte-check (push) Blocked by required conditions
CI / formatting (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / uitest (push) Waiting to run
CI / uitest-pg (push) Waiting to run
CI / uitest-qms (push) Waiting to run
CI / docker-build (push) Blocked by required conditions
CI / dist-build (push) Blocked by required conditions
Signed-off-by: Jasmin <jasmin@hardcoreeng.com>
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import { type Locator, type Page, expect } from '@playwright/test'
|
|
|
|
export class PdfPages {
|
|
readonly page: Page
|
|
readonly printToPdf: Locator
|
|
readonly printToPdfHeader: Locator
|
|
readonly downloadPdf: Locator
|
|
readonly showFullScreenPdf: Locator
|
|
|
|
constructor (page: Page) {
|
|
this.page = page
|
|
this.printToPdf = page.getByRole('button', { name: 'Print to PDF' })
|
|
this.printToPdfHeader = page.getByText('PDF PDF print preview')
|
|
this.downloadPdf = page.locator('form').getByRole('link').getByRole('button')
|
|
this.showFullScreenPdf = page.locator('form').getByRole('button').nth(2)
|
|
}
|
|
|
|
async printToPdfClick (): Promise<void> {
|
|
await this.printToPdf.click()
|
|
await expect(this.printToPdfHeader).toBeVisible()
|
|
}
|
|
|
|
async showFullScreenPdfClick (): Promise<void> {
|
|
await this.showFullScreenPdf.click()
|
|
}
|
|
|
|
async downloadAndVerifyPdf (): Promise<void> {
|
|
const [download] = await Promise.all([this.page.waitForEvent('download'), this.downloadPdf.click()])
|
|
const filePath = await download.path()
|
|
expect(filePath).toBeTruthy()
|
|
const fileName = download.suggestedFilename()
|
|
console.log(`Downloaded file: ${fileName}`)
|
|
}
|
|
}
|