TESTS-22: feat(tests): done test Merge Contacts (#3891)

Signed-off-by: Alex Velichko <nestor_007@mail.ru>
This commit is contained in:
Alex Velichko 2023-10-26 06:34:22 +03:00 committed by GitHub
parent b0650fb8b8
commit 4d0d29bc8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 123 additions and 0 deletions

View File

@ -1,5 +1,6 @@
import { expect, type Locator, type Page } from '@playwright/test'
import { CommonRecruitingPage } from './common-recruiting-page'
import { MergeContacts } from './types'
export class TalentDetailsPage extends CommonRecruitingPage {
readonly page: Page
@ -9,6 +10,12 @@ export class TalentDetailsPage extends CommonRecruitingPage {
readonly buttonContactPhone: Locator
readonly inputLocation: Locator
readonly buttonInputTitle: Locator
readonly buttonInputSource: Locator
readonly buttonContactEmail: Locator
readonly buttonMergeContacts: Locator
readonly buttonFinalContact: Locator
readonly buttonMergeRow: Locator
readonly buttonPopupMergeContacts: Locator
constructor (page: Page) {
super(page)
@ -21,6 +28,18 @@ export class TalentDetailsPage extends CommonRecruitingPage {
)
this.inputLocation = page.locator('div.location input')
this.buttonInputTitle = page.locator('button > span', { hasText: 'Title' })
this.buttonInputSource = page.locator('button > span', { hasText: 'Source' })
this.buttonContactEmail = page.locator(
'div[class^="popupPanel-body"] div.horizontal button[id="gmail:string:Email"]'
)
this.buttonMergeContacts = page.locator('button[class*="menuItem"] span', { hasText: 'Merge contacts' })
this.buttonFinalContact = page.locator('form[id="contact:string:MergePersons"] button', {
hasText: 'Final contact'
})
this.buttonMergeRow = page.locator('form[id="contact:string:MergePersons"] div.box')
this.buttonPopupMergeContacts = page.locator('form[id="contact:string:MergePersons"] button > span', {
hasText: 'Merge contacts'
})
}
async addSkill (skillTag: string, skillDescription: string): Promise<void> {
@ -49,6 +68,9 @@ export class TalentDetailsPage extends CommonRecruitingPage {
case 'Phone':
await expect(this.buttonContactPhone).toBeVisible()
break
case 'Email':
await expect(this.buttonContactEmail).toBeVisible()
break
default:
throw new Error(`Unknown case ${link}`)
}
@ -58,4 +80,40 @@ export class TalentDetailsPage extends CommonRecruitingPage {
await this.buttonInputTitle.click()
await this.fillToSelectPopup(this.page, title)
}
async addSource (source: string): Promise<void> {
await this.buttonInputSource.click()
await this.fillToSelectPopup(this.page, source)
}
async mergeContacts (talentName: MergeContacts): Promise<void> {
await this.buttonMoreActions.click()
await this.buttonMergeContacts.click()
await this.buttonFinalContact.click()
await this.selectMenuItem(this.page, talentName.finalContactName)
await this.buttonMergeRow.locator('div.flex-center', { hasText: talentName.name }).locator('label.checkbox').click()
if (talentName.mergeLocation) {
await this.buttonMergeRow
.locator('div.flex-center', { hasText: talentName.location })
.locator('label.checkbox')
.click()
}
if (talentName.mergeTitle) {
await this.buttonMergeRow
.locator('div.flex-center', { hasText: talentName.title })
.locator('label.checkbox')
.click()
}
if (talentName.mergeSource) {
await this.buttonMergeRow
.locator('div.flex-center', { hasText: talentName.source })
.locator('label.checkbox')
.click()
}
await this.buttonPopupMergeContacts.click()
}
}

View File

@ -8,3 +8,14 @@ export interface TalentName {
firstName: string
lastName: string
}
export interface MergeContacts {
finalContactName: string
name: string
mergeLocation: boolean
location: string
mergeTitle: boolean
title: string
mergeSource: boolean
source: string
}

View File

@ -107,4 +107,58 @@ test.describe('candidate/talents tests', () => {
await navigationMenuPage.buttonTalents.click()
await talentsPage.checkTalentNotExist(talentName)
})
test('Merge contacts', async ({ page, context }) => {
const navigationMenuPage = new NavigationMenuPage(page)
await navigationMenuPage.buttonTalents.click()
const talentsPage = new TalentsPage(page)
// talent1
const talentNameFirst = await talentsPage.createNewTalent()
await talentsPage.openTalentByTalentName(talentNameFirst)
let talentDetailsPage = new TalentDetailsPage(page)
await talentDetailsPage.inputLocation.fill('Awesome Location Merge1')
const titleTalent1 = 'TitleMerge1'
await talentDetailsPage.addTitle(titleTalent1)
const sourceTalent1 = 'SourceTalent1'
await talentDetailsPage.addSource(sourceTalent1)
await talentDetailsPage.addSocialLinks('Phone', '123123213213')
await talentDetailsPage.checkSocialLinks('Phone')
// talent 2
await navigationMenuPage.buttonTalents.click()
const talentNameSecond = await talentsPage.createNewTalent()
await talentsPage.openTalentByTalentName(talentNameSecond)
talentDetailsPage = new TalentDetailsPage(page)
await talentDetailsPage.inputLocation.fill('Awesome Location Merge2')
const titleTalent2 = 'TitleMerge2'
await talentDetailsPage.addTitle(titleTalent2)
const sourceTalent2 = 'SourceTalent2'
await talentDetailsPage.addSource(sourceTalent2)
await talentDetailsPage.addSocialLinks('Email', 'test-merge-2@gmail.com')
await talentDetailsPage.checkSocialLinks('Email')
// merge
await navigationMenuPage.buttonTalents.click()
await talentsPage.openTalentByTalentName(talentNameFirst)
await talentDetailsPage.mergeContacts({
finalContactName: talentNameSecond.lastName,
name: `${talentNameFirst.lastName} ${talentNameFirst.firstName}`,
mergeLocation: true,
location: 'Awesome Location Merge1',
mergeTitle: true,
title: titleTalent1,
mergeSource: true,
source: sourceTalent1
})
await navigationMenuPage.buttonTalents.click()
await talentsPage.openTalentByTalentName(talentNameFirst)
await talentDetailsPage.checkSocialLinks('Phone')
await talentDetailsPage.checkSocialLinks('Email')
await expect(talentDetailsPage.inputLocation).toHaveValue('Awesome Location Merge1')
await expect(talentDetailsPage.page.locator('button > span', { hasText: titleTalent2 })).toBeVisible()
await expect(talentDetailsPage.page.locator('button > span', { hasText: sourceTalent2 })).toBeVisible()
})
})