Skip to content

Commit

Permalink
REQ-10 add test for roles and setup permissions (#6257)
Browse files Browse the repository at this point in the history
Signed-off-by: Jasmin <[email protected]>
  • Loading branch information
JasminMus authored Aug 29, 2024
1 parent 46ced93 commit 387aecd
Show file tree
Hide file tree
Showing 17 changed files with 547 additions and 240 deletions.
3 changes: 3 additions & 0 deletions qms-tests/create-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
# Create second user record in accounts
./tool-local.sh create-account user2 -f Kainin -l Dirak -p 1234
./tool-local.sh confirm-email user2
# Create third user record in accounts
./tool-local.sh create-account user3 -f Cain -l Velasquez -p 1234
./tool-local.sh confirm-email user3

./tool-local.sh create-account user_qara -f Qara -l Admin -p 1234
./tool-local.sh confirm-email user_qara
4 changes: 4 additions & 0 deletions qms-tests/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,15 @@ fi
# Create user record in accounts
./tool.sh create-account user1 -f John -l Appleseed -p 1234
./tool.sh create-account user2 -f Kainin -l Dirak -p 1234
./tool.sh create-account user3 -f Cain -l Velasquez -p 1234

./tool.sh assign-workspace user1 sanity-ws-qms
./tool.sh assign-workspace user2 sanity-ws-qms
./tool.sh assign-workspace user3 sanity-ws-qms
# Make user the workspace maintainer
./tool.sh confirm-email user1
./tool.sh confirm-email user2
./tool.sh confirm-email user3

./tool.sh create-account user_qara -f Qara -l Admin -p 1234
./tool.sh assign-workspace user_qara sanity-ws-qms
Expand Down
2 changes: 2 additions & 0 deletions qms-tests/restore-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export SERVER_SECRET=secret
# Re-assign user to workspace.
./tool-local.sh assign-workspace user1 sanity-ws-qms
./tool-local.sh assign-workspace user2 sanity-ws-qms
./tool-local.sh assign-workspace user3 sanity-ws-qms

./tool-local.sh assign-workspace user_qara sanity-ws-qms
./tool-local.sh set-user-role user1 sanity-ws-qms OWNER
./tool-local.sh set-user-role user2 sanity-ws-qms OWNER
Expand Down
5 changes: 4 additions & 1 deletion qms-tests/restore-workspace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
# Re-assign user to workspace.
./tool.sh assign-workspace user1 sanity-ws-qms
./tool.sh assign-workspace user2 sanity-ws-qms
./tool.sh assign-workspace user3 sanity-ws-qms

./tool.sh set-user-role user2 sanity-ws-qms OWNER
./tool.sh assign-workspace user_qara sanity-ws-qms

./tool.sh configure sanity-ws-qms --enable=*
./tool.sh configure sanity-ws-qms --list
./tool.sh configure sanity-ws-qms --list
2 changes: 2 additions & 0 deletions qms-tests/sanity/.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ PLATFORM_URI='http://localhost:8083'
PLATFORM_TRANSACTOR='ws://localhost:3334'
PLATFORM_USER='user1'
PLATFORM_USER_SECOND='user2'
REGULAR_USER='user3'
PLATFORM_TOKEN='eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjb25maXJtZWQiOnRydWUsImVtYWlsIjoidXNlcjEiLCJ3b3Jrc3BhY2UiOiJzYW5pdHktd3MtcW1zIiwicHJvZHVjdElkIjoiIn0.vQK1jI8gHkjnNJf5XZ71L4dCqyHNmKW4_iBGrhXrqW8'
SETTING=storage.json
SETTING_SECOND=storageSecond.json
SETTING_THIRD=storageThird.json
SETTING_QARA_MANAGER=storageQaraManager.json
PLATFORM_PASSWORD='1234'
34 changes: 34 additions & 0 deletions qms-tests/sanity/storageThird-dev.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"cookies": [],
"origins": [
{
"origin": "http://localhost:8080",
"localStorage": [
{
"name": "login:metadata:LoginEmail",
"value": "user3"
},
{
"name": "login:metadata:LoginTokens",
"value": "{\"sanity-ws-qms\":\"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjb25maXJtZWQiOnRydWUsImVtYWlsIjoidXNlcjMiLCJ3b3Jrc3BhY2UiOiJzYW5pdHktd3MtcW1zIiwicHJvZHVjdElkIjoiIn0.ylvF9znBgI9iQpHSR6GKvhI5yHDE9m8jB4eUPWuwuKk\"}"
},
{
"name": "login:metadata:LoginEndpoint",
"value": "ws://localhost:3334"
},
{
"name": "#platform.notification.logging",
"value": "false"
},
{
"name": "#platform.lazy.loading",
"value": "false"
},
{
"name": "flagOpenInDesktopApp",
"value": "true"
}
]
}
]
}
34 changes: 34 additions & 0 deletions qms-tests/sanity/storageThird.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"cookies": [],
"origins": [
{
"origin": "http://localhost:8083",
"localStorage": [
{
"name": "login:metadata:LoginEmail",
"value": "user3"
},
{
"name": "login:metadata:LoginTokens",
"value": "{\"sanity-ws-qms\":\"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjb25maXJtZWQiOnRydWUsImVtYWlsIjoidXNlcjMiLCJ3b3Jrc3BhY2UiOiJzYW5pdHktd3MtcW1zIiwicHJvZHVjdElkIjoiIn0.ylvF9znBgI9iQpHSR6GKvhI5yHDE9m8jB4eUPWuwuKk\"}"
},
{
"name": "login:metadata:LoginEndpoint",
"value": "ws://localhost:3334"
},
{
"name": "#platform.notification.logging",
"value": "false"
},
{
"name": "#platform.lazy.loading",
"value": "false"
},
{
"name": "flagOpenInDesktopApp",
"value": "true"
}
]
}
]
}
208 changes: 208 additions & 0 deletions qms-tests/sanity/tests/documents/REQ-05-1.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
import { test } from '@playwright/test'
import {
attachScreenshot,
DocumentURI,
generateId,
getSecondPage,
HomepageURI,
PlatformSetting,
PlatformURI
} from '../utils'
import { allure } from 'allure-playwright'
import { DocumentContentPage } from '../model/documents/document-content-page'
import { LeftSideMenuPage } from '../model/left-side-menu-page'

import { faker } from '@faker-js/faker'
import { createTemplateStep, prepareDocumentStep } from './common-documents-steps'
import { DocumentRights, DocumentStatus, NewDocument, NewTemplate } from '../model/types'
import { DocumentsPage } from '../model/documents/documents-page'

test.use({
storageState: PlatformSetting
})

test.describe('ISO 13485, 4.2.4 Control of documents', () => {
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-382. Create new a new Effective Template with category External', async ({ page }) => {
await allure.description('Requirement\nUsers need to create a new template')
await allure.tms('TESTS-382', 'https://tracex.hc.engineering/workbench/platform/tracker/TESTS-382')

const leftSideMenuPage = new LeftSideMenuPage(page)
const category = faker.word.words(2)
const description = faker.lorem.sentence(1)
const code = faker.word.words(2)
const title = faker.word.words(2)

const newTemplate: NewTemplate = {
location: {
space: 'Quality documents',
parent: 'Quality documents'
},
title,
description,
code,
category,
reason: 'Test reason',
reviewers: ['Appleseed John'],
approvers: ['Appleseed John']
}

await leftSideMenuPage.clickButtonOnTheLeft('Documents')
await test.step('2. Create a new category', async () => {
const documentContentPage = new DocumentContentPage(page)
await documentContentPage.selectControlDocumentSubcategory('Categories')
await documentContentPage.clickOnAddCategoryButton()
await documentContentPage.fillCategoryForm(category, description, code)
await documentContentPage.expectCategoryCreated(category, code)
})
await test.step('3. Create a new template', async () => {
const documentContentPage = new DocumentContentPage(page)
await documentContentPage.clickNewDocumentArrow()
await documentContentPage.clickNewTemplate()
await createTemplateStep(page, title, description, category, 'Quality documents')
})
await test.step('4. Check document information', async () => {
const documentContentPage = new DocumentContentPage(page)
await documentContentPage.checkDocumentTitle(newTemplate.title)
await documentContentPage.checkDocument({
type: 'N/A',
category: newTemplate.category ?? '',
version: 'v0.1',
status: DocumentStatus.DRAFT,
owner: 'Appleseed John',
author: 'Appleseed John'
})
})
await test.step('5. Check if templates exists in template category', async () => {
const documentContentPage = new DocumentContentPage(page)
await documentContentPage.selectControlDocumentSubcategory('Templates')
await documentContentPage.chooseFilter(code)
await documentContentPage.checkIfFilterIsApplied(title)
})
await attachScreenshot('TESTS-382_Template_created.png', page)
})

test('TESTS-338. Negative: as a space Member only, I cannot be assigned as an approver to any document of this space', async ({
page
}) => {
await allure.description(
'Requirement\nUser is a space member and cannot be assigned as an approver to any document of this space'
)
await allure.tms('TESTS-338', 'https://tracex.hc.engineering/workbench/platform/tracker/TESTS-338')
const completeDocument: NewDocument = {
template: 'HR (HR)',
title: `Complete document-${generateId()}`,
description: `Complete document description-${generateId()}`
}
const leftSideMenuPage = new LeftSideMenuPage(page)

await leftSideMenuPage.clickButtonOnTheLeft('Documents')
await test.step('2. Add a member to space', async () => {
const documentContentPage = new DocumentContentPage(page)
await documentContentPage.addMemberToQualityDocument()
})
await test.step('3. Check if the member exists in approve list', async () => {
await prepareDocumentStep(page, completeDocument)

const documentContentPage = new DocumentContentPage(page)
await documentContentPage.clickSendForApproval()
await documentContentPage.clickAddMember()
await documentContentPage.checkIfMemberDropdownHasMember('Cain Velasquez', false)
})
await attachScreenshot('TESTS-338_Member_not_in_the_list.png', page)
})

test('TESTS-383. Authorized User can search a doc per category ', async ({ browser, page }) => {
await allure.description('Requirement\nUsers need to create a new category')
await allure.tms('TESTS-383', 'https://tracex.hc.engineering/workbench/platform/tracker/TESTS-383')
const userSecondPage = await getSecondPage(browser)

const title = faker.word.words(2)
const description = faker.lorem.sentence(1)
const code = faker.word.words(2)
const leftSideMenuPage = new LeftSideMenuPage(page)

await leftSideMenuPage.clickButtonOnTheLeft('Documents')
const category = faker.word.words(2)
const newTemplate: NewTemplate = {
location: {
space: 'Quality documents',
parent: 'Quality documents'
},
title,
description,
code,
category,
reason: 'Test reason',
reviewers: ['Appleseed John'],
approvers: ['Appleseed John']
}
const reviewer = 'Dirak Kainin'
await leftSideMenuPage.clickButtonOnTheLeft('Documents')

await test.step('2. Create a new category', async () => {
const documentContentPage = new DocumentContentPage(page)
await documentContentPage.selectControlDocumentSubcategory('Categories')
await documentContentPage.clickOnAddCategoryButton()
await documentContentPage.fillCategoryForm(category, description, code)
await documentContentPage.expectCategoryCreated(category, code)
})
await test.step('3. Create a new template', async () => {
const documentContentPage = new DocumentContentPage(page)
await documentContentPage.clickNewDocumentArrow()
await documentContentPage.clickNewTemplate()
await createTemplateStep(page, title, description, category, 'Quality documents')
})
await test.step('4. Send for Approval', async () => {
const documentContentPage = new DocumentContentPage(page)
await documentContentPage.buttonSendForApproval.click()
await documentContentPage.fillSelectApproversForm([reviewer])
await documentContentPage.checkDocumentStatus(DocumentStatus.IN_APPROVAL)
await documentContentPage.checkCurrentRights(DocumentRights.VIEWING)
await documentContentPage.confirmApproval()
})

await test.step('5. Approve document', async () => {
const documentsPageSecond = new DocumentsPage(userSecondPage)
await (await userSecondPage.goto(`${PlatformURI}/${DocumentURI}`))?.finished()
await documentsPageSecond.openDocument(title)

const documentContentPageSecond = new DocumentContentPage(userSecondPage)
await documentContentPageSecond.confirmApproval()

await documentContentPageSecond.checkDocumentStatus(DocumentStatus.EFFECTIVE)
await documentContentPageSecond.checkCurrentRights(DocumentRights.VIEWING)

await test.step('6. Check document information', async () => {
const documentContentPage = new DocumentContentPage(page)
await documentContentPage.checkDocumentTitle(newTemplate.title)
await documentContentPage.checkDocument({
type: 'N/A',
category: newTemplate.category ?? '',
version: 'v0.1',
status: DocumentStatus.EFFECTIVE,
owner: 'Appleseed John',
author: 'Appleseed John'
})
})
await test.step('7. Check if templates exists in template category', async () => {
const documentContentPage = new DocumentContentPage(page)
await documentContentPage.selectControlDocumentSubcategory('Templates')
await documentContentPage.chooseFilter(code)
await documentContentPage.checkIfFilterIsApplied(title)
await documentContentPage.checkIfCategoryExists(category)
})
await attachScreenshot('TESTS-383_Template_created.png', page)
})
})
})
Loading

0 comments on commit 387aecd

Please sign in to comment.