From 6a3192bd6604f98f1e66aa9f2b750044cddc09ed Mon Sep 17 00:00:00 2001 From: Alex Velichko Date: Tue, 24 Oct 2023 05:52:44 +0300 Subject: [PATCH] TESTS-9: feat(tests): added edit Talent test (#3871) Signed-off-by: Alex Velichko --- tests/sanity/tests/model/common-page.ts | 30 ++++---- .../recruiting/applications-details-page.ts | 42 +---------- .../model/recruiting/applications-page.ts | 12 +-- .../recruiting/common-recruiting-page.ts | 75 +++++++++++++++++++ .../model/recruiting/navigation-menu-page.ts | 2 + .../model/recruiting/talent-details-page.ts | 61 +++++++++++++++ .../tests/model/recruiting/talents-page.ts | 34 +++++++++ .../tests/recruiting/applications.spec.ts | 2 +- tests/sanity/tests/recruiting/talents.spec.ts | 35 ++++++++- 9 files changed, 233 insertions(+), 60 deletions(-) create mode 100644 tests/sanity/tests/model/recruiting/common-recruiting-page.ts create mode 100644 tests/sanity/tests/model/recruiting/talent-details-page.ts create mode 100644 tests/sanity/tests/model/recruiting/talents-page.ts diff --git a/tests/sanity/tests/model/common-page.ts b/tests/sanity/tests/model/common-page.ts index e419d9b578..2518a7e3a2 100644 --- a/tests/sanity/tests/model/common-page.ts +++ b/tests/sanity/tests/model/common-page.ts @@ -1,7 +1,7 @@ import { Page } from '@playwright/test' export class CommonPage { - async fillSelectPopup (page: Page, name: string): Promise { + async selectMenuItem (page: Page, name: string): Promise { if (name !== 'first') { await page.locator('div.selectPopup input').fill(name) } @@ -9,25 +9,29 @@ export class CommonPage { } async pressCreateButtonSelectPopup (page: Page): Promise { - await page.locator('div.selectPopup div.header button').click() + await page.locator('div.selectPopup div.header button:last-child').click() + } + + async pressShowAllButtonSelectPopup (page: Page): Promise { + await page.locator('div.selectPopup div.header button:nth-of-type(1)').click() } async selectFromDropdown (page: Page, point: string): Promise { - await page.locator('div.selectPopup span[class*="label"]', { hasText: point }).click() + await page.locator('div[class$="opup"] span[class*="label"]', { hasText: point }).click() } - async createNewTalentPopup (page: Page, firstName: string, lastName: string): Promise { - await page - .locator('div.popup form[id="recruit:string:CreateTalent"] input[placeholder="First name"]') - .fill(firstName) - await page.locator('div.popup form[id="recruit:string:CreateTalent"] input[placeholder="Last name"]').fill(lastName) - await page.locator('div.popup form[id="recruit:string:CreateTalent"] button[type="submit"]').click() + async fillToDropdown (page: Page, input: string): Promise { + await page.locator('div.popup input.search').fill(input) + await page.locator('div.popup button#channel-ok').click() } - async createNewReviewPopup (page: Page, title: string, description: string): Promise { - await page.locator('div.popup form[id="recruit:string:CreateReviewParams"] input[placeholder="Title"]').fill(title) - await page.locator('div.popup form[id="recruit:string:CreateReviewParams"] div.text-editor-view').fill(description) - await page.locator('div.popup form[id="recruit:string:CreateReviewParams"] button[type="submit"]').click() + async fillToSelectPopup (page: Page, input: string): Promise { + await page.locator('div.selectPopup input').fill(input) + await page.locator('div.selectPopup button').click() + } + + async checkFromDropdown (page: Page, point: string): Promise { + await page.locator('div.selectPopup span[class^="lines"]', { hasText: point }).click() } async pressYesDeletePopup (page: Page): Promise { diff --git a/tests/sanity/tests/model/recruiting/applications-details-page.ts b/tests/sanity/tests/model/recruiting/applications-details-page.ts index 4eebad840f..de6bbb1ffb 100644 --- a/tests/sanity/tests/model/recruiting/applications-details-page.ts +++ b/tests/sanity/tests/model/recruiting/applications-details-page.ts @@ -1,59 +1,23 @@ import { expect, type Locator, type Page } from '@playwright/test' -import path from 'path' -import { CommonPage } from '../common-page' +import { CommonRecruitingPage } from './common-recruiting-page' -export class ApplicationsDetailsPage extends CommonPage { +export class ApplicationsDetailsPage extends CommonRecruitingPage { readonly page: Page - readonly inputCommentComment: Locator - readonly buttonSendComment: Locator - readonly textComment: Locator - readonly inputAddAttachment: Locator - readonly textAttachmentName: Locator - readonly buttonCreateFirstReview: Locator readonly buttonChangeStatusDone: Locator readonly textApplicationId: Locator - readonly buttonMoreActions: Locator - readonly buttonDelete: Locator readonly buttonState: Locator constructor (page: Page) { - super() + super(page) this.page = page - this.inputCommentComment = page.locator('div.tiptap') - this.buttonSendComment = page.locator('g#Send') - this.textComment = page.locator('div.msgactivity-container p') - this.inputAddAttachment = page.locator('div.antiSection #file') - this.textAttachmentName = page.locator('div.name a') - this.buttonCreateFirstReview = page.locator('span:has-text("Create review")') this.buttonChangeStatusDone = page.locator('div[class*="aside-grid"] > div:nth-of-type(2) > button') this.textApplicationId = page.locator('div.popupPanel-title div.title-wrapper > span') - this.buttonMoreActions = page.locator('div.popupPanel-title div.buttons-group > button:nth-of-type(2)') - this.buttonDelete = page.locator('button[class*="menuItem"] span', { hasText: 'Delete' }) this.buttonState = page .locator('div[class*="collapsed-container"]') .nth(0) .locator('div[class*="aside-grid"] > div:nth-of-type(1) > button') } - async addComment (comment: string): Promise { - await this.inputCommentComment.fill(comment) - await this.buttonSendComment.click() - } - - async checkCommentExist (comment: string): Promise { - await expect(await this.textComment.filter({ hasText: comment })).toBeVisible() - } - - async addAttachments (filePath: string): Promise { - await this.inputAddAttachment.setInputFiles(path.join(__dirname, `../../files/${filePath}`)) - await expect(await this.textAttachmentName.filter({ hasText: filePath })).toBeVisible() - } - - async addFirstReview (): Promise { - await this.buttonCreateFirstReview.click() - await this.createNewReviewPopup(this.page, 'First Review', 'First review description') - } - async changeDoneStatus (status: string): Promise { await this.buttonChangeStatusDone.click() await this.selectFromDropdown(this.page, status) diff --git a/tests/sanity/tests/model/recruiting/applications-page.ts b/tests/sanity/tests/model/recruiting/applications-page.ts index c936cd1a86..5daf330757 100644 --- a/tests/sanity/tests/model/recruiting/applications-page.ts +++ b/tests/sanity/tests/model/recruiting/applications-page.ts @@ -1,9 +1,9 @@ import { expect, type Locator, type Page } from '@playwright/test' import { NewApplication, TalentName } from './types' -import { CommonPage } from '../common-page' import { generateId } from '../../utils' +import { CommonRecruitingPage } from './common-recruiting-page' -export class ApplicationsPage extends CommonPage { +export class ApplicationsPage extends CommonRecruitingPage { readonly page: Page readonly pageHeader: Locator readonly buttonCreateApplication: Locator @@ -15,7 +15,7 @@ export class ApplicationsPage extends CommonPage { readonly textTableFirstCell: Locator constructor (page: Page) { - super() + super(page) this.page = page this.pageHeader = page.locator('span[class*="header"]', { hasText: 'Applications' }) this.buttonCreateApplication = page.locator('button > span', { hasText: 'Application' }) @@ -59,17 +59,17 @@ export class ApplicationsPage extends CommonPage { async selectTalent (name: string): Promise { await this.buttonTalentSelector.click() - await this.fillSelectPopup(this.page, name) + await this.selectMenuItem(this.page, name) } async selectVacancy (name: string): Promise { await this.buttonSpaceSelector.click() - await this.fillSelectPopup(this.page, name) + await this.selectMenuItem(this.page, name) } async selectRecruiter (name: string): Promise { await this.buttonAssignedRecruiter.click() - await this.fillSelectPopup(this.page, name) + await this.selectMenuItem(this.page, name) } async openApplicationByTalentName (talentName: TalentName): Promise { diff --git a/tests/sanity/tests/model/recruiting/common-recruiting-page.ts b/tests/sanity/tests/model/recruiting/common-recruiting-page.ts new file mode 100644 index 0000000000..0c10a73d75 --- /dev/null +++ b/tests/sanity/tests/model/recruiting/common-recruiting-page.ts @@ -0,0 +1,75 @@ +import { expect, Locator, Page } from '@playwright/test' +import { CommonPage } from '../common-page' +import path from 'path' + +export class CommonRecruitingPage extends CommonPage { + readonly page: Page + readonly inputComment: Locator + readonly buttonSendComment: Locator + readonly textComment: Locator + readonly inputAddAttachment: Locator + readonly textAttachmentName: Locator + readonly buttonCreateFirstReview: Locator + readonly buttonMoreActions: Locator + readonly buttonDelete: Locator + + constructor (page: Page) { + super() + this.page = page + this.inputComment = page.locator('div.tiptap') + this.buttonSendComment = page.locator('g#Send') + this.textComment = page.locator('div.msgactivity-container p') + this.inputAddAttachment = page.locator('div.antiSection #file') + this.textAttachmentName = page.locator('div.name a') + this.buttonCreateFirstReview = page.locator('span:has-text("Create review")') + this.buttonMoreActions = page.locator('div.popupPanel-title div.buttons-group > button:nth-of-type(2)') + this.buttonDelete = page.locator('button[class*="menuItem"] span', { hasText: 'Delete' }) + } + + async addComment (comment: string): Promise { + await this.inputComment.fill(comment) + await this.buttonSendComment.click() + } + + async checkCommentExist (comment: string): Promise { + await expect(await this.textComment.filter({ hasText: comment })).toBeVisible() + } + + async addAttachments (filePath: string): Promise { + await this.inputAddAttachment.setInputFiles(path.join(__dirname, `../../files/${filePath}`)) + await expect(await this.textAttachmentName.filter({ hasText: filePath })).toBeVisible() + } + + async addFirstReview (reviewTitle: string, reviewDescription: string): Promise { + await this.buttonCreateFirstReview.click() + await this.createNewReviewPopup(this.page, reviewTitle, reviewDescription) + } + + async createNewTalentPopup (page: Page, firstName: string, lastName: string): Promise { + await page + .locator('div.popup form[id="recruit:string:CreateTalent"] input[placeholder="First name"]') + .fill(firstName) + await page.locator('div.popup form[id="recruit:string:CreateTalent"] input[placeholder="Last name"]').fill(lastName) + await page.locator('div.popup form[id="recruit:string:CreateTalent"] button[type="submit"]').click() + } + + async createNewReviewPopup (page: Page, title: string, description: string): Promise { + await page.locator('div.popup form[id="recruit:string:CreateReviewParams"] input[placeholder="Title"]').fill(title) + await page.locator('div.popup form[id="recruit:string:CreateReviewParams"] div.text-editor-view').fill(description) + await page.locator('div.popup form[id="recruit:string:CreateReviewParams"] button[type="submit"]').click() + } + + async addNewTagPopup (page: Page, title: string, description: string): Promise { + await page.locator('div.popup form[id="tags:string:AddTag"] input[placeholder$="title"]').fill(title) + await page + .locator('div.popup form[id="tags:string:AddTag"] input[placeholder="Please type description here"]') + .fill(description) + await page.locator('div.popup form[id="tags:string:AddTag"] button[type="submit"]').click() + } + + async deleteEntity (): Promise { + await this.buttonMoreActions.click() + await this.buttonDelete.click() + await this.pressYesDeletePopup(this.page) + } +} diff --git a/tests/sanity/tests/model/recruiting/navigation-menu-page.ts b/tests/sanity/tests/model/recruiting/navigation-menu-page.ts index 9d5921dd56..41f616b626 100644 --- a/tests/sanity/tests/model/recruiting/navigation-menu-page.ts +++ b/tests/sanity/tests/model/recruiting/navigation-menu-page.ts @@ -4,10 +4,12 @@ export class NavigationMenuPage { readonly page: Page readonly buttonApplications: Locator readonly buttonMyApplications: Locator + readonly buttonTalents: Locator constructor (page: Page) { this.page = page this.buttonApplications = page.locator('a[href$="candidates"]', { hasText: 'Applications' }) this.buttonMyApplications = page.locator('a[href$="my-applications"]', { hasText: 'My applications' }) + this.buttonTalents = page.locator('a[href$="talents"]', { hasText: 'Talents' }) } } diff --git a/tests/sanity/tests/model/recruiting/talent-details-page.ts b/tests/sanity/tests/model/recruiting/talent-details-page.ts new file mode 100644 index 0000000000..fa280f6164 --- /dev/null +++ b/tests/sanity/tests/model/recruiting/talent-details-page.ts @@ -0,0 +1,61 @@ +import { expect, type Locator, type Page } from '@playwright/test' +import { CommonRecruitingPage } from './common-recruiting-page' + +export class TalentDetailsPage extends CommonRecruitingPage { + readonly page: Page + readonly buttonAddSkill: Locator + readonly textTagItem: Locator + readonly buttonAddSocialLinks: Locator + readonly buttonContactPhone: Locator + readonly inputLocation: Locator + readonly buttonInputTitle: Locator + + constructor (page: Page) { + super(page) + this.page = page + this.buttonAddSkill = page.locator('button#add-tag') + this.textTagItem = page.locator('div.tag-item') + this.buttonAddSocialLinks = page.locator('button[id="presentation:string:AddSocialLinks"]') + this.buttonContactPhone = page.locator( + 'div[class^="popupPanel-body"] div.horizontal button[id="contact:string:Phone"]' + ) + this.inputLocation = page.locator('div.location input') + this.buttonInputTitle = page.locator('button > span', { hasText: 'Title' }) + } + + async addSkill (skillTag: string, skillDescription: string): Promise { + await this.buttonAddSkill.click() + await this.pressCreateButtonSelectPopup(this.page) + await this.addNewTagPopup(this.page, skillTag, skillDescription) + + await this.pressShowAllButtonSelectPopup(this.page) + await this.checkFromDropdown(this.page, skillTag) + + await this.page.keyboard.press('Escape') + } + + async checkSkill (skillTag: string): Promise { + await expect(await this.textTagItem).toContainText(skillTag) + } + + async addSocialLinks (link: string, linkDescription: string): Promise { + await this.buttonAddSocialLinks.click() + await this.selectFromDropdown(this.page, link) + await this.fillToDropdown(this.page, linkDescription) + } + + async checkSocialLinks (link: string): Promise { + switch (link) { + case 'Phone': + await expect(this.buttonContactPhone).toBeVisible() + break + default: + throw new Error(`Unknown case ${link}`) + } + } + + async addTitle (title: string): Promise { + await this.buttonInputTitle.click() + await this.fillToSelectPopup(this.page, title) + } +} diff --git a/tests/sanity/tests/model/recruiting/talents-page.ts b/tests/sanity/tests/model/recruiting/talents-page.ts new file mode 100644 index 0000000000..c2772acf04 --- /dev/null +++ b/tests/sanity/tests/model/recruiting/talents-page.ts @@ -0,0 +1,34 @@ +import { type Locator, type Page } from '@playwright/test' +import { TalentName } from './types' +import { generateId } from '../../utils' +import { CommonRecruitingPage } from './common-recruiting-page' + +export class TalentsPage extends CommonRecruitingPage { + readonly page: Page + readonly pageHeader: Locator + readonly buttonCreateTalent: Locator + + constructor (page: Page) { + super(page) + this.page = page + this.pageHeader = page.locator('span[class*="header"]', { hasText: 'Talents' }) + this.buttonCreateTalent = page.locator('div[class*="ac-header"] button > span', { hasText: 'Talent' }) + } + + async createNewTalent (): Promise { + const talentName: TalentName = { + firstName: `TestFirst-${generateId(4)}`, + lastName: `TestLast-${generateId(4)}` + } + await this.buttonCreateTalent.click() + await this.createNewTalentPopup(this.page, talentName.firstName, talentName.lastName) + return talentName + } + + async openTalentByTalentName (talentName: TalentName): Promise { + await this.page + .locator('tr', { hasText: `${talentName.lastName} ${talentName.firstName}` }) + .locator('div[class$="firstCell"]') + .click() + } +} diff --git a/tests/sanity/tests/recruiting/applications.spec.ts b/tests/sanity/tests/recruiting/applications.spec.ts index 00ce652681..6f7fadddf0 100644 --- a/tests/sanity/tests/recruiting/applications.spec.ts +++ b/tests/sanity/tests/recruiting/applications.spec.ts @@ -76,7 +76,7 @@ test.describe('Application tests', () => { await applicationsDetailsPage.addAttachments('cat.jpeg') - await applicationsDetailsPage.addFirstReview() + await applicationsDetailsPage.addFirstReview('First Application Review', 'First Application review description') }) test('Change Done status', async ({ page }) => { diff --git a/tests/sanity/tests/recruiting/talents.spec.ts b/tests/sanity/tests/recruiting/talents.spec.ts index 447dc03ab8..8a5ac5c712 100644 --- a/tests/sanity/tests/recruiting/talents.spec.ts +++ b/tests/sanity/tests/recruiting/talents.spec.ts @@ -1,15 +1,19 @@ import { expect, test } from '@playwright/test' import { generateId, PlatformSetting, PlatformURI } from '../utils' +import { NavigationMenuPage } from '../model/recruiting/navigation-menu-page' +import { TalentsPage } from '../model/recruiting/talents-page' +import { TalentDetailsPage } from '../model/recruiting/talent-details-page' test.use({ storageState: PlatformSetting }) -test.describe('candidate tests', () => { +test.describe('candidate/talents tests', () => { test.beforeEach(async ({ page }) => { // Create user and workspace await (await page.goto(`${PlatformURI}/workbench/sanity-ws/recruit`))?.finished() }) + test('create-candidate', async ({ page, context }) => { await page.locator('[id="app-recruit\\:string\\:RecruitApplication"]').click() @@ -58,4 +62,33 @@ test.describe('candidate tests', () => { await panel.locator('[id="gmail\\:string\\:Email"]').click() expect(await page.locator('.cover-channel >> input').inputValue()).toEqual(email) }) + + test('Edit the Talent', async ({ page, context }) => { + const navigationMenuPage = new NavigationMenuPage(page) + await navigationMenuPage.buttonTalents.click() + + const talentsPage = new TalentsPage(page) + const talentName = await talentsPage.createNewTalent() + + await talentsPage.openTalentByTalentName(talentName) + + const talentDetailsPage = new TalentDetailsPage(page) + await talentDetailsPage.addComment('Test Talent Detail 123') + await talentDetailsPage.checkCommentExist('Test Talent Detail 123') + + await talentDetailsPage.addAttachments('cat.jpeg') + + await talentDetailsPage.addFirstReview('First Talent Review', 'First Talent review description') + + const skillTag = `React-${generateId(4)}` + await talentDetailsPage.addSkill(skillTag, 'Description Java from Talent Description page') + await talentDetailsPage.checkSkill(skillTag) + + await talentDetailsPage.addSocialLinks('Phone', '123123213213') + await talentDetailsPage.checkSocialLinks('Phone') + + await talentDetailsPage.inputLocation.fill('Awesome Location') + const title = `Title-${generateId(4)}` + await talentDetailsPage.addTitle(title) + }) })