Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions tests/sanity/tests/model/common-page.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,37 @@
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)
}
await page.locator('div.selectPopup div.list-item:first-child').click()
}

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 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 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 fillToSelectPopup (page: Page, input: string): Promise<void> {
await page.locator('div.selectPopup input').fill(input)
await page.locator('div.selectPopup button').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 checkFromDropdown (page: Page, point: string): Promise<void> {
await page.locator('div.selectPopup span[class^="lines"]', { hasText: point }).click()
}

async pressYesDeletePopup (page: Page): Promise<void> {
Expand Down
42 changes: 3 additions & 39 deletions tests/sanity/tests/model/recruiting/applications-details-page.ts
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
12 changes: 6 additions & 6 deletions tests/sanity/tests/model/recruiting/applications-page.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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' })
Expand Down Expand Up @@ -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> {
Expand Down
75 changes: 75 additions & 0 deletions tests/sanity/tests/model/recruiting/common-recruiting-page.ts
Original file line number Diff line number Diff line change
@@ -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)
}
}
2 changes: 2 additions & 0 deletions tests/sanity/tests/model/recruiting/navigation-menu-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' })
}
}
61 changes: 61 additions & 0 deletions tests/sanity/tests/model/recruiting/talent-details-page.ts
Original file line number Diff line number Diff line change
@@ -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)
}
}
34 changes: 34 additions & 0 deletions tests/sanity/tests/model/recruiting/talents-page.ts
Original file line number Diff line number Diff line change
@@ -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()
}
}
2 changes: 1 addition & 1 deletion tests/sanity/tests/recruiting/applications.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down
Loading