TESTS-9: feat(tests): added edit Talent test (#3871)

Signed-off-by: Alex Velichko <nestor_007@mail.ru>
This commit is contained in:
Alex Velichko 2023-10-24 05:52:44 +03:00 committed by GitHub
parent 26f533bc88
commit 6a3192bd66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 233 additions and 60 deletions

View File

@ -1,7 +1,7 @@
import { Page } from '@playwright/test'
export class CommonPage {
async fillSelectPopup (page: Page, name: string): Promise<void> {
async selectMenuItem (page: Page, name: string): Promise<void> {
if (name !== 'first') {
await page.locator('div.selectPopup input').fill(name)
}
@ -9,25 +9,29 @@ export class CommonPage {
}
async pressCreateButtonSelectPopup (page: Page): Promise<void> {
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<void> {
await page.locator('div.selectPopup div.header button:nth-of-type(1)').click()
}
async selectFromDropdown (page: Page, point: string): Promise<void> {
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<void> {
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<void> {
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<void> {
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<void> {
await page.locator('div.selectPopup input').fill(input)
await page.locator('div.selectPopup button').click()
}
async checkFromDropdown (page: Page, point: string): Promise<void> {
await page.locator('div.selectPopup span[class^="lines"]', { hasText: point }).click()
}
async pressYesDeletePopup (page: Page): Promise<void> {

View File

@ -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<void> {
await this.inputCommentComment.fill(comment)
await this.buttonSendComment.click()
}
async checkCommentExist (comment: string): Promise<void> {
await expect(await this.textComment.filter({ hasText: comment })).toBeVisible()
}
async addAttachments (filePath: string): Promise<void> {
await this.inputAddAttachment.setInputFiles(path.join(__dirname, `../../files/${filePath}`))
await expect(await this.textAttachmentName.filter({ hasText: filePath })).toBeVisible()
}
async addFirstReview (): Promise<void> {
await this.buttonCreateFirstReview.click()
await this.createNewReviewPopup(this.page, 'First Review', 'First review description')
}
async changeDoneStatus (status: string): Promise<void> {
await this.buttonChangeStatusDone.click()
await this.selectFromDropdown(this.page, status)

View File

@ -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<void> {
await this.buttonTalentSelector.click()
await this.fillSelectPopup(this.page, name)
await this.selectMenuItem(this.page, name)
}
async selectVacancy (name: string): Promise<void> {
await this.buttonSpaceSelector.click()
await this.fillSelectPopup(this.page, name)
await this.selectMenuItem(this.page, name)
}
async selectRecruiter (name: string): Promise<void> {
await this.buttonAssignedRecruiter.click()
await this.fillSelectPopup(this.page, name)
await this.selectMenuItem(this.page, name)
}
async openApplicationByTalentName (talentName: TalentName): Promise<void> {

View File

@ -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<void> {
await this.inputComment.fill(comment)
await this.buttonSendComment.click()
}
async checkCommentExist (comment: string): Promise<void> {
await expect(await this.textComment.filter({ hasText: comment })).toBeVisible()
}
async addAttachments (filePath: string): Promise<void> {
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<void> {
await this.buttonCreateFirstReview.click()
await this.createNewReviewPopup(this.page, reviewTitle, reviewDescription)
}
async createNewTalentPopup (page: Page, firstName: string, lastName: string): Promise<void> {
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<void> {
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<void> {
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<void> {
await this.buttonMoreActions.click()
await this.buttonDelete.click()
await this.pressYesDeletePopup(this.page)
}
}

View File

@ -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' })
}
}

View File

@ -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<void> {
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<void> {
await expect(await this.textTagItem).toContainText(skillTag)
}
async addSocialLinks (link: string, linkDescription: string): Promise<void> {
await this.buttonAddSocialLinks.click()
await this.selectFromDropdown(this.page, link)
await this.fillToDropdown(this.page, linkDescription)
}
async checkSocialLinks (link: string): Promise<void> {
switch (link) {
case 'Phone':
await expect(this.buttonContactPhone).toBeVisible()
break
default:
throw new Error(`Unknown case ${link}`)
}
}
async addTitle (title: string): Promise<void> {
await this.buttonInputTitle.click()
await this.fillToSelectPopup(this.page, title)
}
}

View File

@ -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<TalentName> {
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<void> {
await this.page
.locator('tr', { hasText: `${talentName.lastName} ${talentName.firstName}` })
.locator('div[class$="firstCell"]')
.click()
}
}

View File

@ -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 }) => {

View File

@ -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)
})
})