Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions dev/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ services:
memory: 1024M
print:
image: hardcoreeng/print
extra_hosts:
- "host.docker.internal:host-gateway"
restart: unless-stopped
ports:
- 4005:4005
Expand Down
18 changes: 17 additions & 1 deletion qms-tests/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ version: "3"
services:
mongodb:
image: 'mongo:7-jammy'
extra_hosts:
- "host.docker.internal:host-gateway"
command: mongod --port 27018
environment:
- PUID=1000
Expand Down Expand Up @@ -38,6 +40,8 @@ services:
test: curl -s http://localhost:9200/_cluster/health | grep -vq '"status":"red"'
account:
image: hardcoreeng/account
extra_hosts:
- "host.docker.internal:host-gateway"
pull_policy: never
links:
- mongodb
Expand All @@ -56,6 +60,8 @@ services:
- BRANDING_PATH=/var/cfg/branding-test.json
workspace:
image: hardcoreeng/workspace
extra_hosts:
- "host.docker.internal:host-gateway"
links:
- mongodb
- minio
Expand All @@ -73,6 +79,8 @@ services:
restart: unless-stopped
front:
image: hardcoreeng/front
extra_hosts:
- "host.docker.internal:host-gateway"
pull_policy: never
links:
- account
Expand Down Expand Up @@ -103,6 +111,8 @@ services:
- SIGN_URL=http://host.docker.internal:4006
transactor:
image: hardcoreeng/transactor
extra_hosts:
- "host.docker.internal:host-gateway"
pull_policy: never
links:
- mongodb
Expand Down Expand Up @@ -132,6 +142,8 @@ services:
- BRANDING_PATH=/var/cfg/branding-test.json
collaborator:
image: hardcoreeng/collaborator
extra_hosts:
- "host.docker.internal:host-gateway"
links:
- mongodb
- minio
Expand All @@ -151,6 +163,8 @@ services:
restart: on-failure
print:
image: hardcoreeng/print
extra_hosts:
- "host.docker.internal:host-gateway"
restart: unless-stopped
ports:
- 4005:4005
Expand All @@ -165,6 +179,8 @@ services:
memory: 300M
sign:
image: hardcoreeng/sign
extra_hosts:
- "host.docker.internal:host-gateway"
restart: unless-stopped
ports:
- 4006:4006
Expand All @@ -177,7 +193,7 @@ services:
- MONGO_OPTIONS={"appName":"sign","maxPoolSize":1}
- MINIO_ENDPOINT=minio
- MINIO_ACCESS_KEY=minioadmin
- ACCOUNTS_URL=http://host.docker.internal:3000
- ACCOUNTS_URL=http://account:3003
- MINIO_SECRET_KEY=minioadmin
- CERTIFICATE_PATH=/var/cfg/certificate.p12
- SERVICE_ID=sign-service
Expand Down
82 changes: 82 additions & 0 deletions qms-tests/sanity/tests/documents/REQ-04-01.spec.ts
Original file line number Diff line number Diff line change
@@ -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)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export class DocumentContentPage extends DocumentCommonPage {
readonly changeSpaceButton: Locator
readonly createNewTemplateFromSpace: Locator
readonly okButton: Locator
readonly documentThreeDots: Locator

constructor (page: Page) {
super(page)
Expand Down Expand Up @@ -176,6 +177,7 @@ export class DocumentContentPage extends DocumentCommonPage {
this.changeSpaceButton = page.locator('[id="space\\.selector"]')
this.createNewTemplateFromSpace = page.getByRole('button', { name: 'Create new template' })
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> {
Expand All @@ -198,6 +200,10 @@ export class DocumentContentPage extends DocumentCommonPage {
await this.newTemplate.click()
}

async clickDocumentThreeDots (): Promise<void> {
await this.documentThreeDots.click()
}

async selectControlDocumentSubcategory (
buttonName: 'My Document' | 'Library' | 'Templates' | 'Categories' | 'General documentation'
): Promise<void> {
Expand Down
28 changes: 28 additions & 0 deletions qms-tests/sanity/tests/model/documents/pdf-pages.ts
Original file line number Diff line number Diff line change
@@ -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}`)
}
}