From 4e44f73314e36cf13ee7146e0be163a2998760a4 Mon Sep 17 00:00:00 2001 From: JasminMus <167111741+JasminMus@users.noreply.github.com> Date: Wed, 11 Sep 2024 12:54:17 +0200 Subject: [PATCH] Add Req 10 test (#6458) Signed-off-by: Jasmin --- .../sanity/tests/documents/REQ-10.spec.ts | 77 ++++++++++++++++ .../tests/documents/common-documents-steps.ts | 10 ++- .../sanity/tests/documents/documents.spec.ts | 1 - .../sanity/tests/documents/templates.spec.ts | 1 - .../model/documents/document-content-page.ts | 90 ++++++++++++++++++- .../tests/model/documents/documents-page.ts | 8 +- 6 files changed, 180 insertions(+), 7 deletions(-) diff --git a/qms-tests/sanity/tests/documents/REQ-10.spec.ts b/qms-tests/sanity/tests/documents/REQ-10.spec.ts index 1ef459f4f3..6c675f55ee 100644 --- a/qms-tests/sanity/tests/documents/REQ-10.spec.ts +++ b/qms-tests/sanity/tests/documents/REQ-10.spec.ts @@ -75,4 +75,81 @@ test.describe('ISO 13485, 4.2.4 Control of documents ensure that documents of ex await attachScreenshot('TESTS-347_manager_document_created.png', page) }) }) + + test('TESTS-402. As a non space member, I cannot see nor edit any doc from that space', async ({ page }) => { + await allure.description( + 'Requirement\nUser is not a part of space members and cannot see or edit any document from that space' + ) + await allure.tms('TESTS-402', 'https://tracex.hc.engineering/workbench/platform/tracker/TESTS-402') + await test.step('2. check if non member can see space', async () => { + const folderName = faker.word.words(1) + const documentContentPage = new DocumentContentPage(page) + await documentContentPage.clickAddFolderButton() + await documentContentPage.fillDocumentSpaceFormManager(folderName) + await documentContentPage.changeDocumentSpaceMembers(folderName) + await documentContentPage.checkIfTheSpaceIsVisible(folderName, false) + await attachScreenshot('TESTS-402_space_not_existing.png', page) + }) + }) + + test('TESTS-403. As a space member only, I cannot edit any doc from that space', async ({ page }) => { + await allure.description( + 'Requirement\nUser is only part as a member and cannot see or edit any document from that space' + ) + await allure.tms('TESTS-403', 'https://tracex.hc.engineering/workbench/platform/tracker/TESTS-403') + await test.step('2. check if non member edit or create a new doc in space', async () => { + const folderName = faker.word.words(1) + const documentContentPage = new DocumentContentPage(page) + const completeDocument: NewDocument = { + template: 'HR (HR)', + title: `Complete document-${generateId()}`, + description: `Complete document description-${generateId()}` + } + await documentContentPage.clickAddFolderButton() + await documentContentPage.fillDocumentSpaceFormManager(folderName) + await prepareDocumentStep(page, completeDocument, 1, undefined, folderName) + await documentContentPage.checkTeamMembersReviewerCoauthorApproverNotExists() + await attachScreenshot('TESTS-403_member_cant_edit_space.png', page) + }) + }) + + test('TESTS-404. As a space member only, I cannot create any doc from that space', async ({ page }) => { + await allure.description('Requirement\nUser is not able to create any document from that space') + await allure.tms('TESTS-404', 'https://tracex.hc.engineering/workbench/platform/tracker/TESTS-404') + await test.step('2. cCheck if user can not create documents as a space member', async () => { + const folderName = faker.word.words(1) + const documentContentPage = new DocumentContentPage(page) + await documentContentPage.clickAddFolderButton() + await documentContentPage.createDocumentSpaceMembersToJustMember(folderName) + await documentContentPage.checkIfEditSpaceButtonExists(folderName, false) + await page.keyboard.press('Escape') + await documentContentPage.checkIfUserCanSelectSpace(folderName, false) + await attachScreenshot('TESTS-404_non_space_member_can_not_create_documents.png', page) + }) + }) + + test('TESTS-405. As a Manager space member, I can delete a doc I have previously created', async ({ page }) => { + await allure.description('Requirement\nUser is not able to create any document from that space') + const completeDocument: NewDocument = { + template: 'HR (HR)', + title: `Complete document-${generateId()}`, + description: `Complete document description-${generateId()}` + } + await allure.tms('TESTS-405', 'https://tracex.hc.engineering/workbench/platform/tracker/TESTS-405') + await test.step('2. cCheck if user can not create documents as a space member', async () => { + const folderName = faker.word.words(1) + const documentContentPage = new DocumentContentPage(page) + await documentContentPage.clickAddFolderButton() + await documentContentPage.fillQuaraManager(folderName) + // check if user can create document in space + await prepareDocumentStep(page, completeDocument, 1, undefined, folderName) + await documentContentPage.executeMoreActions('Delete') + }) + + await test.step('3. Check that the document status is equal to deleted status', async () => { + const documentContentPage = new DocumentContentPage(page) + await documentContentPage.checkDocumentStatus(DocumentStatus.DELETED) + }) + await attachScreenshot('TESTS-405_status_is_deleted.png', page) + }) }) diff --git a/qms-tests/sanity/tests/documents/common-documents-steps.ts b/qms-tests/sanity/tests/documents/common-documents-steps.ts index edbfbbf27d..6012e9a796 100644 --- a/qms-tests/sanity/tests/documents/common-documents-steps.ts +++ b/qms-tests/sanity/tests/documents/common-documents-steps.ts @@ -6,7 +6,13 @@ import { NavigationMenuPage } from '../model/documents/navigation-menu-page' import { CategoriesPage } from '../model/documents/categories-page' import { CategoryCreatePopup } from '../model/documents/category-create-popup' -export async function prepareDocumentStep (page: Page, document: NewDocument, stepNumber: number = 1): Promise { +export async function prepareDocumentStep ( + page: Page, + document: NewDocument, + stepNumber: number = 1, + startSecondStep?: boolean, + spaceName?: string +): Promise { await test.step(`${stepNumber}. Create a new document`, async () => { const leftSideMenuPage = new LeftSideMenuPage(page) await leftSideMenuPage.buttonDocuments.click() @@ -14,7 +20,7 @@ export async function prepareDocumentStep (page: Page, document: NewDocument, st const documentsPage = new DocumentsPage(page) await documentsPage.buttonCreateDocument.click() - await documentsPage.createDocument(document) + await documentsPage.createDocument(document, startSecondStep, spaceName) }) } diff --git a/qms-tests/sanity/tests/documents/documents.spec.ts b/qms-tests/sanity/tests/documents/documents.spec.ts index 149c17df52..c0f935c51a 100644 --- a/qms-tests/sanity/tests/documents/documents.spec.ts +++ b/qms-tests/sanity/tests/documents/documents.spec.ts @@ -95,7 +95,6 @@ test.describe('QMS. Documents tests', () => { await documentContentPage.checkDocumentTitle(deleteDocument.title) await documentContentPage.checkDocumentStatus(DocumentStatus.DRAFT) await documentContentPage.executeMoreActions('Delete') - await documentContentPage.pressYesForPopup(page) }) await test.step('3. Check that the document status is equal to deleted status', async () => { diff --git a/qms-tests/sanity/tests/documents/templates.spec.ts b/qms-tests/sanity/tests/documents/templates.spec.ts index e75026de36..e0676b939d 100644 --- a/qms-tests/sanity/tests/documents/templates.spec.ts +++ b/qms-tests/sanity/tests/documents/templates.spec.ts @@ -93,7 +93,6 @@ test.describe('QMS. Templates tests', () => { await test.step('2. Delete the template', async () => { await documentContentPage.executeMoreActions('Delete') - await documentContentPage.pressYesForPopup(page) }) await test.step('3. Check that the document status is equal to the deleted', async () => { diff --git a/qms-tests/sanity/tests/model/documents/document-content-page.ts b/qms-tests/sanity/tests/model/documents/document-content-page.ts index 0daf965e28..9c4c18a09f 100644 --- a/qms-tests/sanity/tests/model/documents/document-content-page.ts +++ b/qms-tests/sanity/tests/model/documents/document-content-page.ts @@ -81,6 +81,8 @@ export class DocumentContentPage extends DocumentCommonPage { readonly addMember: Locator readonly addMemberDropdown: Locator readonly changeSpaceButton: Locator + readonly createNewTemplateFromSpace: Locator + readonly okButton: Locator constructor (page: Page) { super(page) @@ -168,10 +170,12 @@ export class DocumentContentPage extends DocumentCommonPage { this.qualityButtonMembers = page.getByRole('button', { name: 'AJ DK AQ 3 members' }).first() this.userMemberCainVelasquez = page.getByRole('button', { name: 'VC Velasquez Cain' }) this.qualityDocument = page.getByRole('button', { name: 'Quality documents' }) - this.saveButton = page.getByRole('button', { name: 'Save' }) + this.saveButton = page.getByRole('button', { name: 'Save', exact: true }) this.addMember = page.getByText('Add member') this.addMemberDropdown = page.locator('.selectPopup') 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 }) } async checkDocumentTitle (title: string): Promise { @@ -306,6 +310,9 @@ export class DocumentContentPage extends DocumentCommonPage { async executeMoreActions (action: string): Promise { await this.buttonMoreActions.click() await this.selectFromDropdown(this.page, action) + if (action === 'Delete') { + await this.okButton.click() + } } async checkIfFolderExists (folderName: string): Promise { @@ -344,6 +351,15 @@ export class DocumentContentPage extends DocumentCommonPage { await this.createButton.click() } + async fillQuaraManager (spaceName: string): Promise { + await this.inputSpaceName.fill(spaceName) + await this.roleSelector.nth(2).click() + await this.page.getByRole('button', { name: 'DK Dirak Kainin' }).nth(2).click() + await this.page.keyboard.press('Escape') + await this.page.waitForTimeout(1000) + await this.createButton.click() + } + async fillDocumentSpaceFormManager (spaceName: string): Promise { await this.inputSpaceName.fill(spaceName) await this.roleSelector.nth(1).click() @@ -353,6 +369,53 @@ export class DocumentContentPage extends DocumentCommonPage { await this.createButton.click() } + async changeDocumentSpaceMembers (spaceName: string): Promise { + await this.page.getByRole('button', { name: spaceName }).hover() + await this.page.getByRole('button', { name: spaceName }).getByRole('button').click() + await this.editDocumentSpace.click() + await this.page.getByRole('button', { name: 'DK Dirak Kainin' }).first().click() + await this.page.getByRole('button', { name: 'DK Dirak Kainin' }).nth(3).click() + await this.page.getByRole('button', { name: 'AJ Appleseed John' }).click() + await this.page.keyboard.press('Escape') + await this.page.getByRole('button', { name: 'AJ DK 2 members' }).click() + await this.page.getByRole('button', { name: 'DK Dirak Kainin' }).nth(1).click() + await this.page.keyboard.press('Escape') + await this.page.waitForTimeout(1000) + await this.saveButton.click() + } + + async createDocumentSpaceMembersToJustMember (spaceName: string): Promise { + await this.inputSpaceName.fill(spaceName) + await this.page.getByRole('button', { name: 'DK Dirak Kainin' }).first().click() + await this.page.getByRole('button', { name: 'AJ Appleseed John' }).click() + await this.page.getByRole('button', { name: 'DK Dirak Kainin' }).nth(1).click() + await this.page.keyboard.press('Escape') + await this.page.waitForTimeout(1000) + await this.createButton.click() + } + + async checkIfTheSpaceIsVisible (spaceName: string, visible: boolean): Promise { + if (visible) { + await expect(this.page.getByRole('button', { name: spaceName })).toBeVisible() + } else { + await expect(this.page.getByRole('button', { name: spaceName })).not.toBeVisible() + } + } + + async checkIfEditSpaceButtonExists (spaceName: string, visible: boolean): Promise { + await this.page.getByRole('button', { name: spaceName }).hover() + await this.page.getByRole('button', { name: spaceName }).getByRole('button').click() + if (visible) { + await expect(this.editDocumentSpace).toBeVisible() + await expect(this.qualityButtonMembers).toBeVisible() + await expect(this.createNewTemplateFromSpace).toBeVisible() + } else { + await expect(this.createNewDocument).not.toBeVisible() + await expect(this.editDocumentSpace).not.toBeVisible() + await expect(this.createNewTemplateFromSpace).not.toBeVisible() + } + } + async checkSpaceFormIsCreated (spaceName: string): Promise { await expect(this.page.getByRole('button', { name: spaceName })).toBeVisible() } @@ -404,6 +467,19 @@ export class DocumentContentPage extends DocumentCommonPage { await this.checkDocumentStatus(DocumentStatus.DRAFT) } + async checkTeamMembersReviewerCoauthorApproverNotExists (): Promise { + await this.page.waitForTimeout(500) + await this.page.getByText('Team').click() + await this.page.getByText('Add member').first().click() + await expect(this.page.getByRole('button', { name: 'AJ Appleseed John' })).not.toBeVisible() + await this.page.keyboard.press('Escape') + await this.page.getByText('Add member').nth(1).click() + await expect(this.page.getByRole('button', { name: 'AJ Appleseed John' })).not.toBeVisible() + await this.page.keyboard.press('Escape') + await this.page.getByText('Add member').nth(2).click() + await expect(this.page.getByRole('button', { name: 'AJ Appleseed John' })).not.toBeVisible() + } + async checkIfHistoryVersionExists (description: string): Promise { await this.page.waitForTimeout(200) await expect(this.page.getByText(description)).toBeVisible() @@ -554,6 +630,18 @@ export class DocumentContentPage extends DocumentCommonPage { await expect(this.page.locator('span.text-editor-highlighted-node-delete', { hasText: text }).first()).toBeVisible() } + async checkIfUserCanSelectSpace (space: string, spaceExists: boolean): Promise { + await expect(this.page.getByRole('button', { name: space, exact: true })).toBeVisible() + await this.page.getByRole('button', { name: 'New document' }).click() + await this.changeSpaceButton.click() + if (spaceExists) { + await expect(this.page.getByRole('button', { name: space, exact: true }).nth(1)).toBeVisible() + } + if (!spaceExists) { + await expect(this.page.getByRole('button', { name: space, exact: true }).nth(1)).not.toBeVisible() + } + } + async openApprovals (): Promise { await expect(this.buttonDocumentApprovals).toBeVisible() await this.buttonDocumentApprovals.click({ position: { x: 1, y: 1 }, force: true }) diff --git a/qms-tests/sanity/tests/model/documents/documents-page.ts b/qms-tests/sanity/tests/model/documents/documents-page.ts index d8662495be..85d2e33aa0 100644 --- a/qms-tests/sanity/tests/model/documents/documents-page.ts +++ b/qms-tests/sanity/tests/model/documents/documents-page.ts @@ -40,7 +40,11 @@ export class DocumentsPage extends CalendarPage { this.changeSpaceButton = page.locator('[id="space\\.selector"]') } - async createDocument (data: NewDocument, startSecondStep: boolean = false): Promise { + async createDocument ( + data: NewDocument, + startSecondStep: boolean = false, + changeSpaceInCreateDocument: string = 'Quality documents' + ): Promise { if (data.location != null) { await this.buttonSpaceSelector.click() await this.selectListItemWithSearch(this.page, data.location.space ?? '') @@ -50,7 +54,7 @@ export class DocumentsPage extends CalendarPage { // template if (!startSecondStep) { - await this.changeSpaceInCreateDocumentForm('Quality documents') + await this.changeSpaceInCreateDocumentForm(changeSpaceInCreateDocument) await this.buttonPopupNextStep.click() } await this.page.locator('div.templates div.tmpHeader', { hasText: data.template }).click()