mirror of
https://github.com/hcengineering/platform.git
synced 2025-06-05 15:24:22 +00:00
Add test for downloading PDF (#6541)
Signed-off-by: Jasmin <jasmin@hardcoreeng.com> Co-authored-by: Alexey Zinoviev <alexey.zinoviev@xored.com>
This commit is contained in:
parent
c949a79d28
commit
9095853f7b
@ -217,6 +217,8 @@ services:
|
|||||||
memory: 1024M
|
memory: 1024M
|
||||||
print:
|
print:
|
||||||
image: hardcoreeng/print
|
image: hardcoreeng/print
|
||||||
|
extra_hosts:
|
||||||
|
- "host.docker.internal:host-gateway"
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- 4005:4005
|
- 4005:4005
|
||||||
|
@ -2,6 +2,8 @@ version: "3"
|
|||||||
services:
|
services:
|
||||||
mongodb:
|
mongodb:
|
||||||
image: 'mongo:7-jammy'
|
image: 'mongo:7-jammy'
|
||||||
|
extra_hosts:
|
||||||
|
- "host.docker.internal:host-gateway"
|
||||||
command: mongod --port 27018
|
command: mongod --port 27018
|
||||||
environment:
|
environment:
|
||||||
- PUID=1000
|
- PUID=1000
|
||||||
@ -38,6 +40,8 @@ services:
|
|||||||
test: curl -s http://localhost:9200/_cluster/health | grep -vq '"status":"red"'
|
test: curl -s http://localhost:9200/_cluster/health | grep -vq '"status":"red"'
|
||||||
account:
|
account:
|
||||||
image: hardcoreeng/account
|
image: hardcoreeng/account
|
||||||
|
extra_hosts:
|
||||||
|
- "host.docker.internal:host-gateway"
|
||||||
pull_policy: never
|
pull_policy: never
|
||||||
links:
|
links:
|
||||||
- mongodb
|
- mongodb
|
||||||
@ -56,6 +60,8 @@ services:
|
|||||||
- BRANDING_PATH=/var/cfg/branding-test.json
|
- BRANDING_PATH=/var/cfg/branding-test.json
|
||||||
workspace:
|
workspace:
|
||||||
image: hardcoreeng/workspace
|
image: hardcoreeng/workspace
|
||||||
|
extra_hosts:
|
||||||
|
- "host.docker.internal:host-gateway"
|
||||||
links:
|
links:
|
||||||
- mongodb
|
- mongodb
|
||||||
- minio
|
- minio
|
||||||
@ -73,6 +79,8 @@ services:
|
|||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
front:
|
front:
|
||||||
image: hardcoreeng/front
|
image: hardcoreeng/front
|
||||||
|
extra_hosts:
|
||||||
|
- "host.docker.internal:host-gateway"
|
||||||
pull_policy: never
|
pull_policy: never
|
||||||
links:
|
links:
|
||||||
- account
|
- account
|
||||||
@ -103,6 +111,8 @@ services:
|
|||||||
- SIGN_URL=http://host.docker.internal:4006
|
- SIGN_URL=http://host.docker.internal:4006
|
||||||
transactor:
|
transactor:
|
||||||
image: hardcoreeng/transactor
|
image: hardcoreeng/transactor
|
||||||
|
extra_hosts:
|
||||||
|
- "host.docker.internal:host-gateway"
|
||||||
pull_policy: never
|
pull_policy: never
|
||||||
links:
|
links:
|
||||||
- mongodb
|
- mongodb
|
||||||
@ -132,6 +142,8 @@ services:
|
|||||||
- BRANDING_PATH=/var/cfg/branding-test.json
|
- BRANDING_PATH=/var/cfg/branding-test.json
|
||||||
collaborator:
|
collaborator:
|
||||||
image: hardcoreeng/collaborator
|
image: hardcoreeng/collaborator
|
||||||
|
extra_hosts:
|
||||||
|
- "host.docker.internal:host-gateway"
|
||||||
links:
|
links:
|
||||||
- mongodb
|
- mongodb
|
||||||
- minio
|
- minio
|
||||||
@ -151,6 +163,8 @@ services:
|
|||||||
restart: on-failure
|
restart: on-failure
|
||||||
print:
|
print:
|
||||||
image: hardcoreeng/print
|
image: hardcoreeng/print
|
||||||
|
extra_hosts:
|
||||||
|
- "host.docker.internal:host-gateway"
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- 4005:4005
|
- 4005:4005
|
||||||
@ -165,6 +179,8 @@ services:
|
|||||||
memory: 300M
|
memory: 300M
|
||||||
sign:
|
sign:
|
||||||
image: hardcoreeng/sign
|
image: hardcoreeng/sign
|
||||||
|
extra_hosts:
|
||||||
|
- "host.docker.internal:host-gateway"
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- 4006:4006
|
- 4006:4006
|
||||||
@ -177,7 +193,7 @@ services:
|
|||||||
- MONGO_OPTIONS={"appName":"sign","maxPoolSize":1}
|
- MONGO_OPTIONS={"appName":"sign","maxPoolSize":1}
|
||||||
- MINIO_ENDPOINT=minio
|
- MINIO_ENDPOINT=minio
|
||||||
- MINIO_ACCESS_KEY=minioadmin
|
- MINIO_ACCESS_KEY=minioadmin
|
||||||
- ACCOUNTS_URL=http://host.docker.internal:3000
|
- ACCOUNTS_URL=http://account:3003
|
||||||
- MINIO_SECRET_KEY=minioadmin
|
- MINIO_SECRET_KEY=minioadmin
|
||||||
- CERTIFICATE_PATH=/var/cfg/certificate.p12
|
- CERTIFICATE_PATH=/var/cfg/certificate.p12
|
||||||
- SERVICE_ID=sign-service
|
- SERVICE_ID=sign-service
|
||||||
|
82
qms-tests/sanity/tests/documents/REQ-04-01.spec.ts
Normal file
82
qms-tests/sanity/tests/documents/REQ-04-01.spec.ts
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
import { test } from '@playwright/test'
|
||||||
|
import { attachScreenshot, generateId, HomepageURI, PlatformSetting, PlatformURI } from '../utils'
|
||||||
|
import { allure } from 'allure-playwright'
|
||||||
|
import { DocumentDetails, DocumentRights, DocumentStatus, NewDocument } from '../model/types'
|
||||||
|
import { DocumentContentPage } from '../model/documents/document-content-page'
|
||||||
|
import { prepareDocumentStep } from './common-documents-steps'
|
||||||
|
import { DocumentApprovalsPage } from '../model/documents/document-approvals-page'
|
||||||
|
import { PdfPages } from '../model/documents/pdf-pages'
|
||||||
|
|
||||||
|
test.use({
|
||||||
|
storageState: PlatformSetting
|
||||||
|
})
|
||||||
|
|
||||||
|
test.describe('QMS. PDF Download', () => {
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
await (await page.goto(`${PlatformURI}/${HomepageURI}`))?.finished()
|
||||||
|
})
|
||||||
|
|
||||||
|
test.afterEach(async ({ browser }) => {
|
||||||
|
const contexts = browser.contexts()
|
||||||
|
for (const context of contexts) {
|
||||||
|
await context.close()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
test('TESTS-271. Download PDF', async ({ page }) => {
|
||||||
|
await allure.description('Requirement\nUsers need to approve the document')
|
||||||
|
await allure.tms('TESTS-271', 'https://tracex.hc.engineering/workbench/platform/tracker/TESTS-271')
|
||||||
|
const approveDocument: NewDocument = {
|
||||||
|
template: 'HR (HR)',
|
||||||
|
title: `Approve document-${generateId()}`,
|
||||||
|
description: `Approve document description-${generateId()}`
|
||||||
|
}
|
||||||
|
const documentDetails: DocumentDetails = {
|
||||||
|
type: 'HR',
|
||||||
|
category: 'Human Resources',
|
||||||
|
version: 'v0.1',
|
||||||
|
status: DocumentStatus.DRAFT,
|
||||||
|
owner: 'Appleseed John',
|
||||||
|
author: 'Appleseed John'
|
||||||
|
}
|
||||||
|
|
||||||
|
await prepareDocumentStep(page, approveDocument)
|
||||||
|
const documentContentPage = new DocumentContentPage(page)
|
||||||
|
await test.step('2. Send for Approval', async () => {
|
||||||
|
await documentContentPage.buttonSendForApproval.click()
|
||||||
|
await documentContentPage.fillSelectApproversForm([documentDetails.owner])
|
||||||
|
await documentContentPage.checkDocumentStatus(DocumentStatus.IN_APPROVAL)
|
||||||
|
await documentContentPage.checkDocument({
|
||||||
|
...documentDetails,
|
||||||
|
status: DocumentStatus.IN_APPROVAL
|
||||||
|
})
|
||||||
|
await documentContentPage.checkCurrentRights(DocumentRights.VIEWING)
|
||||||
|
})
|
||||||
|
|
||||||
|
await test.step('3. Approve document', async () => {
|
||||||
|
await documentContentPage.confirmApproval()
|
||||||
|
})
|
||||||
|
|
||||||
|
await test.step('4. Check the document and status', async () => {
|
||||||
|
await documentContentPage.checkDocumentStatus(DocumentStatus.EFFECTIVE)
|
||||||
|
await documentContentPage.checkDocument({
|
||||||
|
...documentDetails,
|
||||||
|
status: DocumentStatus.EFFECTIVE,
|
||||||
|
version: 'v0.1'
|
||||||
|
})
|
||||||
|
await documentContentPage.checkCurrentRights(DocumentRights.VIEWING)
|
||||||
|
|
||||||
|
await documentContentPage.openApprovals()
|
||||||
|
const documentApprovalsPage = new DocumentApprovalsPage(page)
|
||||||
|
await documentApprovalsPage.checkSuccessApproval(documentDetails.owner)
|
||||||
|
await attachScreenshot('TESTS-271_approve_document.png', page)
|
||||||
|
})
|
||||||
|
await test.step('5. Download PDF', async () => {
|
||||||
|
await documentContentPage.clickDocumentThreeDots()
|
||||||
|
const pdfPages = new PdfPages(page)
|
||||||
|
await pdfPages.printToPdfClick()
|
||||||
|
await pdfPages.downloadAndVerifyPdf()
|
||||||
|
})
|
||||||
|
await attachScreenshot('TESTS-271_ddownloaded_document.png', page)
|
||||||
|
})
|
||||||
|
})
|
@ -83,6 +83,7 @@ export class DocumentContentPage extends DocumentCommonPage {
|
|||||||
readonly changeSpaceButton: Locator
|
readonly changeSpaceButton: Locator
|
||||||
readonly createNewTemplateFromSpace: Locator
|
readonly createNewTemplateFromSpace: Locator
|
||||||
readonly okButton: Locator
|
readonly okButton: Locator
|
||||||
|
readonly documentThreeDots: Locator
|
||||||
|
|
||||||
constructor (page: Page) {
|
constructor (page: Page) {
|
||||||
super(page)
|
super(page)
|
||||||
@ -176,6 +177,7 @@ export class DocumentContentPage extends DocumentCommonPage {
|
|||||||
this.changeSpaceButton = page.locator('[id="space\\.selector"]')
|
this.changeSpaceButton = page.locator('[id="space\\.selector"]')
|
||||||
this.createNewTemplateFromSpace = page.getByRole('button', { name: 'Create new template' })
|
this.createNewTemplateFromSpace = page.getByRole('button', { name: 'Create new template' })
|
||||||
this.okButton = page.getByRole('button', { name: 'Ok', exact: true })
|
this.okButton = page.getByRole('button', { name: 'Ok', exact: true })
|
||||||
|
this.documentThreeDots = page.locator("div[class='no-print ml-1'] button[type='button']")
|
||||||
}
|
}
|
||||||
|
|
||||||
async checkDocumentTitle (title: string): Promise<void> {
|
async checkDocumentTitle (title: string): Promise<void> {
|
||||||
@ -198,6 +200,10 @@ export class DocumentContentPage extends DocumentCommonPage {
|
|||||||
await this.newTemplate.click()
|
await this.newTemplate.click()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async clickDocumentThreeDots (): Promise<void> {
|
||||||
|
await this.documentThreeDots.click()
|
||||||
|
}
|
||||||
|
|
||||||
async selectControlDocumentSubcategory (
|
async selectControlDocumentSubcategory (
|
||||||
buttonName: 'My Document' | 'Library' | 'Templates' | 'Categories' | 'General documentation'
|
buttonName: 'My Document' | 'Library' | 'Templates' | 'Categories' | 'General documentation'
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
28
qms-tests/sanity/tests/model/documents/pdf-pages.ts
Normal file
28
qms-tests/sanity/tests/model/documents/pdf-pages.ts
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import { type Locator, type Page, expect } from '@playwright/test'
|
||||||
|
|
||||||
|
export class PdfPages {
|
||||||
|
readonly page: Page
|
||||||
|
readonly printToPdf: Locator
|
||||||
|
readonly printToPdfHeader: Locator
|
||||||
|
readonly downloadPdf: 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')
|
||||||
|
}
|
||||||
|
|
||||||
|
async printToPdfClick (): Promise<void> {
|
||||||
|
await this.printToPdf.click()
|
||||||
|
await expect(this.printToPdfHeader).toBeVisible()
|
||||||
|
}
|
||||||
|
|
||||||
|
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}`)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user