From 704503ef12e4826b830b86c448e07b97dcdc90ff Mon Sep 17 00:00:00 2001 From: Alex Velichko Date: Mon, 27 Nov 2023 12:17:36 +0300 Subject: [PATCH] TESTS-88: feat(tests): done Add comment from several users test (#4054) Signed-off-by: Alex Velichko --- .../tests/collaborative/applications.spec.ts | 95 +++++++++++++++++++ .../sanity/tests/collaborative/issues.spec.ts | 2 +- tests/sanity/tests/model/notification-page.ts | 7 +- .../recruiting/applications-details-page.ts | 16 ++++ 4 files changed, 118 insertions(+), 2 deletions(-) create mode 100644 tests/sanity/tests/collaborative/applications.spec.ts diff --git a/tests/sanity/tests/collaborative/applications.spec.ts b/tests/sanity/tests/collaborative/applications.spec.ts new file mode 100644 index 0000000000..c13b404580 --- /dev/null +++ b/tests/sanity/tests/collaborative/applications.spec.ts @@ -0,0 +1,95 @@ +import { test } from '@playwright/test' +import { getSecondPage, PlatformSetting, PlatformURI } from '../utils' +import { NavigationMenuPage } from '../model/recruiting/navigation-menu-page' +import { ApplicationsPage } from '../model/recruiting/applications-page' +import { ApplicationsDetailsPage } from '../model/recruiting/applications-details-page' +import { allure } from 'allure-playwright' +import { TalentName } from '../model/recruiting/types' +import { LeftSideMenuPage } from '../model/left-side-menu-page' +import { NotificationPage } from '../model/notification-page' + +test.use({ + storageState: PlatformSetting +}) + +test.describe('Collaborative tests for Application', () => { + test.beforeEach(async ({ page }) => { + await allure.parentSuite('Collaborative tests') + await (await page.goto(`${PlatformURI}/workbench/sanity-ws/recruit`))?.finished() + }) + + test('Add comment from several users', async ({ page, browser }) => { + const vacancyName = 'Software Engineer' + let talentName: TalentName + // open second page + const userSecondPage = await getSecondPage(browser) + + await test.step('User1. Add collaborators and comment from user1', async () => { + const navigationMenuPage = new NavigationMenuPage(page) + await navigationMenuPage.buttonApplications.click() + + const applicationsPage = new ApplicationsPage(page) + talentName = await applicationsPage.createNewApplicationWithNewTalent({ + vacancy: vacancyName, + recruiterName: 'first' + }) + await applicationsPage.selectType(vacancyName) + await applicationsPage.openApplicationByTalentName(talentName) + + const applicationsDetailsPage = new ApplicationsDetailsPage(page) + await applicationsDetailsPage.addCollaborators('Dirak Kainin') + await applicationsDetailsPage.addComment('Test Comment from user1') + await applicationsDetailsPage.checkCommentExist('Test Comment from user1') + }) + + await test.step('User2. Check notification and add comment from user2', async () => { + await (await userSecondPage.goto(`${PlatformURI}/workbench/sanity-ws/recruit`))?.finished() + + const leftSideMenuPageSecond = new LeftSideMenuPage(userSecondPage) + await leftSideMenuPageSecond.checkExistNewNotification(userSecondPage) + await leftSideMenuPageSecond.buttonNotification.click() + + const notificationPageSecond = new NotificationPage(userSecondPage) + await notificationPageSecond.checkNotificationCollaborators( + `${talentName.lastName} ${talentName.firstName}`, + 'You have been added to collaborators' + ) + + await (await userSecondPage.goto(`${PlatformURI}/workbench/sanity-ws/recruit`))?.finished() + const navigationMenuPageSecond = new NavigationMenuPage(userSecondPage) + await navigationMenuPageSecond.buttonApplications.click() + + const applicationsPageSecond = new ApplicationsPage(userSecondPage) + await applicationsPageSecond.selectType(vacancyName) + await applicationsPageSecond.openApplicationByTalentName(talentName) + + const applicationsDetailsPageSecond = new ApplicationsDetailsPage(userSecondPage) + await applicationsDetailsPageSecond.checkCommentExist('Test Comment from user1') + await applicationsDetailsPageSecond.addComment('Test Comment from user2') + await applicationsDetailsPageSecond.checkCommentExist('Test Comment from user2') + }) + + await test.step('User1. Check notification and check comment from user1', async () => { + const leftSideMenuPage = new LeftSideMenuPage(page) + await leftSideMenuPage.checkExistNewNotification(page) + await leftSideMenuPage.buttonNotification.click() + + const notificationPage = new NotificationPage(page) + await notificationPage.checkNotificationCollaborators( + `${talentName.lastName} ${talentName.firstName}`, + 'left a comment' + ) + + await (await page.goto(`${PlatformURI}/workbench/sanity-ws/recruit`))?.finished() + const navigationMenuPage = new NavigationMenuPage(page) + await navigationMenuPage.buttonApplications.click() + + const applicationsPage = new ApplicationsPage(page) + await applicationsPage.selectType(vacancyName) + await applicationsPage.openApplicationByTalentName(talentName) + + const applicationsDetailsPage = new ApplicationsDetailsPage(page) + await applicationsDetailsPage.checkCommentExist('Test Comment from user2') + }) + }) +}) diff --git a/tests/sanity/tests/collaborative/issues.spec.ts b/tests/sanity/tests/collaborative/issues.spec.ts index 9e0ef4ef3d..44729de03a 100644 --- a/tests/sanity/tests/collaborative/issues.spec.ts +++ b/tests/sanity/tests/collaborative/issues.spec.ts @@ -135,7 +135,7 @@ test.describe('Collaborative test for issue', () => { await leftSideMenuPageSecond.buttonNotification.click() const notificationPageSecond = new NotificationPage(userSecondPage) - await notificationPageSecond.checkNotification(issue.title, newAssignee) + await notificationPageSecond.checkNotificationIssue(issue.title, newAssignee) await leftSideMenuPageSecond.buttonTracker.click() }) diff --git a/tests/sanity/tests/model/notification-page.ts b/tests/sanity/tests/model/notification-page.ts index a5516c33fd..d517ec4d51 100644 --- a/tests/sanity/tests/model/notification-page.ts +++ b/tests/sanity/tests/model/notification-page.ts @@ -7,8 +7,13 @@ export class NotificationPage { this.page = page } - async checkNotification (name: string, assignee: string): Promise { + async checkNotificationIssue (name: string, assignee: string): Promise { const notification = this.page.locator('div[class*="inbox-activity"] span', { hasText: name }) await expect(notification.locator('xpath=../../..').locator('a span.ap-label')).toHaveText(assignee) } + + async checkNotificationCollaborators (name: string, text: string): Promise { + const notification = this.page.locator('div[class*="inbox-activity"] span', { hasText: name }) + await expect(notification.locator('xpath=../../..').locator('div[class*="title"]')).toHaveText(text) + } } diff --git a/tests/sanity/tests/model/recruiting/applications-details-page.ts b/tests/sanity/tests/model/recruiting/applications-details-page.ts index b98ab321eb..55135ee349 100644 --- a/tests/sanity/tests/model/recruiting/applications-details-page.ts +++ b/tests/sanity/tests/model/recruiting/applications-details-page.ts @@ -5,6 +5,7 @@ export class ApplicationsDetailsPage extends CommonRecruitingPage { readonly page: Page readonly textApplicationId: Locator readonly buttonState: Locator + readonly buttonSelectCollaborators: Locator constructor (page: Page) { super(page) @@ -14,6 +15,7 @@ export class ApplicationsDetailsPage extends CommonRecruitingPage { .locator('div[class*="collapsed-container"]') .nth(0) .locator('div[class*="aside-grid"] > div:nth-of-type(1) > button') + this.buttonSelectCollaborators = page.locator('xpath=//span[text()="Collaborators"]/..//button') } async getApplicationId (): Promise { @@ -27,4 +29,18 @@ export class ApplicationsDetailsPage extends CommonRecruitingPage { await this.selectFromDropdown(this.page, status) await expect(this.buttonState).toContainText(status) } + + async addCollaborators (name: string): Promise { + await this.buttonSelectCollaborators.click() + if (name === 'all') { + const checks = this.page.locator('div.popup button.menu-item') + const count = await checks.count() + for (let i = 0; i < count; i++) { + await checks.nth(i).click() + } + } else { + await this.page.locator('div.popup button.menu-item div.label', { hasText: name }).click() + } + await this.buttonSelectCollaborators.press('Escape') + } }